UI Strings internationalization translator
string values string list adapter - each item can have optional string or integer id, and optional icon resource id
Container for UI string - either raw value or string resource ID
UIString item collection
Synopsis:
import dlangui.core.i18n; // use global i18n object to get translation for string ID dstring translated = i18n.get("STR_FILE_OPEN"); // as well, you can specify fallback value - to return if translation is not found dstring translated = i18n.get("STR_FILE_OPEN", "Open..."d); // UIString type can hold either string resource id or dstring raw value. UIString text; // assign resource id as string (will remove dstring value if it was here) text = "ID_FILE_EXIT"; // or assign raw value as dstring (will remove id if it was here) text = "some text"d; // assign both resource id and fallback value - to use if string resource is not found text = UIString("ID_FILE_EXIT", "Exit"d); // i18n.get() will automatically be invoked when getting UIString value (e.g. using alias this). dstring translated = text;
Boost License 1.0
Vadim Lopatin, 2014
This module contains UI internationalization support implementation.
UIString struct provides string container which can be either plain unicode string or id of string resource.
Translation strings are being stored in translation files, consisting of simple key=value pair lines:
Supports fallback to another translation file (e.g. default language).
If string resource is not found neither in main nor fallback translation files, UNTRANSLATED: RESOURCE_ID will be returned.
String resources must be placed in i18n subdirectory inside one or more resource directories (set using Platform.instance.resourceDirs property on application initialization).
File names must be language code with extension .ini (e.g. en.ini, fr.ini, es.ini)
If several files for the same language are found in (different directories) their content will be merged. It's useful to merge string resources from DLangUI framework with resources of application.
Set interface language using Platform.instance.uiLanguage in UIAppMain during initialization of application settings: