5

I know that already exists a Locale.getAvailableLocales() function and some other similars witch returns all the avaiable languages (regardless of whether they are available on your mobile phone or no)

I'm looking a method to return just the languages that i made the translation (i.e.: if i have the 3 folders values-en, values-es, values-pt; i hope get the response: [en, es, pt], or [english, spanish, portuguese]

Ira Baxter
  • 93,541
  • 22
  • 172
  • 341
  • Hi, I am looking for this type of implementation. Is there any way to get the response as [en,es,pt].? – Karthick Jun 06 '13 at 12:08

1 Answers1

0

Locale.getAvailableLocales() will give you a list of system-wide available Locales. These are used to format dates, times, numbers and alike. It has nothing to do with your application localization files.

I am guessing that you want to switch languages at runtime and that is why you want to enumerate over list of languages. Well, you probably need to create specific configuration file with that list and read that at runtime. Adding L10n files would require another step - registering it in you configuration file.
Alternatively you may want to enumerate resource directories (values-<Locale-ID>) and grab supported Locales from their names, but I don't think it is the most elegant solution. However, it works without any registration...

Paweł Dyda
  • 18,366
  • 7
  • 57
  • 79