Skip to content

Releases: longbridge/rust-i18n

v0.5.2

02 Apr 08:43
Compare
Choose a tag to compare
  • Fix locales output path with absolute source path.
  • Use ignore crate to glob Rust files and ignore files that was Git ignored.

v0.5.1

10 Dec 03:41
Compare
Choose a tag to compare
  • Add i18n config support in Cargo.toml, now cargo 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

09 Dec 07:37
Compare
Choose a tag to compare
  • 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

09 Dec 07:15
Compare
Choose a tag to compare
  • Improve t! macro for support expr arguments.
let name = "Jason Lee";
let locale = "en";

t!("hello, %{name}", name = name);
t!("hello, %{name}", name = &format!("{}", name));
t!("hello, %{name}", locale = locale, name = name);

v0.3.3

09 Dec 06:22
Compare
Choose a tag to compare

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

06 Dec 15:24
Compare
Choose a tag to compare
  • Add build.rs for glob all YAML files in project for fix cargo build cache.

v0.2.0

06 Dec 13:57
Compare
Choose a tag to compare

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.

v0.1.6

06 Dec 02:42
Compare
Choose a tag to compare
  • Search translation resources recursively in workdir

This is to support use cases like a crate using rust-i18n is being usedby another crate.

v0.1.5

03 Dec 10:20
Compare
Choose a tag to compare
  • Fix build on Windows again.
  • Add RUST_I18N_DEBUG env for debug codegen, use stdout print.

v0.1.2

02 Dec 10:37
Compare
Choose a tag to compare
  • Fix for Windows support.