我想知道我应该把我的包文件放在哪里以实现国际化。Libgdx wiki没有解释在哪里(Android assets文件夹?)他们使用名为MyBundle的文件名作为示例。我可以用另一个名字吗?我为我的天真道歉。
发布于 2015-01-27 07:52:33
I18NBundle构造函数的第一个参数是一个FileHandle实例。这意味着您不受某个特定文件夹的限制。有关libGDX中的文件处理,请参阅this wiki entry。我假设你使用来自官方维基的示例,它有这样一行:
FileHandle baseFileHandle = Gdx.files.internal("i18n/MyBundle");在本例中,当我们使用Gdx.files.internal时,包必须位于Android项目的assets文件夹中。对文件名也没有限制。
发布于 2016-11-05 15:45:54
在android模块的assets中创建i18n文件夹。在i18n文件夹中创建不同的属性文件,如lang.properties、lang_es.properties、lang_fr.properties等。
然后,我在我的项目中使用此代码。
FileHandle internal = Gdx.files.internal("i18n/lang");
I18NBundle local = I18NBundle.createBundle(internal, Locale.ROOT);
I18NBundle portuguese = I18NBundle.createBundle(internal, new Locale("pt"));发布于 2020-05-12 04:00:23
如果您想要使用默认本地:
FileHandle internal = Gdx.files.internal("i18n/MyBundle");
I18NBundle local = I18NBundle.createBundle(internal, Locale.getDefault());https://stackoverflow.com/questions/28160566
复制相似问题