Localizing country names can be done with new Locale("", iso).getDisplayName() but is there a way of localizing ISO codes themselves? In my widget I'm using those to represent various countries. It seems wrong for a language - say, Arabic - to have countries be represented by the two letter ISO code from another alphabet. What are my options here?
By definition, ISO country codes are fixed strings of characters. Their very idea is that they are internationalized, independent of language. They provide the basis for transmitting information about a country in a standardized, language-neutral way; this information can then be displayed in a localized format, but localizing the code would fight against its very purpose.
ISO country codes are meant to be used in machine-readable data, in communication between programs and systems. They are not meant to be displayed to users, though for various reasons, they might be seen by them. Localizing them would still be a wrong move; the correct fix is to change the software that passes them through instead of proper localization.
Related
From a question received privately:
I'm currently creating an Android app and one of the requirements is that it supports a second language. I've Googled the language codes but I'm not finding the one that I need; could you tell me if you support the Welsh language, which is a place in the United Kingdom? And if so, what is the country code for it?
That would be on Android’s side, not on the IDE side, to support; the resources are bundled within the APK itself and you should put localised strings in a localised values folder within the res/ folder. For example:
res/
values/ # Default locale (e.g., American English)
values-en-rGB/ # British English
values-it/ # Italian (any country)
In general, localisations on Android are defined as a two-letter ISO 639-1 language code, optionally followed by a two letter ISO 3166-1-alpha-2 region code (preceded by lowercase r). Wales is not an independent country, but is part of Great Britain, and as such there is no ISO code for Wales as a region. But, there is a Welsh language code! So you should be able to localise your app by putting your Welsh strings in the res/values-cy or res/values-cy-rGB. The former will be used on all devices that are set to Cymraeg, regardless of the country they’re set to; the latter is specific to devices in Welsh with the country set to Great Britain. For Welsh, the two things are essentially the same, since there aren’t variations of it outside the UK, but this mechanism can be used for example to differentiate Traditional Chinese (zh-rTW) from simplified Chinese (zh-rCN).
For more details on how localisation works on Android, I recommend referring to the Localisation guide on the Android Developers website: https://developer.android.com/guide/topics/resources/localization
For the list of supported ISO languages and countries, you can refer to the Wikipedia: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for the countries, and https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes for the languages.
I have a set of strings like "Friday 8:00am till 6:00pm", how do I localize this string to different languages.
I've tried to use 2 Calendars and SimpleDateFormat, but it doesn't support several values.
Use DateUtils.formatDateRange(...) to format time spans.
Formats a date or a time range according to the local conventions.
Although this will not allow you to localize parts of it yourself, it will provide a consistent user experience on the device and is properly localized. You can modify what and how it is displayed by providing various flags.
I have some Android applications about finance (prices and some calculations). What is the right way to show the finance data for Arabic localization? Formatted as Arabic numbers or "Latin" (١٢٣٤٥٦٧٨ or 12345678)?
Usually I format all the numbers to user locale, but uninstall rate for Arabic locale is way too high compared to other localizations (except Saudi Arabia). Also I've noticed that many of the developers from Arab countries (on Google Play) do not format the numbers.
Formatting numbers in Arabic Locale (١٢٣٤٥٦٧٨) is considered "going for the extra mile" and will be mostly appreciated by Arabic natives. Native Arabic speakers will certainly notice the product is extremely localized to their needs (in your case financial markets) and you have taken them into consideration.
Nevertheless, you need to consider copy-and-paste and form filling (mostly they are already taken care of by the OS). e.g. copying the number "١٢٣٤٥٦٧٨ " shall copy 12345678 to make sure compatibility with other apps. Also, Regular Expressions in forms shall consider the Arabic numbers.
PS, make sure the translation is perfect :)
I would like to provide support for the Flemish language in my Android app, but as per ISO 639-1 there is no separate code for this language. How can I then do this?
Bear in mind that the resource qualifier can combine language and country. Although Dutch and Flemish are both ISO 639-1 nl, you can attach a region qualifier as well to further specify the region.
The documentation provides an example for British English:
Also, you might not need to create alternative text for every string. For example, assume the following:
Your application's default language is American English. Every string that the application uses is defined, using American English spellings, in res/values/strings.xml.
For a few important phrases, you want to provide British English spelling. You want these alternative strings to be used when your application runs on a device in the United Kingdom.
To do this, you could create a small file called res/values-en-rGB/strings.xml that includes only the strings that should be different when the application runs in the U.K.
Similarly, you could provide this for Flemish by specifying the resource directory values-nl-rBE.
If the language got no code, then you got rather no other way to "hijack" the code of other language or write own localization engine (or use something existing, but not the framework's one). As for hijacking the existing code, simply pick up that one that your user are most unlikely to face in real life and put your translation there.
using nl-rBE (dutch as used in Belgium) worked for me.
(r is required per the Android localization reference--the r denotes "region".)
http://www.localeplanet.com/icu/nl-BE/index.html
In the below link the documentation mentions creating "res/values-fr/strings.xml" for French translations and "res/values-ja/strings.xml" for Japanese translations. However, I couldn't find a list of all the acceptable path formats for all languages. I assume Italian would be "res/values-it/strings.xml", but it would be great if someone knew where this is documented.
http://developer.android.com/guide/topics/resources/localization.html
I assume Italian would be "res/values-it/strings.xml"
Yes, it is. The resource system uses the ISO3166-1 two letter country codes. See TelephonyManager.
Taken from Android docs:
The language codes are two-letter lowercase ISO language codes (such as "en") as defined by ISO 639-1. The country codes are two-letter uppercase ISO country codes (such as "US") as defined by ISO 3166-1.