Skip to content

Optional analytics, session recording and advertising stay off unless you accept. You can reject them and use Transglot. Change your choice anytime in Cookie preferences. Cookie Policy

Back to the blog
Developer guides

How to Translate JSON Files Locally with Ollama

Translate JSON locale files locally with Ollama and Transglot Community. Preview one key, preserve placeholders, review the draft, and check the Git diff.

by transglot team
published November 30, 2026
7 min read

Translate JSON files locally by running an instruction model in Ollama and using Transglot Community to apply it to your locale files. This walkthrough takes one English invitation label, drafts its French translation, and shows the change in Git. The key stays project.invite so your application can find it, and {{name}} stays intact so your i18n library can substitute the recipient’s name.

Transglot Community is an MIT-licensed JSON translation editor and CLI. It runs on your computer and writes validated translations to the locale files you already keep in Git. It supports JSON, YAML maps, and literal Laravel PHP arrays. This example uses JSON and a model running on the same machine. Community quickstart · Source code on GitHub

1. Install Ollama and download a local model

Use Node.js 22.15 or later, npm, Git, and Ollama. Install and start Ollama using the instructions for macOS, Linux, or Windows. For a terminal-managed server, start ollama serve in a separate terminal if there is no Ollama service running. Ollama setup

In a second terminal, download and list the model. These commands work in PowerShell and macOS or Linux shells.

shsh
ollama pull qwen3:8b
ollama list

The example uses the same qwen3:8b model as the Community demo. Ollama also lists a smaller qwen3:4b variant. If you use it, select that exact model tag in Community. Try the one-string sample before choosing a model for a full catalog. Qwen3 model tags in Ollama

Ollama’s local API listens on http://127.0.0.1:11434 by default. To check both the connection and the model list, open http://127.0.0.1:11434/api/tags in a browser. The response should include the tag you pulled. Ollama model list API

2. Open Community and import your JSON locale files

Run these commands from the directory where you want to clone Community.

shsh
git clone https://github.com/transglot/community.git
cd community
npm ci
npm start -- --port 0

The editor opens in your browser. The --port 0 option chooses an available port. Keep the local editor URL printed by the command private.

To try a disposable project first, run npm run demo -- --port 0 from the Community checkout. The demo already contains a partially translated French catalog and the same project.invite key used below.

For the Git workflow, start with a repository that tracks its locale files. Here are the two small catalogs used in the example.

locales/en/messages.json

jsonjson
{
"project": {
"create": "Create project",
"invite": "Invite {{name}} to your team"
}
}

locales/fr/messages.json

jsonjson
{
"project": {
"create": "Créer un projet"
}
}
  1. In Projects, choose Import folder and enter the repository’s absolute path, such as /path/to/my-app or C:/dev/my-app.
  2. Click Detect files. Choose en as the source, fr as the target, and locales/{locale}/**/*.json as the mapping for this folder layout. For a repository with messages/en.json and messages/fr.json, use messages/{locale}.json.
  3. Click Preview import. The two-file example has one source file, two source strings, one existing translation, and one missing translation for French. Confirm with Import project.

The screenshot shows the same JSON keys alongside an additional, already translated YAML file.

Community import preview showing detected JSON and YAML paths, with one French translation to draft

3. Connect Ollama and preview one missing key

Open AI & context and select Ollama / local model under AI connection. Use the default base URL for a local Ollama service and click Load models. Select qwen3:8b or enter the exact tag shown by ollama list.

In Product context & tone, tell the model where the string appears. For this example, use “This is a button label in a project management app. Use a concise French imperative.” Click Test translation. Community sends a fixed sample greeting and checks whether the model preserves its placeholder. Click Save AI & context settings after the sample passes.

Open Translations, select French, and search for project.invite. Click Translate 1 pending. The translation plan should show one missing string, one target file, and your selected Ollama model. Confirm it once those match.

Translation plan showing one pending French string, locales/fr/messages.json, and qwen3:8b on Ollama

4. Review the draft and check the Git diff

Open Review changes and find project.invite. Compare the source and the draft. Confirm that the French reads well on a button and still contains the exact {{name}} placeholder. Edit the draft if needed and select Approve.

Review changes comparing the English invitation label with an example French draft that keeps the name placeholder

Community writes validated drafts to your target file when they are generated. Approval records your review and protects the wording from automatic replacement. Inspect the changes from your project repository before staging them.

shsh
git status --short
git diff -- locales/
git diff --check

The French diff for this example adds an invitation alongside the existing project label. The exact draft may vary by model.

diffdiff
{
"project": {
- "create": "Créer un projet"
+ "create": "Créer un projet",
+ "invite": "Invitez {{name}} dans votre équipe"
}
}

Use git status --short to catch newly created locale files, which you can open directly for review. Commit the reviewed locale files and .transglot/state.json when you want to preserve review status in version control. Use Refresh files after editing files outside Community, or Restore points to recover an earlier local snapshot.

Run the same JSON translation from the terminal

Run the following from the Community checkout. Substitute an absolute path for /path/to/my-app. Use init only when the project has no transglot.community.json. Importing through the browser already sets up the mapping.

shsh
node bin/transglot-local.mjs init --project "/path/to/my-app" --source en --locales fr --format json --pattern "locales/{locale}/**/*.json" --provider ollama --model qwen3:8b
node bin/transglot-local.mjs test-connection --project "/path/to/my-app"
node bin/transglot-local.mjs translate --project "/path/to/my-app" --locale fr --key project.invite --dry-run

The dry run lists the planned work before making model requests or writing files. A new copy of the two-file example reports one planned translation. Once the scope matches, run the same command with --dry-run removed.

Inspect the French text in Git, then record your review and run the structural check for that specific key.

shsh
node bin/transglot-local.mjs review --project "/path/to/my-app" --locale fr --key project.invite
node bin/transglot-local.mjs check --project "/path/to/my-app" --locale fr --key project.invite --require-reviewed

What to check beyond valid JSON

  • Placeholders. Preserve names and delimiter styles such as {name}, {{name}}, or %s. A well-formed string with {{nom}} still breaks a call site that supplies name.
  • ICU plurals. Read the message with real inputs. In {count, plural, =0 {No invitations} one {# invitation} other {# invitations}}, count is the argument and =0 is an exact selector. Community checks ICU structure and target locale categories. If your project uses separate i18next keys such as items_one and items_other, manage the key families for each language in your app.
  • Meaning and fit. Read the text in the product. Check tone, terminology, punctuation, and whether longer strings still fit in buttons and menus. Structural checks leave those decisions to the reviewer.

Community supports flat and nested JSON objects. The editor displays a literal dot as \. so you can tell a single key named project.invite from the nested invite inside project. Pass the key as displayed. When the same key appears in several files, add a source-file filter such as --file locales/en/messages.json to the CLI command. Supported formats and validation details

Troubleshoot a local translation run

What you seeWhat to check
Connection failsStart Ollama and open the local /api/tags endpoint. Check the host and port in Community.
Model list is emptyRun ollama list and pull a model if the list is empty. Use the complete tag, such as qwen3:8b.
The plan has zero pending keysCheck the source mapping and target locale. If the French value already exists, open the key in the editor to edit it directly.
The sample fails validationTry a different instruction model and repeat the built-in sample. If larger runs fail after a sample passes, use a smaller batch.
The draft passes but reads badlyAdd a product-specific instruction or glossary term. Review and edit the phrase in context before approving it.

Can I translate JSON files offline?

Yes. Install Community’s dependencies and download your Ollama model first. Once both are ready, inference runs on your machine when Community uses the local Ollama server and the downloaded model. For a cloud API or an eligible ChatGPT account, the selected provider receives the source strings, keys, and relevant context for the run. Community provider setup and data flow

See the broader guide for API scripts and other ways to translate locale files. Translate JSON i18n files with AI

Try the workflow with a single missing key, then repeat it for the rest of the file once the model and review checks work for your project. Get Transglot Community on GitHub

colophon

Who wrote this, and what to read next

wrote this

transglot team

Written by the Transglot team.

Engineering
Developer guides
keep reading

How to Translate JSON i18n Files with AI

Three ways to translate a JSON locale file with AI, what breaks when you paste it into a chatbot, and the checks that keep keys, placeholders and plurals intact.

November 23, 2026
8 min read
keep reading

i18next best practices for scalable apps

Scale i18next with deliberate namespaces, correct plural lookups, safe interpolation and explicit fallback rules. Includes working examples and a release checklist.

February 3, 2026
6 min read
works with what you already run

41 connectors, already built.

the pipeline this post describes

Try it on your own strings. Free, no card.

Free plan: 100,000 words to start (25,000 at sign-up, 75,000 after a phone check), then 10,000 a month, 15 locales including your source, 3 seats.