views:

53

answers:

2

Hi,

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

ie: programmingpanda

thanks, panda

+2  A: 

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..
}
Bozho
thanks all for your help!
programming panda
+3  A: 

Depends on your notion of "text". A Java string contains unicode characters and Unicode does not have a notion of superscripted text, so you will need some kind of interpretation depending on context.

A frequent context is HTML, and there "programming<sup>panda</sup>" is a perfectly valid text string you can have in a resource bundle. Please note that there are several ways to provide the value for the lookup key, one is a property file and another one is code. All have advantages and disadvantages.

I recommend you look at the appropriate chapter in the Sun Java Tutorial: http://java.sun.com/docs/books/tutorial/i18n/resbundle/index.html

Thorbjørn Ravn Andersen