简体   繁体   中英

I18N : Constants needed in constant (Java/GWT)

I I18N an application. Part of it consists in I18N-ing the menus. That is OK.
With GWT I can use the Constants interface.
Now I have to I18N the help for the app, which includes some text referring to Menus.
So in these bigger constants, I need to use the menu constants.

Exemple :
I have a resource in the property file for I18N :

menuPlay = Play ...

Now I want to define another resource = some help text:

howToPlay = In order to start the game, go to the menu ??<resource menuPlay>??

In question marks above, I want to use the resource menuPlay.

When I want to translate eg in French, the two resources would be :

menuPlay = Jouer...
howToPlay = Pour démarrer le jeu, aller au menu ??<resource menuPlay>??

How can I do that (in Java / GWT) ? I mean is there an off-the-shelf solution (which I could not find or think of). I don't want to code some specific solution that would combine both --in real time-- based on localized info.
This would help prevent inconsistencies when changing the menuPlay resource : no need to bother on changing the other resource howToPlay (high risks to forget).

Then you property is like

menuPlay = Play ...
howToPlay = In order to start the game, go to the menu {0}

while using

inorder to get menuPlay then in java you may using like resource.menuPlay();

now inorder to get howtoPlay

resource.howToPlay(resource.menuPlay()); //now {0} replaces with Play

you can do it for no.of arguments

howToPlay = In order to start the game, go to the menu {0} {1} ..etc

see message patterns

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM