4 releases

0.1.2 Dec 9, 2018
0.1.1 Nov 25, 2018
0.1.0 Nov 25, 2018
0.0.0 Nov 7, 2018

#68 in Internationalization (i18n)

36 downloads per month
Used in 1 crate

MIT license

343 lines


Internationalisation helper

This crate maily expose a macro that wraps gettext in a convinient ways. See the documentation of the tr! macro.

To translate a rust crate, simply wrap your string within the tr! macro. One can then use the xtr binary to extract all the translatable from a crate in a .po file. GNU gettext tools can be used to process and translate these strings.

The tr! macro also support support rust-like formating.


extern crate tr;
fn main() {
    // use the tr_init macro to tell gettext where to look for translations
    let folder = if let Some(folder) = std::env::args().nth(1) {
    } else {
        println!("{}", tr!("Please give folder name"));
    match std::fs::read_dir(&folder) {
        Err(e) => {
            println!("{}", tr!("Could not read directory '{}'\nError: {}",
                                folder, e));
        Ok(r) => {
            // Singular/plural formating
            println!("{}", tr!(
                "The directory {} has one file" | "The directory {} has {n} files" % r.count(),

poor man's dynamic formater.

This module create a simple dynamic formater which replaces '{}' or '{n}' with the argument.

This does not use the runtime_fmt crate because it needs nightly compiler

TODO: better error reporting and support for more replacement option


~41K SLoC