Copy en.json as a template and create a new file, e.g., de.json for German:
cp i18n/en.json i18n/de.jsonAt the beginning of the file, modify the meta section:
{
"meta": {
"code": "de", // ISO 639-1 code (2 letters)
"name": "Deutsch", // Language name in that language
"flag": "DE" // Country code (displayed as flag)
},
...
}Translate values (NOT keys!) in each section:
common- buttons: Add, Cancel, Save, Delete, Edit, Closenav- navigation: Settings, Logoutlist- list: title, empty list, shopping list, completed, Boughtitems- products: What to buy?, Note, name, new product, select sectionsections- sections: title, new section, section list, manage, select, no sectionsactions- actions: move up, move down, move, uncertain, certainsettings- settings: title, languagelogin- login: title, subtitle, password, placeholder, button, errorconfirm- confirmations: delete item, delete sections (with{{name}},{{count}}parameters)
JSON files are embedded in the binary, so after adding/changing translations:
go build -o shopping-list-go
./shopping-list-goThe new language will automatically appear in the Settings language selector.
{
"meta": {
"code": "xx",
"name": "Language name",
"flag": "XX"
},
"common": {
"add": "...",
"cancel": "...",
"save": "...",
"delete": "...",
"edit": "...",
"close": "..."
},
"nav": {
"settings": "...",
"logout": "..."
},
"list": {
"title": "...",
"empty_list": "...",
"shopping_list": "...",
"completed": "...",
"bought": "..."
},
"items": {
"what_to_buy": "...",
"note": "...",
"note_optional": "...",
"name": "...",
"new_product": "...",
"select_section": "...",
"section": "..."
},
"sections": {
"title": "...",
"new_section": "...",
"section_list": "...",
"manage": "...",
"select": "...",
"no_sections": "...",
"add_first_section": "..."
},
"actions": {
"move_up": "...",
"move_down": "...",
"move": "...",
"uncertain": "...",
"certain": "...",
"remove_mark": "...",
"mark_uncertain": "..."
},
"settings": {
"title": "...",
"language": "...",
"coming_soon": "..."
},
"login": {
"title": "...",
"subtitle": "...",
"password": "...",
"password_placeholder": "...",
"submit": "...",
"error_invalid": "..."
},
"confirm": {
"delete_item": "... \"{{name}}\"?",
"delete_sections": "... {{count}} ...?",
"delete_section": "... '{{name}}'?"
}
}| Code | Language |
|---|---|
| pl | Polski |
| en | English |
| de | Deutsch |
| es | Español |
| fr | Français |
| it | Italiano |
| pt | Português |
| uk | Українська |
| cs | Čeština |
| sk | Slovenčina |
| ru | Русский |
| nl | Nederlands |
| sv | Svenska |
| no | Norsk |
| da | Dansk |
| fi | Suomi |
| ja | 日本語 |
| ko | 한국어 |
| zh | 中文 |
Some texts contain parameters in {{param}} format:
{{name}}- element name (item, section){{count}}- number of elements
Example:
"delete_item": "Delete \"{{name}}\"?"In JS code called as:
t('confirm.delete_item', { name: 'Milk' })
// Result: Delete "Milk"?