Click to See Complete Forum and Search --> : Formtting text within resource bundle .properties files


dylanmac
July 17th, 2009, 06:31 PM
So I have a resource bundle with key/value pairs, e.g.

alert.NoPromoCodeRequired=No promotion code required.

If I wanted to bold, say, the "promotion code" phrase within the first sentence of the text value above, how would I accomplish that? Can I just dump html into the properties file, like so?

alert.NoPromoCodeRequired=No <span class="baseCopyEm">promotion code</span> required.

This strikes me as NOT a best practice but I canot find any guidance.

Conversely creating three separate key values ("No", "promotion code" and "required") pulling them each into the web page than applying html around the second text value does not seem like the way to go either.

Thanks.

dlorde
July 18th, 2009, 02:26 AM
Can I just dump html into the properties file, like so?

alert.NoPromoCodeRequired=No <span class="baseCopyEm">promotion code</span> required.I don't see why not - you need some way to indicate the formatting, and HTML has the tags for the job, plus you can plug it directly into your display component.

This strikes me as NOT a best practice but I canot find any guidance.Why, what's wrong with it? If you want the property to be more readable in the property file, you could put each part on a separate logical line (still for the one property), using the '\' to escape the line termination (see Properties.load(Reader reader) (http://java.sun.com/javase/6/docs/api/java/util/Properties.html#load(java.io.Reader))).

Conversely creating three separate key values ("No", "promotion code" and "required") pulling them each into the web page than applying html around the second text value does not seem like the way to go either.I agree that doesn't seem particularly helpful.

The outcome of any serious research can only be to make two questions grow where only one grew before...
T. Veblen

dylanmac
July 24th, 2009, 07:01 PM
Alright thanks for reply!