1

My android app has below values directories:

enter image description here

Now, if I set my device language (via Settings) to wx_rYZ then I would like to know if my app supports this locale or not.

At the same time I would like to keep the default values folder as is with all the translations.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Gagan
  • 1,497
  • 1
  • 12
  • 27

1 Answers1

0

Get the current locale

String current = getResources().getConfiguration().locale.toString();  

You will have to maintain a hashSet of locales that your application support. You can than check if the current locale is present in the hashSet to know if it is supported or not.

sauvik
  • 2,224
  • 1
  • 17
  • 25
  • I thought about this but the drawback of this approach is whenever someone adds another locale to app, this hashSet must also be updated. This is something which is not ideal and hence dropped the idea to go ahead with this. – Gagan Jan 15 '18 at 09:05
  • @Gagan In my opinion this is the cleanest way to achieve this. If you want to dynamically get the list of locales that your app supports take a look at these answers.. https://stackoverflow.com/questions/11611065/get-the-applications-resources-languages and https://stackoverflow.com/questions/32589521/get-only-the-list-of-locales-that-are-shipped-with-my-android-applicaiton – sauvik Jan 15 '18 at 09:53
  • I had seen that link before posting the question as the answers present there didn't provide solution for this.. Thanks anyway! – Gagan Jan 15 '18 at 10:24