Crate gettextrs[−][src]
gettext C library FFI binding for Rust
Usage:
use gettextrs::*; setlocale(LocaleCategory::LcAll, "en_US.UTF-8"); bindtextdomain("hellorust", "/usr/local/share/locale"); textdomain("hellorust"); println!("Translated: {}", gettext("Hello, world!")); println!("Singular: {}", ngettext("One thing", "Multiple things", 1)); println!("Plural: {}", ngettext("One thing", "Multiple things", 2));
Alternatively, you can initialize the locale and text domain using the TextDomain
builder.
By default, a translation of the specified text domain in current language is searched in
the system's data paths. See TextDomain
's documentation for other options.
use gettextrs::TextDomain; TextDomain::new("hellorust") .init() .unwrap();
Structs
TextDomain |
A text domain initializer builder which finds the path to bind by searching translations in the system data paths and optionally in user specified paths. |
Enums
LocaleCategory |
Locale category enum ported from locale.h |
TextDomainError |
Functions
bind_textdomain_codeset | |
bindtextdomain |
Bind text domain to some directory containing gettext MO files |
dcgettext |
Translate msgid to localized message from specified domain using custom locale category |
dcngettext |
Translate msgid to localized message from specified domain using custom locale category (with plural support) |
dgettext |
Translate msgid to localized message from specified domain |
dngettext |
Translate msgid to localized message from specified domain (with plural support) |
gettext |
Translate msgid to localized message from default domain |
ngettext |
Translate msgid to localized message from default domain (with plural support) |
npgettext |
Translate msgid to localized message from default domain (with plural support and context support) |
pgettext |
Translate msgid to localized message from default domain (with context support) |
setlocale |
Set current locale for translations |
textdomain |
Switch to specific text domain |