Translate en/messages.json (chrome.i18n format) to 100+ locales automatically.
Project description
> translate-messages
Translate
en/messages.json(chrome.i18n format) to 100+ locales automatically.
Installation
pip install translate-messages
Usage
Run the CLI:
translate-messages [options] # or translate-msgs
If no options are passed, the CLI will:
- Prompt for message keys to ignore
- Auto-discover closest child
_localesdir - Translate found
en/messages.jsonto target languages
Note: Any messages.json in the chrome.i18n format can be used as a source file.
Options
Options can be set by using command-line arguments:
| Option | Description | Example |
|---|---|---|
-d, --locales-dir |
Name of the folder containing locale files (default: _locales) |
--locales-dir=_messages |
-t, --target-langs |
Comma-separated list of languages to translate to (default: all 100+ stable_locales) |
--target-langs=es,fr |
-k, --keys |
Comma-separated list of keys to translate (default: all found src keys missing in target files) | --keys=app_DESC,err_NOT_FOUND |
--exclude-langs |
Comma-separated list of languages to exclude | --exclude-langs=es,zh |
--exclude-keys |
Comma-separated list of keys to ignore | --exclude-keys=app_NAME,author |
--only-stable |
Only use stable locales (skip auto-discovery) | |
--config |
Use custom config file | --config=path/to/file |
init, -i, --init |
Create .translate-msgs.config.json5 in project root to store default options |
|
-f, --force |
Force overwrite of existing config file when using init |
|
-n, --no-wizard |
Skip interactive prompts during start-up | |
-h, --help |
Show help screen | |
-v, --version |
Show version | |
-V, --debug [targetConfigKey] |
Show debug logs | |
--docs |
Open docs URL |
Examples
Translate all keys except app_NAME from _locales/en/messages.json to all stable_locales:
translate-messages --ignore-keys=app_NAME # prompts for more keys to ignore
Translate app_DESC key from messges/en/messages.json to French:
translate-messages -n --keys=app_DESC --locales-dir=messages --target-langs=fr # no prompts
Translate app_DESC + err_NOT_FOUND keys from _msgs/en/messages.json to Spanish and Hindi:
translate-msgs -n -k app_DESC,err_NOT_FOUND -d _msgs -t es,hi # no prompts
Config file
Run translate-msgs init to create .translate-msgs.config.json5 in your project root to set default options.
Example defaults:
{
"locales_dir": "_locales", // name of the folder containing locale files
"target_langs": "", // languages to translate to (e.g. "en,es,fr") (default: all 100+ supported locales)
"keys": "", // keys to translate (e.g. "app_DESC,err_NOT_FOUND")
"exclude_langs": "", // languages to exclude (e.g. "en,es")
"exclude_keys": "", // keys to ignore (e.g. "app_NAME,author")
"force": false, // force overwrite existing config file when using init
"no_wizard": false // skip interactive prompts during start-up
}
Note: CLI arguments always override config file.
MIT License
Copyright © 2023–2026 Adam Lui.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file translate_messages-1.7.0.tar.gz.
File metadata
- Download URL: translate_messages-1.7.0.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f11a33d02c21c75e01c0d1c2ac6f944d21177ae4a16003524547b8d9b5cab542
|
|
| MD5 |
d6f7c7c002bc43da0ee40aa9ceeeaef8
|
|
| BLAKE2b-256 |
7d858c50c522d5292320d27fc8188cc5dd8124e957e2c3ccb5c52870b6f2e9a3
|
File details
Details for the file translate_messages-1.7.0-py3-none-any.whl.
File metadata
- Download URL: translate_messages-1.7.0-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bfb69c4b31823d1132b89ec39a5789774c8c45099e09188f35f3c236e8166d5
|
|
| MD5 |
6d68b24c76ba448dabf640b80b35a697
|
|
| BLAKE2b-256 |
83d808d3384bf86c95a659749d3ba90a755a5374aef1a904a8d20272b4603a56
|