GNU gettext now supports Rust

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 the gettext-rs crate for the runtime code and the formatx crate for format strings.

See here for relevant documentation:

Compared to xtr, xgettext has two improvements:

  • xgettext recognizes format string requirements (via the formatx! macro) and annotates them with a rust-format attribute, that msgfmt -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".
4 Likes