1
votes

I'm implementing multiple language support for my application. For now in my default values folder I have strings for english locale. I also have a folder for swedish values-sv. I want to let the user to be able to choose the locale manually, for that I need to display a list with supported languages.

Is there a way to get which locales are supported(have their own values folder)?

So far I have:

String[] languages = getResources().getAssets().getLocales();

But this returns all the languages that are supported by this Android version but it does not make sense to show that long list. I only need the languages supported by my application.

2

2 Answers

1
votes

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

0
votes

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.