1

我正在为我的应用程序实现多语言支持。现在在我的默认values文件夹中,我有英语语言环境的字符串。我还有一个 swedish 文件夹values-sv。我想让用户能够手动选择语言环境,因为我需要显示一个支持语言的列表。

有没有办法获得支持的语言环境(有自己的值文件夹)?

到目前为止,我有:

String[] 语言 = getResources().getAssets().getLocales();

但这会返回此 Android 版本支持的所有语言,但显示那长长的列表是没有意义的。我只需要我的应用程序支持的语言。

4

2 回答 2

1

Well in your You can show a spinner/dialog chooser to user with items of supported languages that you have and can tell your app which resources you have to select

Suppose if you have spanish and englih language:

show a spinner with values i.e: Spanish,English the upon user selected value set the Locale to Spanish Or Either English

于 2013-08-26T12:32:47.537 回答
0

Hardcode it.

Or, write a script that generates a snippet of Java code based on what is in your res/values/ directory, and integrate that script into your build process. This may be easier with the new Gradle-based build system as it moves towards release status.

于 2013-08-26T12:32:09.643 回答