Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Though using a <code>ResourceBundle</code> is the traditional and most well-known approach to internationalization in Java, it is possible to make internationalization data available as class members, somewhat similar to the way you seek.</p> <p>You can further put your strings for some message in different languages in a <code>Map</code>, indexed by language. And make this Map a static member of some class. Thus you get the ability to reference these string collections for messages by their class member names in a compiler-checked manner. And next, if you have a way to select preferred user language at run time (you have to have it), you just pick the right string from an appropriate collection using its language key, boiling down to something like this:</p> <pre><code>logger.info (MyClassWithMessages.MY_MULTILANGUAGE_MESSAGE.s ()); </code></pre> <p>And the <code>s()</code> method to be added to your <code>Map</code> subclass can be made resposible for dealing with user preferences and selection from <code>Map</code> by language key.</p> <p>That said, the remaining task is just to formulate a convenient API for all this... You are welcome to have a look at such an implementation on my blog page <a href="http://s-n-ushakov.blogspot.ru/2013/02/look-ma-no-resourcebundle-or-yet.html" rel="nofollow">Look Ma, no ResourceBundle :) ...</a>, and the <a href="http://s-n-ushakov.blogspot.ru/2013/06/look-ma-no-resourcebundle-step-2.html" rel="nofollow">next page</a> that goes ahead with message formatting arguments.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload