| Crates.io | intl-cli |
| lib.rs | intl-cli |
| version | 0.1.1 |
| created_at | 2025-01-13 07:25:52.169297+00 |
| updated_at | 2025-03-04 09:22:25.082266+00 |
| description | A tool to extract and translate messages from source code. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1514312 |
| size | 90,976 |
cargo install intl-cli
This is a CLI tool for handling internationalization (i18n) text and translation. It supports the following commands:
extract CommandUsed to extract i18n text from specified files.
The
extractcommand only extracts the strings contained within the$tfunction, such as$t('some words')and$t("after {count} days", {count: 1}).
Usage:
intl-cli extract [OPTIONS]
Options:
| Short | Long | Description | Default |
|---|---|---|---|
-o |
--output |
Output file path | output.json |
-e |
--excludes |
Glob patterns for files to exclude | ["**/node_modules/**", "**/.git/**"] |
-i |
--includes |
Glob patterns for files to include | ["*.{ts,tsx}"] |
-d |
--delete_unreached |
Delete unreached key-value pairs in output | None (default: false) |
Example:
intl-cli extract -o extracted.json -i "*.{ts,tsx}" -e "**/node_modules/**" --delete_unreached
tencent-translate CommandTranslate text using the Tencent Translation service.
Usage:
intl-cli tencent-translate [OPTIONS]
Options:
| Short | Long | Description | Default |
|---|---|---|---|
-i |
--input |
Input file path | output.json |
-o |
--output |
Output file path | None |
-s |
--source |
Source language | zh |
-t |
--target |
Target language | en |
-p |
--project_id |
Tencent Translation service Project ID | 0 |
-d |
--secret_id |
Tencent Translation service Secret ID | None |
-k |
--secret_key |
Tencent Translation service Secret Key | None |
-w |
--write_all |
Translate and write all content from input to output | None (default: false) |
Example:
intl-cli tencent-translate -i input.json -o translated.json -s zh -t en --secret_id YOUR_SECRET_ID --secret_key YOUR_SECRET_KEY --write_all
| Short | Long | Description |
|---|---|---|
-h |
--help |
Show help message |
-V |
--version |
Show version information |
Extract i18n text and save to i18n.json, ignoring node_modules and .git directories:
intl extract -o i18n.json -i "*.{ts,tsx}" -e "**/node_modules/**" --delete_unreached
Use the Tencent Translation service to translate i18n.json into English and save to translated.json:
intl-cli tencent-translate -i i18n.json -o translated.json --secret_id YOUR_SECRET_ID --secret_key YOUR_SECRET_KEY --write_all
tencent-translate command, you must provide secret_id and secret_key, otherwise the Tencent Translation service cannot be invoked.write_all option determines whether to translate and write all content from the input to the output.