JSON translation files (Deprecated)
PluginDeprecated: This plugin is deprecated in favor of the inlang message format plugin, which provides a simpler, more robust solution.
This plugin is a general purpose plugin to read and write messages of json files.
The plugin uses the inlang SDK v1 API but can be used in V2 projects.
A slight difference is that
languageTagis calledlocalein v2 projects. UselanguageTagfor this plugin.
Manual Installation
We recommend using the install button, but if you want to do it manually:
- Add this to the modules in your
project.inlang/settings.json - Change the
sourceLanguageTagif needed - Include existing languagetags in the
languageTagsarray
{
"sourceLanguageTag": "en",
"languageTags": ["en", "de"],
"modules": ["https://cdn.jsdelivr.net/npm/@inlang/plugin-json@latest/dist/index.js"],
"plugin.inlang.json": {
"pathPattern": "./resources/{languageTag}.json"
}
}
Example
messages/en.json
{
"hello": "Hello {name}!",
"loginButton": "Login"
}
messages/de.json
{
"hello": "Hallo {name}!",
"loginButton": "Anmelden"
}
Settings
The plugin offers further configuration options that can be passed as arguments. The following settings exist:
Here is the syntax for the PluginSettings object in TypeScript:
type PluginSettings = {
pathPattern: string | { [key: string]: string }
variableReferencePattern?: [string] | [string, string]
ignore?: string[]
}
pathPattern
To use our plugin, you need to provide a path to the directory where your language-specific files are stored. Use the dynamic path syntax {languageTag} to specify the language name.
Without namespaces
"plugin.inlang.json": {
"pathPattern": "./resources/{languageTag}.json"
}
With namespaces
Does not get created by 'npx @inlang/cli config init'
"plugin.inlang.json": {
"pathPattern": {
"website": "./resources/{languageTag}/website.json",
"app": "./resources/{languageTag}/app.json"
}
}
variableReferencePattern
Defines the pattern for variable references. The default is how i18next suggests the usage of placeholders.
default:
"plugin.inlang.json": {
"variableReferencePattern": ["{", "}"]
}
Common use cases
| Placeholder | Pattern |
|---|---|
{placeholder} | ["{", "}"] |
{{placeholder}} | ["{{", "}}"] |
${placeholder} | ["${", "}"] |
%placeholder | ["%"] |
[placeholder] | ["[", "]"] |
:placeholder | [":"] |
ignore
An array of strings that are used to ignore certain files. The strings are matched against the file path. If the file path contains the string, the file is ignored.
"plugin.inlang.json": {
"ignore": ["node_modules", "dist"]
}
Expected behavior
The message IDs are sorted in the order in which they appear in the sourceLanguage file. The nesting or flattening of IDs is detected on a file-by-file basis. If the sourceLanguage file contains nested IDs, the plugin will also create nested IDs in the targetLanguage files. If the sourceLanguage file contains flattened IDs, the plugin will also create flattened IDs in the targetLanguage files.
Contributing
Getting started
Run the following commands in your terminal (node and npm must be installed):
npm installnpm run dev
npm run dev will start the development environment which automatically compiles the src/index.ts files to JavaScript (dist/index.js), runs tests defined in *.test.ts files and watches changes.
Recommended complementary solutions
inlang CLI
Automate localization tasks in CI/CD pipelines with machine translation, validation, and plugin support for JSON, i18next, next-intl, and more.
Fink - CAT Editor (Computer Assisted Translation Editor)
Manage translations in a web app with Fink.

Sherlock - VS Code extension
Visualize, edit & lint translated strings at a glance via Inline Decorations & Hover Support, and extract new strings with a single click.

Paraglide JS
Simple, adaptable and tiny i18n library that integrates with any framework