gettr
gettr is a i18n framework for rust.
It's initial objective is to support i18n for yew applications.
Getting Started
Add gettr as dependency and as build-dependency.
[]
= "0.0.1"
[]
= "0.0.1"
add build step to build.rs:
use PathBuf;
build.rs
use gettr
src/main.rs
gettr will search all files in src and find calls of the gettr! macro. The default language is used as translation key and fallback. For each call a translation file is generated in src/i18n. In this case the following file is generated:
// This file is generated and automatically updated by gettr.
// Values set to keys will be kept on updates.
// src/main.rs#8
"Hello World! {}" = ""
src/i18n/de
You can maintain the translation for Hello World! in this file. It will be automatically updated on every build. Existing keys will be kept. If a maintained key can no longer be found in the code it is removed.
Integration with yew
Using the yew feature you can use the provided GettrContext and use_gettr to integrate gettr in your yew client.
use Routing;
use ;
use GettrProvider;
use ;
Limitations
formatting
gettr uses a regular expression to find regex! calls in the code. This means it won't work well with formatting these calls in more than one line.
Good:
gettr!;
Bad:
gettr!;
placeholders
Rusts fmt macros allow named arguments. gettr can not handle them ATM.
plurals
gettr has no support for plural forms other than specifing them manually.