Prompt
building a Git-based localization process
Latest observation
A Git-based localization process is a solid way to keep translations versioned, reviewable, and tied to your codebase. Here’s a practical blueprint you can adapt.
1) Decide your localization model
Common options:
A. File-based i18n in the repo
Store translations in the repository as JSON, YAML, PO, XLIFF, or similar.
Example:
src/
locales/
en/
common.json
fr/
common.json
de/
common.json
Pros:
- Simple
- Works well with Git
- Easy to review diffs
Cons:
- Translators may need tooling
- Merge conflicts can happen
B. Git repo + translation platform
Use Git as the source of truth, but connect to a localization platform (e.g. Phrase, Lokalise, Crowdin, Transifex).
Flow:
- Developers push source strings to Git
- Platform handles translation workflow
- Translations come back as PRs or sync commits
Pros:
- Better for non-technical translators
- QA and workflow support
- Easier scaling
Cons:
- More tooling and cost
2) Choose a file format
Pick a format that is:
- Structured
- Stable for diffs
- Easy to validate
Good choices:
- JSON: common, but order-sensitive unless normalized
- YAML: readable, but indentation mistakes possible
- PO/MO: great for translation workflows
- XLIFF: industry standard for localization tooling
For a Git-first workflow, many teams use:
- JSON for app localization
- PO for software translation
- XLIFF when integrating with translation tools
3) Define a strict key structure
Use consistent keys so translators and developers can navigate easily.
Example:
{
"nav.home": "Home",
"nav.about": "About",
"auth.login.button": "Log in",
"auth.login.error.invalid": "Invalid username or password"
}
Best practices:
- Use stable keys, not source text as keys
- Organize by feature or screen
- Avoid embedding variables into keys
- Keep keys semantic and reusable
4) Create a source language workflow
Pick one language as the source, usually English.
Workflow:
- Developer adds or updates source strings
- CI validates structure and syntax
- Strings are extracted into locale files
- Translation requests are created
- Translations are reviewed and merged
Important rule:
- Source language changes should trigger translation updates
5) Use branches and pull requests
A clean Git flow might look like this:
main: production-ready code and translationsfeature/*: app changes that add or modify stringslocalization/*: translation updates
Typical process:
- Developer opens a feature branch with new strings
- CI detects untranslated keys
- A localization PR is created or updated
- Translators or reviewers edit locale files
- PR is merged after checks pass
This keeps translation changes visible and auditable.
6) Automate string extraction
Avoid manual editing where possible.
Use scripts to:
- Extract keys from code
- Compare source and target locales
- Flag missing keys
- Remove unused keys
- Sort keys consistently
Example checks:
- Every locale has the same keys
- No empty values in required locales
- Placeholders match across languages
- No duplicate keys
Example CI validation:
npm run i18n:extract
npm run i18n:check
7) Add validation in CI
CI should fail if:
- A locale file is invalid JSON/YAML
- A required key is missing
- Placeholder count differs
- A translation file is malformed
- Encoding or line endings are wrong
Example checks:
- JSON schema validation
- Placeholder validation:
{name}must appear in all languages - Length checks for UI constraints
- Encoding UTF-8 only
8) Handle placeholders carefully
Placeholders are a common source of bugs.
Example:
{
"welcome_user": "Welcome, {name}!"
}
Rules:
- Keep placeholder names identical across locales
- Support pluralization properly
- Validate ordering if needed
For pluralization, use frameworks that support ICU MessageFormat, for example:
{count, plural, one {1 file} other {# files}}
This avoids awkward manual string concatenation.
9) Support translator-friendly diffs
Make Git diffs easy to review:
- Keep one string per line if possible
- Sort keys consistently
- Avoid reformatting unrelated sections
- Don’t regenerate whole files unless necessary
If using JSON:
- Pretty-print with stable ordering
- Avoid minified files
10) Decide who edits translations
There are a few models:
Developer-owned
Developers update translations directly in Git.
Best for:
- Small teams
- Few languages
- Technical teams
Translator-owned
Translators work in a platform or directly in PRs.
Best for:
- Larger teams
- Many languages
- Ongoing localization
Hybrid
Developers manage source strings and technical checks; translators handle target languages.
This is usually the best long-term approach.
11) Set up review rules
Translations should be reviewed like code:
- Linguistic review
- Product review
- In-context QA
Recommended:
- Require approval from localization owner or reviewer
- Protect locale files on
main - Use CODEOWNERS for translation directories
Example:
/locales/ @localization-team
12) Handle screenshots and context
Translators need context to avoid bad translations.
Provide:
- Screenshot references
- UI location
- Character limits
- Notes for ambiguous strings
- Variables and example values
Example annotation:
{
"checkout.submit": "Place order"
}
Note:
- Appears on checkout button
- Max 20 characters on mobile
- CTA after payment confirmation
13) Manage missing translations
Decide how your app behaves when a translation is missing:
- Fallback to source language
- Show placeholder like
[[missing_key]] - Hide the string
- Block release if required locales are incomplete
Recommended:
- Fallback in runtime
- Block production if required release locales are incomplete
14) Versioning strategy
Treat translation updates as normal commits, but be deliberate:
- Commit source changes separately from translation changes when possible
- Tag releases that include localization updates
- Keep translation churn out of unrelated code changes
This makes rollback easier.
15) Example Git workflow
Repository structure
app/
locales/
en.json
fr.json
es.json
scripts/
extract-i18n.js
check-i18n.js
Process
- Developer adds a new string in code
- Extraction script updates
en.json - CI identifies missing translations in
fr.jsonandes.json - A translation PR is created or updated
- Translators fill in the missing entries
- CI validates placeholders and completeness
- PR merges
16) Practical recommendations
If you’re starting from scratch:
- Use stable semantic keys
- Store translations in Git
- Add CI validation
- Use PR-based reviews
- Keep a source language
- Provide context for translators
- Automate extraction and sync
If you expect growth:
- Use a translation management platform
- Keep Git as the authoritative code sync layer
- Add screenshots, glossary, and translation memory support
17) Suggested minimal stack
A simple, effective setup:
- Source strings in JSON or PO files
- GitHub or GitLab for PRs
- CI for validation
- Extraction/check scripts
- CODEOWNERS for locale files
Optional additions:
- Translation platform
- Screenshot capture tool
- Glossary and style guide
If you want, I can also give you:
- a sample repository structure,
- a GitHub Actions CI example, or
- a full end-to-end localization workflow for web/mobile apps.