This discussion is archived
1 Reply Latest reply: Feb 26, 2011 7:02 AM by baftos RSS

Resource Bundle Multiple Keys

843027 Newbie
Currently Being Moderated
Hii all
Is there any possibility to represent multiple keys in a ResourceBundle with single (Same) Value
Instead of writing all the keys one bye one following by its value.

For Example,

If we have four First Name Keys as First,First_1,First_2 = Google
then can we represent some thing like this

First,First_1,First_2=Google
  • 1. Re: Resource Bundle Multiple Keys
    baftos Expert
    Currently Being Moderated
    The API offers two sub-classes of ResourceBundle: ListResourceBundle and PropertiesResourceBundle.
    You seem to use PropertiesResourceBundle. Each of those sub-classes prescribe the format of the data.
    ListResourceBundle expects a class file, while PropertiesResourceBundle expects a properties file.
    The syntax you propose is not valid for a properties file, so the answer is no.
    On the other hand, nothing prevents you from sub-classing ResourceBundle yourself and use your own format.
    But why? Is it worth the extra work and the fact that you would not use the established conventions?

    Edit. I am trying to guess why you want this. One valid reason I can imagine is that you have to pass those files to translators and they charge per word.
    They would not bother to detect duplicates and charge you less. If so, you can quite easily write an offline utility that converts back and forth between the PropertiesResourceBundle format and the one you propose. This way you keep your program clean and easy to understand, while the utility takes care of your 'administrative' issues.

    Edited by: baftos on Feb 26, 2011 9:56 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points