Chapter 13: Internationalization (i18n)
TL;DR
- Create the folder structure: In your pack's root, create
locales/en/andlocales/es/(and any other language you want to support). - Create translation files: Add a
translation.jsonfile inside each language folder.en/translation.json:{ "my_greeting": "Hello World" }es/translation.json:{ "my_greeting": "Hola Mundo" }
- Reference keys in A2UI using string references instead of hard‑coded text.
Worka supports localization through pack‑provided locale files. The host selects the best match based on the user’s system language.
Step 1: Create the Directory Structure
In the root of your pack, create a locales directory. Inside locales, create a separate folder for each language you want to support, using the two-letter ISO 639-1 language code.
For example, to support English and Spanish, your structure would look like this:
my-cool-pack/
└── locales/
├── en/ // English
│ └── translation.json
└── es/ // Spanish
└── translation.json
Step 2: Add Your Translations
Inside each language folder, the translation.json file should contain a simple key-value map of your translation strings.
locales/en/translation.json
{
"greeting": "Hello from my pack!",
"submit_button": "Submit Data"
}
locales/es/translation.json
{
"greeting": "¡Hola desde mi pack!",
"submit_button": "Enviar Datos"
}
Step 3: Use translations in A2UI
Instead of hard‑coding text, reference translation keys in A2UI. The host resolves those keys against the active locale.
When a user’s language is Spanish, the host displays the Spanish strings; for English, it uses the English file. The system handles language selection for you.