Skip to content

Commit

Permalink
Rename Command line tool for use cargo i18n.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Dec 9, 2021
1 parent 6c77c83 commit c314efe
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "MIT"
name = "rust-i18n"
readme = "README.md"
repository = "https://github.com/longbridgeapp/rust-i18n"
version = "0.3.5-alpha.0"
version = "0.4.0-alpha.0"

[dependencies]
anyhow = {version = "1", optional = true}
Expand All @@ -35,6 +35,6 @@ name = "app"
test = true

[[bin]]
name = "i18n"
name = "cargo-i18n"
path = "src/main.rs"
required-features = ["default"]
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ The API of this crate is inspired by [ruby-i18n](https://github.com/ruby-i18n/i1
- Codegen on compile time for includes translations into binary.
- Global `t!` macro for loading localized text in everywhere.
- Use YAML for mapping localized text, and support mutiple YAML files merging.
- Command lint tool for checking and extract untranslated texts into YAML files.
- Command line tool for checking and extract untranslated texts into YAML files.

## Installation

Rust I18n also provided a `i18n` command line tool help you process translations.
Rust I18n also provided a `cargo i18n` command line tool help you process translations.

```bash
$ cargo install rust-i18n
Expand Down Expand Up @@ -129,9 +129,9 @@ Rust I18n providered a `i18n` bin for help you extract the untranslated texts fr
```bash
$ cd your_project_root_directory
$ cargo install rust-i18n
# Now you have `cargo i18n` command

# Now you have `i18n` command
$ i18n extract .
$ cargo i18n -h
```

After that the untranslated texts will be extracted and saved into `locales/TODO.en.yml` file.
Expand All @@ -140,7 +140,7 @@ You also can special the locale by use `--locale` option:

```bash
$ cd your_project_root_directory
$ i18n extract -l en fr zh-CN zh-HK
$ cargo i18n -l en fr zh-CN zh-HK

Checking [en] and generating untranslated texts...
Found 1 new texts need to translate.
Expand All @@ -161,15 +161,21 @@ Found 11 new texts need to translate.
Writing to TODO.zh-HK.yml
```

Run `i18n extract -h` to see details.
Run `cargo i18n -h` to see details.

```bash
$ i18n extract -h
i18n-extract
Extracts strings from source files
$ cargo i18n -h
cargo-i18n 0.4.0
---------------------------------------
Rust I18n command for help you simply to extract all untranslated texts from soruce code.

It will iter all Rust files in and extract all untranslated texts that used `t!` macro.
And then generate a YAML file and merge for existing texts.

https://github.com/longbridgeapp/rust-i18n

USAGE:
i18n extract [OPTIONS] [--] [source]
cargo i18n [OPTIONS] [--] [source]

FLAGS:
-h, --help Prints help information
Expand Down
20 changes: 14 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ use std::collections::HashMap;
use rust_i18n_extract::{extractor, generator, iter};

fn main() -> Result<(), Error> {
let extract_command = SubCommand::with_name("extract")
.about("Extracts strings from source files")
let extract_command = SubCommand::with_name("i18n")
.about(
r#"---------------------------------------
Rust I18n command for help you simply to extract all untranslated texts from soruce code.
It will iter all Rust files in and extract all untranslated texts that used `t!` macro.
And then generate a YAML file and merge for existing texts.
https://github.com/longbridgeapp/rust-i18n
"#,
)
.version(clap::crate_version!())
.arg(
Arg::with_name("output")
.short("o")
Expand All @@ -27,10 +37,8 @@ fn main() -> Result<(), Error> {
.default_value("./"),
);

let app = App::new("i18n")
.version(clap::crate_version!())
.author(clap::crate_authors!())
.about("Rust I18n is a crate for loading localized text from a set of YAML mapping files. The mappings are converted into data readable by Rust programs at compile time, and then localized text can be loaded by simply calling the provided `t!` macro.")
let app = App::new("rust-i18n")
.bin_name("cargo")
.subcommand(extract_command)
.get_matches();

Expand Down

0 comments on commit c314efe

Please sign in to comment.