CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009
    Posts
    2

    Formtting text within resource bundle .properties files

    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.

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Formtting text within resource bundle .properties files

    Quote Originally Posted by dylanmac View Post
    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)).

    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
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    Jul 2009
    Posts
    2

    Re: Formtting text within resource bundle .properties files

    Alright thanks for reply!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured