A Google Sheets script that takes a sheet with translations and generates localization files for both iOS and Android platforms, with support for plurals.
- For Android: Creates XML resource files with strings and plurals
- For iOS:
- Legacy format: Creates Localizable.strings files and Localizable.stringsdict for plurals
- Modern format: Creates Localizable.xcstrings files which combine both regular strings and plurals in a single JSON file
- Open your Google Sheet
- Go to Extensions → Apps Script
- Copy the contents of
script.gsinto the editor - Save the project
- Refresh your Google Sheet
- Format your sheet according to the guidelines below
- From your sheet, access the custom menu: Custom Export
- Select one of the following:
- iOS (Legacy) - creates .strings and .stringsdict files
- iOS (.xcstrings) - creates modern .xcstrings file
- Android - creates strings.xml
- Copy the generated files to your project
The script expects a specific sheet format:
| ... (any columns) | Identifier iOS | Identifier Android | English text | German text | ... |
|---|---|---|---|---|---|
| (additional info) | login_button_title | login_button_title | Login | Einloggen | |
| ... | ... | ... | ... | ... |
Important notes:
- The bold headers are required exactly as written
- The first row must contain headers
- The position of the iOS/Android identifier columns can be configured (see Configuration)
- Language columns should be added to the right of the identifier columns
This script supports pluralization with a special key format:
translation.key##{quantity}
Where quantity is one of the CLDR plural categories:
zeroonetwofewmanyother
Example:
| Identifier iOS | Identifier Android | English | German |
|---|---|---|---|
| items.count##{zero} | items_count##{zero} | No items | Keine Elemente |
| items.count##{one} | items_count##{one} | One item | Ein Element |
| items.count##{other} | items_count##{other} | %d items | %d Elemente |
For Android string arrays, append [] to the key. Consecutive rows with the same array name will be grouped:
| Identifier iOS | Identifier Android | English | German |
|---|---|---|---|
| week.days | week.days[] | Monday | Montag |
| week.days | week.days[] | Tuesday | Dienstag |
| week.days | week.days[] | Wednesday | Mittwoch |
The script has several configurable properties at the top of the file:
// Number of languages in your sheet (columns after identifier columns)
var NUMBER_OF_LANGUAGES = 2;
// Position of the first column with iOS identifiers (1-based)
var FIRST_COLUMN_POSITION = 1;
// Position of the header row
var HEADER_ROW_POSITION = 1;
// Source language identifier (used for .xcstrings format)
var SOURCE_LANGUAGE = "en";
// Language codes for each column after the identifier columns
var LANGUAGE_CODES = ["en", "de"];Make sure to:
- Set
NUMBER_OF_LANGUAGESto match the number of language columns in your sheet - Update
LANGUAGE_CODESarray to match your actual language codes in the correct order - Set
SOURCE_LANGUAGEto your development language (typically "en")
strings.xmlwith string and plural resources (one per language)
Localizable.stringsfor regular strings (one per language)Localizable.stringsdictfor plurals (one per language)
Localizable.xcstrings(combines all languages and both regular strings and plurals in a single JSON file)
The modern iOS format introduced in Xcode 15 combines all localizations in a single JSON file with the following advantages:
- Combines both regular strings and plurals in one file
- Supports multiple languages in a single file
- Native support in Xcode's localization system
- Better compatibility with future iOS/macOS versions
This script is inspired by localizable-sheet-script by COBE, with added support for plurals and other enhancements.
MIT License - See the LICENSE file for details.