Translate en/messages.json (chrome.i18n format) to 100+ locales.
Project description
> translate-messages
Translate
en/messages.json(chrome.i18n format) to 100+ locales.
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 supported_locales) |
--target-langs=en,es,fr |
-k, --keys |
Comma-separated list of keys to translate | --keys=app_DESC,err_NOT_FOUND |
--exclude-langs |
Comma-separated list of languages to exclude | --exclude-langs=en,es |
--exclude-keys |
Comma-separated list of keys to ignore | --exclude-keys=app_NAME,author |
-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 |
|
-W, --no-wizard |
Skip interactive prompts during start-up | |
-h, --help |
Show help screen |
Examples
Translate all keys except app_NAME from _locales/en/messages.json to all supported_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 --keys=app_DESC --locales-dir=messages --target-langs=fr -W # no prompts
Translate app_DESC + err_NOT_FOUND keys from _msgs/en/messages.json to Spanish and Hindi:
translate-msgs -k app_DESC,err_NOT_FOUND -d _msgs -t es,hi -W # no prompts
Config file
Use --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 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. "appName,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.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 Distributions
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.2.2-py3-none-any.whl.
File metadata
- Download URL: translate_messages-1.2.2-py3-none-any.whl
- Upload date:
- Size: 15.1 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 |
f7214fb212629fc2938ef989e5e742c874206d9080299cf7db6d965d0154a9dd
|
|
| MD5 |
61366610474bc838e32c4d8693bd0f85
|
|
| BLAKE2b-256 |
cc111b501a77442d8046494dbe2a9ff716a35b5494d5b14ba495780bf7eabfd0
|