Search code examples
javaresourcesresourcebundle

superscripting text in resource bundle in java


has anyone included superscripted text in a resource bundle? any advice on this matter would be appreciated!

ie: programmingpanda

thanks, panda


Solution

  • Resource bundles are plain-text. So even if you are to include presentation details, it will depend on where is it going to be displayed.

    For example, if it is displayed on html page, you can use:

    key=text<sup>super</sup>
    

    If it is going to have multiple presentations, then you may define your custom presentation scheme and to parse it according to the presentation type. For example:

    key=text^^sup^^
    
    public String format(key, PresentationType type) {
        if (type = PresentationType.HTML) {
           // parse the input with regex and put <sup>..</sup>
        }
        if (type = PresentationType.DOC) {
           // doc-specific superscript
        }
        etc..
    }