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?
When the Java virtual machine starts running on a computer, it creates an object called the default locale. This object affects the format of strings created from data. Depending on the default locale, a program creates different strings for the same number.
You'll find this screen either in the System Settings app: Languages, or System Settings: System: Languages and input. The Language preference screen should contain one entry called “English (Europe)”. Click Add language and add a fallback language.
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.
uk Ukrainian ukrainien Ukrainisch
ru Russian russe Russisch
http://www.loc.gov/standards/iso639-2/php/code_list.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With