From ea0dfa0023703ed3c3ea4e750cd257c71541ce02 Mon Sep 17 00:00:00 2001 From: Eisha CHEN-YEN-SU Date: Thu, 17 May 2018 11:42:07 +0200 Subject: [PATCH] App: Add the definition of the text domain This adds the definition of the text domain used by gettext to translate the strings of the user interface. gettext will search for a package named "fractal" in the directory "./fractal-gtk/po". Thus MO files containing the translations must be found in "./fractal-gtk/po/[LANG]/LC_MESSAGES/fractal.mo". Closes https://gitlab.gnome.org/World/fractal/issues/89 --- fractal-gtk/src/app/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fractal-gtk/src/app/mod.rs b/fractal-gtk/src/app/mod.rs index 559aaf6e..69a0e6d4 100644 --- a/fractal-gtk/src/app/mod.rs +++ b/fractal-gtk/src/app/mod.rs @@ -1,7 +1,9 @@ extern crate gtk; extern crate gdk; +extern crate gettextrs; use self::gtk::prelude::*; +use self::gettextrs::{setlocale, LocaleCategory, bindtextdomain, textdomain}; use std::env; use std::sync::{Arc, Mutex}; use std::sync::mpsc::channel; @@ -79,6 +81,12 @@ impl App { let bk = Backend::new(tx); let apptx = bk.run(); + // Set up the textdomain for gettext + setlocale(LocaleCategory::LcAll, ""); + bindtextdomain("fractal", "./fractal-gtk/po"); + textdomain("fractal"); + + let ui = uibuilder::UI::new(); let window: gtk::Window = ui.builder .get_object("main_window")