Different languages for different localizations - android

I am developing an application, that has both English and Russian language. I want my application to be in Russian for countries of former USSR and English for other countries.
The solution I was thinking about: to put the same files as in values-ru folder into values-xx localizations folders, where I want Russian to be the default language. The same thing to do with English: to copy files from values-en to values-xx (here values-xx are localization folders of those countries, where I want English to set as default language).
I doubt, that this is a correct solution. Is there a better and shorter solution for my task?

You can use the values (with no county specifier) folder to place your resources in English; this will be your default language configuration. Then you can add Russian resources to the specific countries you want (i.e. the ex-USSR countries) like you say.

First of all, you can copy only string.xml from "values-ru" folder. Other localization automatically take strings from default "values" folder. You don't need to copy English version.

Related

Android localization resources

I have just finished developing an android application that I was asked to make. I had also planned to translate it in different languages; below you can see the tree of the folders/files:
Inside strings.xml there are all the values that I am using inside the classes and they are all in Italian, my language (Here you can see an example if needed). I'd like to be able to translate all those fields in English and french as well.
I have read this article -> http://developer.android.com/training/basics/supporting-devices/languages.html
From what I have understood, I'd have to create a folder called values-fr with a strings.xml inside (it will have the same values names, but different translations).
QUESTION
I would like to be able to support English and Italian as well, but I don't understand how to manage the folders. Could you please tell me which option is the correct?
Inside the folder values use strings.xml with Italian (my language) strings. Then create another folder called values-en and, like I did before, create strings.xml with English values
Inside the folder values use strings.xml with English strings. Then create another folder called values-it and then, create strings.xml with Italian values
I guess that the point 2 is the correct solution but I'm not sure. The folder values has English as default language?
Thanks for the attention.
Technically speaking both are valid. values/ is the fallback if a more specific qualifier is not found. There is no written rule that enforces you in having the English strings in values/. It just makes a little more sense to have the English as fallback since it easier to find foreigners that speak English rather than Italian

android localization resource chooser

I have an android application on eclipse it's text-views and the buttons' texts on Arabic language , I want to localize my application to both Arabic and English users .
Firstly under res folder I have created another folder and named it values-en .
I let the original folder values as is it and later I will use it for Arabic .
My first question it is necessary to create another folder (values-ar) for Arabic localization issues.
Or original values folder is just enough?.
Secondly
On values-en folder I created strings.xml file and added the following statement to it
COMTAS
I set the text of one of the textviews from resource chooser so choose application-title .
after that the textview's text converted to #string/application-title.
the project gives me the following message
NOTE: This project contains Java compilation errors, which can cause rendering failures for custom views. Fix compilation problems first.
Can someone explains to me how to make localization in simple steps.
And how I can retrieve textviews' texts either in english or arabic (reading from values folder)?
First: Leaving a strings.xml in the "values" folder will cause this language to be "default" (or rather "fallback") language.
Second: The text is read automatically from the strings.xml placed in the values-folder matching your System Locale (the locale you get when you call Locale.getDefault()), e.g. if system locale is set to english, the values are taken from values-en folder. Therefore it would be wise to place the arabic values in a values-ar folder.
I can't say anything related to your compile errors as you didn't post the code causing the error.
It's always good to follow the documentation. Here is the link for Localizing with Resources.
Create a values-ar folder for the arabic language, and let the default language as english. Why?
Whenever the application runs in a locale for which you have not provided locale-specific text, Android will load the default strings from res/values/strings.xml.
So if your application is running on a device set to Spanish language, it would still load arabic language (if it's set as default).
English is a most talked language, which would be better to let english by default, ant let the arabic language in values-ar(in my humble opinion).
Hope this helps you.

Android Strings.XML Regional file overrides language file?

I am trying to localize my app and have a few doubts. i have translate strings in spanish language and i am trying to be very specific with Region codes, so I named the folders as values-es_rES, values-es_rUS and values-es_rMX. Now there are more countries and users who like to use spanish language so i created a generic values-es folder.
I am wondering can android automatically push all mexico, US and Spain users to respective languages under their region codes and can others like chile, peru will be shown values-es language rather than my default US English?
You have two options
Use the language-region locale (ie. es_ES for Spanish/Spain or es_PE for Spanish/Peru)
Use MNC/MCC codes in your resource folders, which will take presence over the locale ones.
The way you have described it, all users with a defined locale of es_XX (any region) will go to your "values-es" folder, but the US user will not, unless the US user has configured "es_US" as their locale.
Take a look at Table 2 at
http://developer.android.com/guide/topics/resources/providing-resources.html
Remember that if an asset is missing from "es_ES" it will get it from "es", so only change those that are different.

Set translated languages in application

The default language of my app is English and I translated it into German. But now if I want to export it as an signed application in Eclipse there comes many errors that all string are not translated in other languages like es, fr , it and so on.
How can I export my app as signed application with only two languages and ignore all other languages?
You don't need to translate your app if you don't want to. Just check that all strings are defined in the base values/ folder. Then you can create more values-XX/ folders with their own strings.xml with all of the strings (or just a fraction of them). Android will take the default string if it doesn't find the localised version of the string.
If you are not localising to other languages, make sure that their values folder are not defined. For example, if you are not localising to Spanish, make sure that you don't have the values-es/ folder in your res/ folder.
EDIT: Same topic solved: Lint: How to ignore "<key> is not translated in <language>" errors?

How to show Locale List based on the Resource availability

I am developing an application that fetches all the system available locales and show in a listview to be selected by user to change the application language(just like android's language change option).
But I have a few res/values folder in my application resources like values (default), values-bn, values-zh, values-ar. SO I want these 4 languages to be shown in the list. How can I do this? I need to do this programmatically.
Suppose, I have 4 folders values, values-bn, values-en, values-zh
Then I only show,
Bengali
English
Chinese
OK, so what you want to do is have four languages: English, Bengali, Chinese, and Arabic, have I got that right? (Your question is internally inconsistent so it's hard to tell).
And you want to have a set of fallback values for when a string is missing in one of those four languages. The fallback values are in English, although the system won't know or care about that.
So what you want to do is put the strings for the four languages in the values-en, values-bn, values-zh, and values-ar directories and the fallback strings in the values directory.
In fact, since your fallback strings are in English, you could just put them in the values directory and have an empty resources file in the values-en directory. English would still show up in the list.
But why not just put the English versions of the strings in the values-en directory?

Categories

Resources