A command-line utility for automatically syncing translation keys in rust_i18n projects.
- Scans your Rust source code for
t!("key")andi18n!("key")macros - Checks your YAML locale files for missing translation keys
- Automatically adds missing keys with empty values
- Keeps all your locale files in sync
cargo install i18n-syncBasic usage with default settings:
i18n-sync --locale-dir ./localesScan specific source directory:
i18n-sync --path ./src --locale-dir ./locales --default-locale enWith short flags:
i18n-sync -l ./locales -d en-p, --path <PATH>- Root path to scan for Rust files (default: ".")-l, --locale-dir <DIR>- Directory containing locale YAML files (required)-d, --default-locale <LOCALE>- Default locale (default: "en")
Before running i18n-sync:
- Your code has:
t!("hello")andt!("new_key") - Your
en.ymlonly has:hello: "Hello"
After running i18n-sync, en.yml becomes:
hello: "Hello"
new_key: ""All other locale files (like fr.yml, es.yml) will also get the new key with empty values.
Your project should look like:
your_project/
├── src/
│ └── *.rs (with t! macros)
└── locales/
├── en.yml
├── fr.yml
└── es.yml
MIT