Skip to content

Instantly share code, notes, and snippets.

@saivert
Created August 2, 2023 20:30
Show Gist options
  • Save saivert/9e14f2535bb6f0b09718818bfb8e7214 to your computer and use it in GitHub Desktop.
Save saivert/9e14f2535bb6f0b09718818bfb8e7214 to your computer and use it in GitHub Desktop.
gettext-rs development locale dir search path
fn main() -> gtk::glib::ExitCode {
let mut textdomain = gettextrs::TextDomain::new(GETTEXT_PACKAGE);
if cfg!(debug_assertions) {
// Add extra search path for debug builds so we don't have to install
textdomain = textdomain.prepend("../locale-test");
}
_ = textdomain.init().map_err(|x|{
// TranslationNotFound is not a fatal error, fallback to msgid (english)
if !matches!(x, TextDomainError::TranslationNotFound(_)) {
panic!("Unable to setup gettext!")
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment