how to use external language files to display text in the user's preferred language.
Objective Contents Language strings Resource file structure Getting a localized string Replacing values in a localized string iOS-specific localizations Localize system buttons and submit to international App Stores Localize property list keys Set default language Internationalizing the app's name Changing locale for testing App name localization Android app name localization with Titanium SDK 3.1.x and older Reference Links Internationalizing image and file resources Date and time formatting Other formatting and locale functions Testing languages Hands-on practice Goal Steps Summary References and further reading
Objective In this section, you will learn how you can seamlessly internationalize your Titanium apps. We'll look specifically at how you can use external language files to display text in the user's preferred language.
Language strings Rather than hard-coding strings into your project, you can use localized strings. Localized strings are replaced at runtime with values appropriate to the user's language. Titanium relies on resources files and string placeholders to accomplish this task.
In your Alloy project create a directory called i18n. Inside the i18n folder, create folders for each language your application will support. Name the folder according to the ISO 639-1 standard. For example, use en for English, es for Spanish, fr for French, etc.
You can also add a suffix to the language directories for variants of languages. However, if you don't plan on adding multiple suffix-ed directories omit the suffix completely. Suffix the folder name with a dash followed by the country's ISO 3166-1 Alpha-2 code. For example, use en-US for American English, en-CA for Canadian English, en-GB for British English, etc. Note that the OS may not support all regional languages.