Releases: longbridge/rust-i18n
Releases · longbridge/rust-i18n
v0.5.2
v0.5.1
- Add
i18n
config support inCargo.toml
, nowcargo i18n
will use that. cargo i18n
has removed--locale
,--output
flags, instead to use I18n config.
In your Cargo.toml
:
You can change the I18n settings.
[package.metadata.i18n]
# The available locales for your application, default: ["en"].
available-locales = ["en", "zh-CN"]
# The default locale, default: "en".
default-locale = "en"
# Path for your translations YAML file, default: "locales".
load-path = "locales"
After that, cargo i18n
will use these settings for check and generate.
v0.4.0
- Rename Command line tool as
cargo i18n
.
$ 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:
cargo i18n [OPTIONS] [--] [source]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-l <locale>... Source locale [default: en]
-o <output> Path for output locales YAML files. [default: ./locales]
ARGS:
<source> Path of your Rust crate root [default: ./]
v0.3.4
v0.3.3
Rust I18n Cli
Add i18n
cli command for extract untranslated texts into YAML.
Use cargo install rust-i18n
to installation.
$ cargo install rust-i18n
$ i18n -h
i18n 0.3.3
Jason Lee <[email protected]>
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.
USAGE:
i18n [SUBCOMMAND]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
SUBCOMMANDS:
extract Extracts strings from source files
help Prints this message or the help of the given subcommand(s)
Extract all untranslated texts
$ cd your-project
$ i18n extract -l en fr zh-CN zh-HK
Checking [en] and generating untranslated texts...
Found 1 new texts need to translate.
----------------------------------------
Writing to TODO.en.yml
Checking [fr] and generating untranslated texts...
Found 11 new texts need to translate.
----------------------------------------
Writing to TODO.fr.yml
Checking [zh-CN] and generating untranslated texts...
All thing done.
Checking [zh-HK] and generating untranslated texts...
Found 11 new texts need to translate.
----------------------------------------
Writing to TODO.zh-HK.yml
Now, 4 YAML files named TODO.*.yml
are created into locales/
path.
v0.2.1
v0.2.0
BRAKE CHANGES
Rust I18n API has rewrite, now you need use i18n!
macro to load locales file by manually.
This changes for allow I18n to support load translations from difference sub project.
For example:
// deps: rust-i18n
foo
Cargo.toml
locales
src/lib.rs
// deps: rust-i18n, foo
bar
Cargo.toml
locales
src/lib.rs
// deps: rust-i18n, foo and bar
your-project:
Cargo.toml
locales
src/lib.rs
Is this case, Rust I18n allows foo
, bar
and your-project
use i18n!
macro to load itself's translations.
Usage:
// Load I18n macro, for allow you use `t!` macro in anywhere.
#[macro_use]
extern crate rust_i18n;
// Init translations for current crate.
i18n!("./locales");
fn main() {
println!(t!("hello"))
}
- Add
i18n!
macro to load translations and required this. - Add for support merge multiple YAML files.