java - Using multiple ResourceBundles -
i'm create game, , @ start i'm asking user 1/2/3 number input confirm language selection (1 dutch, 2 french, 3 english). have 3 properties files resourcebundles have no idea how load them game. when user puts in 1 in joptionpane, there should method (or something?) sets "language" dutch (cuz nr 1 inserted), or french if 2 inserted or 3 english.
and has work on several app-classes, startplayerapp, startworldmap, etc... in startplayerapp example ask user enter name, after language selection, if picked dutch should ask "wat uw naam?", if picked english "what name?" etc...
for works, "hardcoded" in string in normal dutch, it's unilanguage compatible now, not multilanguage :(
if me possible (preferably before end of week :p) amazing gesture! it's schoolproject :(!!
name resource files reflect language:
myresource.properties myresource_fr.properties ...
then use resourcebundle , let detect language , load appropriate file:
resourcebundle.getbundle("myresource", locale.getdefault());
finally, message need, use:
messages.resources.getstring(identifier);
note not passing _fr
it, automagically added if case. if language requested not available, default plain myresource.strings
, should put english translation there.
Comments
Post a Comment