The GNU gettext package — the GNU internationalization tools — now supports the Rust programming language.
This means:
- The
xgettext
program can now extract translatable strings from Rust source code. - An
msgfmt -c
invocation now verifies the syntax of translations of Rust format strings. - A new example
hello-rust
is available, showing the use of thegettext-rs
crate for the runtime code and theformatx
crate for format strings.
See here for relevant documentation:
Compared to xtr
, xgettext
has two improvements:
xgettext
recognizes format string requirements (via theformatx!
macro) and annotates them with arust-format
attribute, thatmsgfmt -c
uses to verify that the translations of such format strings are well-formed and have have matching parameters.- While
xtr
extracts all comments before a translatable string, as if they were intended for a translator,xgettext
only extracts comments that are explicitly intended for a translator (e.g. command-line option--add-comments=TRANSLATORS:
); for more details, see the documentation section "Translator advice".