Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android localization values-** folder names

I have seen several conflicting tables that show localizations and what names they should take

A lot of them suggest that there are versions of the language for each country, which is fine, for languages like English, Spanish and Chinese, where I can choose to make a values-en folder or a values-en_US folder if I want to make it more specific

but some other languages like greek have a locale name el_GR , can I just make a folder names values-el or does it HAVE to be values-el_GR

thats just an example and I don't trust the tables I have read, and the android developer guide does not nearly list the available locales

like image 222
CQM Avatar asked Dec 03 '12 22:12

CQM


2 Answers

The folder name of Android string files is formatted as the following:

  • without region variant: values-[locale]
  • with region variant: values-[locale]-r[region]
  • For example: values-en, values-en-rGB, values-el-rGR.

In your case, you just need to create a folder values-el for the Greek translation, and values-el-rGR for the country-specific Greek translation.

Also, you can make use of the resources fallback mechanism in Android, to allow particular strings to be further translated locally.

For example, suppose you have a string called “R.string.title” and the locale is ‘el-GR’, Android will look for a value of “R.string.title” by searching the files in the following order:

  • res/values-el-rGR/strings.xml
  • res/values-el/strings.xml
  • res/values/strings.xml

Therefore, you can just put the country-specific translation inside the res/values-el-rGR/strings.xml, and let the res/values-el/strings.xml stores the general translations.

It can avoid duplicating your strings in different language files by utilizing this fallback mechanism.

like image 86
Cowcow02 Avatar answered Oct 15 '22 17:10

Cowcow02


Right click "res" folder in your project. Pick > New > Android resource file > Localization - and it will offer you all the possible Language and Locales options and even create required folders.

like image 45
careful7j Avatar answered Oct 15 '22 17:10

careful7j