This guide explains how to add or improve translations for learnGitBranching.
learnGitBranching stores all translatable text in two places:
- UI strings (
src/js/intl/strings.js) — button labels, dialog text, error messages (~104 keys) - Level content (
src/levels/**/*.js) — level names, hints, and tutorial dialogs (~34 levels)
Each string is stored as an object keyed by locale code:
"some-key": {
"__desc__": "What this string is used for",
"en_US": "English text",
"de_DE": "Deutschsprachiger Text",
"hu_HU": "Magyar szöveg"
}Locale codes follow the pattern language_REGION (e.g., en_US, de_DE, hu_HU) or just language for some locales (e.g., ko, ja).
Edit src/js/stores/LocaleStore.js:
// In langLocaleMap, add your language code:
xx: 'xx_XX',
// In headerLocaleMap (optional, for browser Accept-Language header):
'xx-XX': 'xx_XX',
'xx': 'xx_XX',Edit src/js/react_views/IntlHelperBarView.jsx and add an entry to the getItems() array:
}, {
text: 'Your Language Name',
testID: 'yourlanguage',
onClick: function() {
this.fireCommand('locale xx_XX; levels');
}.bind(this)
}, {Edit src/js/intl/strings.js. For every entry, add your locale:
"finish-dialog-finished": {
"en_US": "Wow! You finished the last level, great!",
// ... other locales ...
"xx_XX": "Your translation here"
},For each level file in src/levels/, add translations to the name, hint, and startDialog fields:
"name": {
"en_US": "Introduction to Git Commits",
// ... other locales ...
"xx_XX": "Your translated level name"
},
"hint": {
"en_US": "Try using git commit",
// ... other locales ...
"xx_XX": "Your translated hint"
},
"startDialog": {
"en_US": { "childViews": [...] },
// ... other locales ...
"xx_XX": {
"childViews": [
{
"type": "ModalAlert",
"options": {
"markdowns": [
"## Your Translated Title",
"Your translated paragraph text."
]
}
}
]
}
}node scripts/validate-locale.js xx_XXOutput example:
Locale validation: hu_HU
══════════════════════════════════════════════════
UI Strings: 104/104
✓ All strings translated
Levels: 34/34
✓ All levels translated
──────────────────────────────────────────────────
✓ hu_HU is fully translated!
To get a JSON file with all English strings and empty target fields:
node scripts/extract-translation-template.js xx_XX > template_xx.jsonFill in all the empty "xx_XX": "" fields, then manually apply the translations to the source files following Steps 3 and 4 above.
-
Keep git commands in English:
commit,branch,merge,rebase,cherry-pick,fetch,push,pull,tag,clone— these are technical terms that developers recognize in any language. -
Keep code examples in English: Anything in backticks like
`git commit -m "message"`should stay in English. -
Preserve markdown formatting: Keep
##headers,*bold*,`code`, and newlines exactly as they appear in the English source. -
Preserve placeholders: Variables like
{nextLevel},{branch},{ref}must not be translated or modified. -
Use natural, informal language: Address the user informally (e.g., "tu" in French, "du" in German, "te" in Hungarian). Avoid overly formal or academic tone.
-
Be concise: Dialog text is displayed in small modal windows. Keep translations roughly the same length as the English original.
-
Translate level names meaningfully: Level names should be descriptive and help learners understand what they'll practice.
-
Build the app:
yarn install yarn gulp fastBuild
Why this matters: the app loads a pre-bundled JS file (build/bundle-*.js) referenced from index.html — it does not read src/ files directly. Every time you edit a translation file, you must re-run yarn gulp fastBuild before the change shows up, otherwise you'll see stale (untranslated) content even though your source edits are correct.
-
Start the dev server:
yarn dev
-
Open the app in your browser and switch to your locale:
- Click the language selector, or
- Type in the command line:
locale xx_XX; levels
-
Navigate through levels and verify all text appears correctly.
-
Run the validation script:
node scripts/validate-locale.js xx_XX
-
Run the existing string validation:
yarn gulp lintStrings
Before submitting your translation PR:
-
src/js/stores/LocaleStore.js— locale registered inlangLocaleMap(andheaderLocaleMapif applicable) -
src/js/react_views/IntlHelperBarView.jsx— language button added -
src/js/intl/strings.js— all 104 UI strings translated - All level
namefields translated (34 levels) - All level
hintfields translated (34 levels) - All level
startDialogfields translated (34 levels) -
node scripts/validate-locale.js xx_XXpasses with 0 errors -
yarn gulp lintStringspasses -
yarn testpasses - Tested locally by switching to the new locale in the UI
Open an issue at https://github.com/pcottle/learnGitBranching/issues and tag it with i18n.