Reputation: 147
I wonder where do I put my Bundle file for internationalization. The Libgdx wiki doesn't explain where (Android assets folder?) and they use as example the name of file called MyBundle. May I use another name? My apologize for my naivety.
Upvotes: 3
Views: 1786
Reputation: 196
In case you would like to use the phone locals : Create an i18n in assets folder and a subfolder (example MyBundle). Insite this folder put files : - MyBundle.properties (defaults values, exemple : game=Game) - MyBundle_en.properties (game=Game) - MyBundle_fr.properties
Initialization : FileHandle internal = Gdx.files.internal("i18n/MyBundle"); I18NBundle local = I18NBundle.createBundle(internal, Locale.getDefault());
Use : String sTitre=local.get("game");
Upvotes: 0
Reputation: 196
If you want to use the default local :
FileHandle internal = Gdx.files.internal("i18n/MyBundle");
I18NBundle local = I18NBundle.createBundle(internal, Locale.getDefault());
Upvotes: 1
Reputation: 20140
Create i18n folder in assets of android module. create different properties files in i18n folder like lang.properties, lang_es.properties, lang_fr.properties etc.
Then I use this code in my project.
FileHandle internal = Gdx.files.internal("i18n/lang");
I18NBundle local = I18NBundle.createBundle(internal, Locale.ROOT);
I18NBundle portuguese = I18NBundle.createBundle(internal, new Locale("pt"));
Upvotes: 1
Reputation: 3102
First argument of I18NBundle constructor is a FileHandle instance. That's mean that you are not limited by one specific folder. See this wiki entry on file handling in libGDX. I suppose you use sample from official wiki and it has this line:
FileHandle baseFileHandle = Gdx.files.internal("i18n/MyBundle");
In this particular case, when we use Gdx.files.internal
, bundle must be located in Android project's assets
folder. There is no restrictions on file name also.
Upvotes: 3