The Lingua localization tool utilizes a structured Google Sheets document to manage and store localization keys and values for various languages and platforms. Here’s a detailed guide on how to structure the sheet.
For every language you wish to support, create an individual sheet within the Google Sheets document. Name the sheet using the convention LanguageCode_LanguageName
. For example:
en_US_English
fr_FR_French
es_ES_Spanish
The sheet will have several columns to manage different aspects of localization:
Identifier for referencing a group of keys
A unique identifier for referencing translation values in the code.
A brief description to help understand the context and usage of the localization key.
These columns store the translation values for different plural cases, following the Unicode CLDR language plural rules. Below are the specific columns:
To enhance the semantic organization of the localization keys, the Lingua tool supports the use of sections. Keys within the same section are grouped together, enabling a more intuitive and structured way to manage translations.
When localization files are generated, the section and key are combined to create platform-specific references:
The format will be Lingua.Section.Key
. Using the example values mentioned:
welcome
message
The reference in iOS will be Lingua.Welcome.message
.
The format will be R.string.section_key
. Using the example values:
welcome
message
The reference in Android will be R.string.welcome_message
.
The Lingua localization tool uses iOS (Apple) format specifiers as the base for managing string replacements within localization keys. During the export process, these specifiers are automatically mapped to the corresponding iOS and Android platforms.
You can add string format specifiers directly in your Google Sheets document using the standard iOS format. The tool will take care of mapping them to each platform during the export process.
Here are the common iOS format specifiers used:
%@
: Placeholder for strings%d
: Placeholder for integers%f
: Placeholder for floating-point numberswelcome_message
Welcome %@!
Welcome, %1$s!
Willkommen %@!
Willkommen, %1$s!
In these examples, %@
is used as a placeholder for the name of the user, a string value. During the export process, the iOS format specifier will remain the same for iOS and will be replaced with the appropriate Android placeholder.