4

Android: Choose between two languages ​​without & ldquo; Local & rdquo;

 3 years ago
source link: https://www.codesd.com/item/android-choose-between-two-languages-without-local.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Android: Choose between two languages ​​without & ldquo; Local & rdquo;

advertisements

I'm developing application that can be useful only in my country(Ukraine). In Ukraine people primary speak Ukrainian or Russian. And I need to create something like radioButton to switch between languages.

Until now I only found tutorials that were using "locale", but it will not suit my needs, because location is same (Ukraine) but languages are different.

So let's imagine that I have saved in database parameter that show language

I created 2 types of res/values (values-ua & values-rus). I am starting activity what code I need to use to show which resources I need?


I think your problem is that you used the wrong country codes. Try values-ru and values-uk. [source]

Not fully sure what you intend to do, but I would not provide any radio button. Instead, I would rely on android's built in support for localization. In other words, suppose user A has a device with the Ukranian language enabled by the os, the app will automatically use the strings provided in the strings.xml file which resides in the values-uk folder. Same goes for russian. Check this answer- it might help.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK