intl-cli-0.1.1 is not a library.
install
CLI Usage Guide
Overview
This is a CLI tool for handling internationalization (i18n) text and translation. It supports the following commands:
- extract: Extract i18n text from files.
- tencent-translate: Translate text using the Tencent Translation service.
Commands and Arguments
extract Command
Used to extract i18n text from specified files.
Notice
The
extractcommand only extracts the strings contained within the$tfunction, such as$t('some words')and$t("after {count} days", {count: 1}).
Usage:
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:
tencent-translate Command
Translate text using the Tencent Translation service.
Usage:
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:
Global Options
| Short | Long | Description |
|---|---|---|
-h |
--help |
Show help message |
-V |
--version |
Show version information |
Example Commands
-
Extract i18n text and save to
i18n.json, ignoringnode_modulesand.gitdirectories: -
Use the Tencent Translation service to translate
i18n.jsoninto English and save totranslated.json:
Notes
- When using the
tencent-translatecommand, you must providesecret_idandsecret_key, otherwise the Tencent Translation service cannot be invoked. - The
write_alloption determines whether to translate and write all content from the input to the output.