Skip to content Skip to sidebar Skip to footer

How To List Languages Supported By My Application

The application has a number of localization folders: values-cs values-da values-de values-es ... How can I enumerate all the supported languages at runtime? Sure, I can define so

Solution 1:

I think this could work...

enumLanguage {
      en, fr, de, cs
}

And then in your activity...

List<Language> langs = new ArrayList<Language>();
for(String lan : ctx.getAssets().list("/res")) {
 if(lan.startsWith("values-")) {
   langs.add(Language.valueOf(lan.substring(lan.lastIndexOf('-') + 1)))'
 }
}

Post a Comment for "How To List Languages Supported By My Application"