Workaround to make translation works

merge-requests/64/head
Huluti 2016-12-11 00:05:32 +01:00
parent 02400eb6bf
commit 58894fa9d3
5 changed files with 133 additions and 98 deletions

View File

@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-09 17:26+0100\n" "POT-Creation-Date: 2016-12-10 23:59+0100\n"
"PO-Revision-Date: 2016-12-09 17:26+0100\n" "PO-Revision-Date: 2016-12-10 23:59+0100\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"Language: fr_FR\n" "Language: fr_FR\n"
@ -30,11 +30,11 @@ msgstr "Écran de bienvenue pour Manjaro"
msgid "Github" msgid "Github"
msgstr "Github" msgstr "Github"
#: manjaro-hello.glade:104 #: manjaro-hello.glade:103
msgid "Welcome to Manjaro!" msgid "Welcome to Manjaro!"
msgstr "Bienvenue sur Manjaro !" msgstr "Bienvenue sur Manjaro !"
#: manjaro-hello.glade:121 #: manjaro-hello.glade:120
msgid "" msgid ""
"Thank you for joining our community!\n" "Thank you for joining our community!\n"
"\n" "\n"
@ -51,86 +51,84 @@ msgstr ""
"Alors profitez de l'expérience, et n'hésitez pas à nous faire part de vos " "Alors profitez de l'expérience, et n'hésitez pas à nous faire part de vos "
"commentaires." "commentaires."
#: manjaro-hello.glade:138 #: manjaro-hello.glade:137
msgid "DOCUMENTATION" msgid "DOCUMENTATION"
msgstr "DOCUMENTATION" msgstr "DOCUMENTATION"
#: manjaro-hello.glade:152 #: manjaro-hello.glade:151
msgid "SUPPORT" msgid "SUPPORT"
msgstr "SUPPORT" msgstr "SUPPORT"
#: manjaro-hello.glade:166 #: manjaro-hello.glade:165
msgid "PROJECT" msgid "PROJECT"
msgstr "PROJET" msgstr "PROJET"
#: manjaro-hello.glade:178 manjaro-hello.glade:542 #: manjaro-hello.glade:177 manjaro-hello.glade:537
msgid "Read me" msgid "Read me"
msgstr "Lisez moi" msgstr "Lisez moi"
#: manjaro-hello.glade:192 manjaro-hello.glade:582 #: manjaro-hello.glade:191 manjaro-hello.glade:577
msgid "Release info" msgid "Release info"
msgstr "Informations de version" msgstr "Informations de version"
#: manjaro-hello.glade:206 #: manjaro-hello.glade:205
msgid "Wiki" msgid "Wiki"
msgstr "Wiki" msgstr "Wiki"
#: manjaro-hello.glade:220 manjaro-hello.glade:643 #: manjaro-hello.glade:219 manjaro-hello.glade:638
msgid "Get involved" msgid "Get involved"
msgstr "S'investir" msgstr "S'investir"
#: manjaro-hello.glade:234 #: manjaro-hello.glade:233
msgid "Forums" msgid "Forums"
msgstr "Forums" msgstr "Forums"
#: manjaro-hello.glade:248 #: manjaro-hello.glade:247
msgid "Chat room" msgid "Chat room"
msgstr "Salon de chat" msgstr "Salon de chat"
#: manjaro-hello.glade:262 #: manjaro-hello.glade:261
msgid "Mailling lists" msgid "Mailling lists"
msgstr "Listes de diffusion" msgstr "Listes de diffusion"
#: manjaro-hello.glade:276 #: manjaro-hello.glade:275
msgid "Build Manjaro" msgid "Build Manjaro"
msgstr "Construire Manjaro" msgstr "Construire Manjaro"
#: manjaro-hello.glade:290 #: manjaro-hello.glade:289
msgid "Donate" msgid "Donate"
msgstr "Faire un don" msgstr "Faire un don"
#: manjaro-hello.glade:406 #: manjaro-hello.glade:401
msgid "Launch at start" msgid "Launch at start"
msgstr "Lancer au démarrage" msgstr "Lancer au démarrage"
#: manjaro-hello.glade:443 #: manjaro-hello.glade:438
msgid "Use Calamares (Graphic method)" msgid "Use Calamares (Graphic method)"
msgstr "Utiliser Calamares (Méthode graphique)" msgstr "Utiliser Calamares (Méthode graphique)"
#: manjaro-hello.glade:457 #: manjaro-hello.glade:452
msgid "Use CLI-Installer (Command line)" msgid "Use CLI-Installer (Command line)"
msgstr "Utiliser CLI-Installer (Ligne de commande)" msgstr "Utiliser CLI-Installer (Ligne de commande)"
#: manjaro-hello.glade:479 #: manjaro-hello.glade:474
msgid "INSTALLATION" msgid "INSTALLATION"
msgstr "INSTALLATION" msgstr "INSTALLATION"
#: manjaro-hello.glade:498 #: manjaro-hello.glade:493
msgid "Welcome" msgid "Welcome"
msgstr "Bienvenue" msgstr "Bienvenue"
#: manjaro-hello.glade:598 #: manjaro-hello.glade:593
msgid "Documentation" msgid "Documentation"
msgstr "Documentation" msgstr "Documentation"
#: manjaro-hello.glade:664 #: manjaro-hello.glade:659
msgid "Project" msgid "Project"
msgstr "Projet" msgstr "Projet"
#: manjaro-hello.glade:687 #~ msgid "English (United States)"
msgid "English (United States)" #~ msgstr "Anglais (États-Unis)"
msgstr "Anglais (États-Unis)"
#: manjaro-hello.glade:688 #~ msgid "French (France)"
msgid "French (France)" #~ msgstr "Français (France)"
msgstr "Français (France)"

View File

@ -75,7 +75,7 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="transition_type">crossfade</property> <property name="transition_type">crossfade</property>
<child> <child>
<object class="GtkGrid"> <object class="GtkGrid" id="welcome">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_left">10</property> <property name="margin_left">10</property>
@ -97,7 +97,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="welcomelabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Welcome to Manjaro!</property> <property name="label" translatable="yes">Welcome to Manjaro!</property>
@ -113,7 +113,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="welcometext">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
@ -131,7 +131,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="documentationtitle">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">DOCUMENTATION</property> <property name="label" translatable="yes">DOCUMENTATION</property>
@ -145,7 +145,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="supporttitle">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">SUPPORT</property> <property name="label" translatable="yes">SUPPORT</property>
@ -159,7 +159,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="projecttitle">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">PROJECT</property> <property name="label" translatable="yes">PROJECT</property>
@ -173,7 +173,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton" id="readmebtn">
<property name="label" translatable="yes">Read me</property> <property name="label" translatable="yes">Read me</property>
<property name="name">readmebtn</property> <property name="name">readmebtn</property>
<property name="visible">True</property> <property name="visible">True</property>
@ -187,7 +187,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton" id="releasebtn">
<property name="label" translatable="yes">Release info</property> <property name="label" translatable="yes">Release info</property>
<property name="name">releasebtn</property> <property name="name">releasebtn</property>
<property name="visible">True</property> <property name="visible">True</property>
@ -201,7 +201,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton" id="wikibtn">
<property name="label" translatable="yes">Wiki</property> <property name="label" translatable="yes">Wiki</property>
<property name="name">wikibtn</property> <property name="name">wikibtn</property>
<property name="visible">True</property> <property name="visible">True</property>
@ -215,7 +215,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton" id="involvedbtn">
<property name="label" translatable="yes">Get involved</property> <property name="label" translatable="yes">Get involved</property>
<property name="name">involvedbtn</property> <property name="name">involvedbtn</property>
<property name="visible">True</property> <property name="visible">True</property>
@ -229,7 +229,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton" id="forumsbtn">
<property name="label" translatable="yes">Forums</property> <property name="label" translatable="yes">Forums</property>
<property name="name">forumsbtn</property> <property name="name">forumsbtn</property>
<property name="visible">True</property> <property name="visible">True</property>
@ -243,7 +243,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton" id="chatbtn">
<property name="label" translatable="yes">Chat room</property> <property name="label" translatable="yes">Chat room</property>
<property name="name">chatbtn</property> <property name="name">chatbtn</property>
<property name="visible">True</property> <property name="visible">True</property>
@ -257,7 +257,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton" id="maillingbtn">
<property name="label" translatable="yes">Mailling lists</property> <property name="label" translatable="yes">Mailling lists</property>
<property name="name">maillingbtn</property> <property name="name">maillingbtn</property>
<property name="visible">True</property> <property name="visible">True</property>
@ -271,7 +271,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton" id="buildbtn">
<property name="label" translatable="yes">Build Manjaro</property> <property name="label" translatable="yes">Build Manjaro</property>
<property name="name">buildbtn</property> <property name="name">buildbtn</property>
<property name="visible">True</property> <property name="visible">True</property>
@ -285,7 +285,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton" id="donatebtn">
<property name="label" translatable="yes">Donate</property> <property name="label" translatable="yes">Donate</property>
<property name="name">donatebtn</property> <property name="name">donatebtn</property>
<property name="visible">True</property> <property name="visible">True</property>
@ -394,7 +394,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="autostartlabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">end</property> <property name="halign">end</property>
@ -531,7 +531,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
<object class="GtkLabel"> <object class="GtkLabel" id="readmelabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Read me</property> <property name="label" translatable="yes">Read me</property>
@ -571,7 +571,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
<object class="GtkLabel"> <object class="GtkLabel" id="releaselabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Release info</property> <property name="label" translatable="yes">Release info</property>
@ -632,7 +632,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
<object class="GtkLabel"> <object class="GtkLabel" id="involvedlabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Get involved</property> <property name="label" translatable="yes">Get involved</property>
@ -679,8 +679,8 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<items> <items>
<item id="en_US" translatable="yes">English (United States)</item> <item id="en_US">English (United States)</item>
<item id="fr_FR" translatable="yes">French (France)</item> <item id="fr_FR">Français (France)</item>
</items> </items>
</object> </object>
<packing> <packing>

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-09 17:26+0100\n" "POT-Creation-Date: 2016-12-10 23:58+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -29,11 +29,11 @@ msgstr ""
msgid "Github" msgid "Github"
msgstr "" msgstr ""
#: manjaro-hello.glade:104 #: manjaro-hello.glade:103
msgid "Welcome to Manjaro!" msgid "Welcome to Manjaro!"
msgstr "" msgstr ""
#: manjaro-hello.glade:121 #: manjaro-hello.glade:120
msgid "" msgid ""
"Thank you for joining our community!\n" "Thank you for joining our community!\n"
"\n" "\n"
@ -43,86 +43,78 @@ msgid ""
"your feedback." "your feedback."
msgstr "" msgstr ""
#: manjaro-hello.glade:138 #: manjaro-hello.glade:137
msgid "DOCUMENTATION" msgid "DOCUMENTATION"
msgstr "" msgstr ""
#: manjaro-hello.glade:152 #: manjaro-hello.glade:151
msgid "SUPPORT" msgid "SUPPORT"
msgstr "" msgstr ""
#: manjaro-hello.glade:166 #: manjaro-hello.glade:165
msgid "PROJECT" msgid "PROJECT"
msgstr "" msgstr ""
#: manjaro-hello.glade:178 manjaro-hello.glade:542 #: manjaro-hello.glade:177 manjaro-hello.glade:537
msgid "Read me" msgid "Read me"
msgstr "" msgstr ""
#: manjaro-hello.glade:192 manjaro-hello.glade:582 #: manjaro-hello.glade:191 manjaro-hello.glade:577
msgid "Release info" msgid "Release info"
msgstr "" msgstr ""
#: manjaro-hello.glade:206 #: manjaro-hello.glade:205
msgid "Wiki" msgid "Wiki"
msgstr "" msgstr ""
#: manjaro-hello.glade:220 manjaro-hello.glade:643 #: manjaro-hello.glade:219 manjaro-hello.glade:638
msgid "Get involved" msgid "Get involved"
msgstr "" msgstr ""
#: manjaro-hello.glade:234 #: manjaro-hello.glade:233
msgid "Forums" msgid "Forums"
msgstr "" msgstr ""
#: manjaro-hello.glade:248 #: manjaro-hello.glade:247
msgid "Chat room" msgid "Chat room"
msgstr "" msgstr ""
#: manjaro-hello.glade:262 #: manjaro-hello.glade:261
msgid "Mailling lists" msgid "Mailling lists"
msgstr "" msgstr ""
#: manjaro-hello.glade:276 #: manjaro-hello.glade:275
msgid "Build Manjaro" msgid "Build Manjaro"
msgstr "" msgstr ""
#: manjaro-hello.glade:290 #: manjaro-hello.glade:289
msgid "Donate" msgid "Donate"
msgstr "" msgstr ""
#: manjaro-hello.glade:406 #: manjaro-hello.glade:401
msgid "Launch at start" msgid "Launch at start"
msgstr "" msgstr ""
#: manjaro-hello.glade:443 #: manjaro-hello.glade:438
msgid "Use Calamares (Graphic method)" msgid "Use Calamares (Graphic method)"
msgstr "" msgstr ""
#: manjaro-hello.glade:457 #: manjaro-hello.glade:452
msgid "Use CLI-Installer (Command line)" msgid "Use CLI-Installer (Command line)"
msgstr "" msgstr ""
#: manjaro-hello.glade:479 #: manjaro-hello.glade:474
msgid "INSTALLATION" msgid "INSTALLATION"
msgstr "" msgstr ""
#: manjaro-hello.glade:498 #: manjaro-hello.glade:493
msgid "Welcome" msgid "Welcome"
msgstr "" msgstr ""
#: manjaro-hello.glade:598 #: manjaro-hello.glade:593
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
#: manjaro-hello.glade:664 #: manjaro-hello.glade:659
msgid "Project" msgid "Project"
msgstr "" msgstr ""
#: manjaro-hello.glade:687
msgid "English (United States)"
msgstr ""
#: manjaro-hello.glade:688
msgid "French (France)"
msgstr ""

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from locale import gettext as _ import gettext
import gi import gi
import json import json
import locale import locale
@ -53,7 +53,17 @@ class ManjaroHello():
"locale": None "locale": None
} }
# Load system infos
self.infos = get_infos()
# Init window
self.builder = Gtk.Builder()
self.builder.add_from_file("manjaro-hello.glade")
self.builder.connect_signals(self)
self.window = self.builder.get_object("window")
# Init translation # Init translation
self.default_texts = {}
locales = os.listdir(self.locale_path) locales = os.listdir(self.locale_path)
locales.append(self.default_locale) locales.append(self.default_locale)
if self.preferences["locale"] not in locales: if self.preferences["locale"] not in locales:
@ -62,26 +72,18 @@ class ManjaroHello():
else: else:
self.preferences["locale"] = self.default_locale self.preferences["locale"] = self.default_locale
locale.setlocale(locale.LC_ALL, self.preferences["locale"] + ".utf8") # Select current locale in languages menu
locale.bindtextdomain(self.app, self.locale_path) self.builder.get_object("languages").set_active_id(self.preferences["locale"]);
locale.textdomain(self.app) self.builder.get_object("languages").connect("changed", self.on_languages_changed)
# Make translation
gettext.bindtextdomain(self.app, self.locale_path)
gettext.textdomain(self.app)
self.set_locale(self.preferences["locale"])
# Save locale used in config file # Save locale used in config file
self.save_preferences() self.save_preferences()
# Load system infos
self.infos = get_infos()
# Init window
self.builder = Gtk.Builder()
self.builder.set_translation_domain(self.app)
self.builder.add_from_file("manjaro-hello.glade")
self.builder.connect_signals(self)
self.window = self.builder.get_object("window")
# Select current locale in languages menu
self.builder.get_object("languages").set_active_id(self.preferences["locale"]);
self.builder.get_object("languages").connect("changed", self.on_languages_changed)
# Set window subtitle # Set window subtitle
if self.infos["codename"] and self.infos["release"]: if self.infos["codename"] and self.infos["release"]:
@ -115,6 +117,49 @@ class ManjaroHello():
self.window.show(); self.window.show();
def set_locale(self, locale_code):
if self.preferences["locale"] != self.default_locale:
locale = gettext.translation(self.app, self.locale_path, [locale_code])
locale.install()
else:
gettext.install(self.app)
# Dirty code to fix an issue with gettext that can't translate text from glade interface
# TODO: Find a better solution
elts = {
"welcomelabel": "label",
"welcometext": "label",
"documentationtitle": "label",
"readmelabel": "label",
"releaselabel": "label",
"involvedlabel": "label",
"supporttitle": "label",
"projecttitle": "label",
"readmebtn": "label",
"releasebtn": "label",
"wikibtn": "label",
"involvedbtn": "label",
"forumsbtn": "label",
"chatbtn": "label",
"maillingbtn": "label",
"buildbtn": "label",
"donatebtn": "label",
"installlabel": "label",
"installgui": "label",
"installcli": "label",
"autostartlabel": "label",
"aboutdialog": "comments"
}
for elt in elts:
if elt not in self.default_texts:
self.default_texts[elt] = getattr(self.builder.get_object(elt), "get_" + elts[elt])()
getattr(self.builder.get_object(elt), "set_" + elts[elt])(_(self.default_texts[elt]))
for stack in ("welcome", "documentation", "project"):
if stack not in self.default_texts:
self.default_texts[stack] = self.builder.get_object("stack").child_get_property(self.builder.get_object(stack), "title")
self.builder.get_object("stack").child_set_property(self.builder.get_object(stack), "title", _(self.default_texts[stack]))
def change_autostart(self, state): def change_autostart(self, state):
if state and not os.path.isfile(self.autostart_path): if state and not os.path.isfile(self.autostart_path):
try: try:
@ -156,8 +201,8 @@ class ManjaroHello():
# Handlers # Handlers
def on_languages_changed(self, combobox): def on_languages_changed(self, combobox):
self.preferences["locale"] = combobox.get_active_id() self.preferences["locale"] = combobox.get_active_id()
self.set_locale(self.preferences["locale"])
self.save_preferences() self.save_preferences()
os.execv(sys.executable, ['python'] + sys.argv)
def on_about_clicked(self, btn): def on_about_clicked(self, btn):
dialog = self.builder.get_object("aboutdialog") dialog = self.builder.get_object("aboutdialog")