Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: choosing between two languages without "locale"

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?

like image 423
haawa Avatar asked Mar 28 '12 18:03

haawa


People also ask

What is use locale default?

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.

How do I change localization in Android?

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.


2 Answers

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.

like image 165
Dhruv Gairola Avatar answered Oct 12 '22 02:10

Dhruv Gairola


uk Ukrainian ukrainien Ukrainisch
ru Russian russe Russisch

http://www.loc.gov/standards/iso639-2/php/code_list.php

like image 27
NickUnuchek Avatar answered Oct 12 '22 04:10

NickUnuchek