Reputation: 2987
I'm building an Android application that aims to have multi language support. Nut just the usual Spanish, French, German etc but also some minority languages for which there is no Android Locale.
I'm aware of the typical solution of providing various values folders within the resource folder. For example values_fr, or values_sp. However, that will not help me for minority languages which do not have a locale.
So what I aim to do is put multiple strings xml files into the values folder. For example: strings-welsh.xml, strings-cornish.xml, strings-gaelic.xml, strings-french.xml etc.
However, I have a problem doing this because I get many 'Resource entry ## is allready defined' errors (where ## is the name of the string resource).
How, then can I have so the compiler stops complaining and I am free to call: getString(R.strings_welsh.app_name) or getStrings(R.strings_french.app_name).
I will be supporting Android 4.0 (ICS) and above.
Upvotes: 1
Views: 495
Reputation: 36302
You should stick with the standard way. You can create locales that don't have a provided static instance. In fact you can provide anything you want; from the locale docs:
You can create a Locale for languages and countries that don't exist
using the constructors.
Now I haven't tried it, but I assume this means that if you put the right strings in the right files in the right folders and your device supports those languages or you specify the locale explicitly, you should get the right localized strings back. I don't know which languages you need, but at least for the ones you mentioned, here are the two letter language codes:
cy
kw
gd
Upvotes: 1