[gnome-tweak-tool] Use translations from schema files in the UI
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] Use translations from schema files in the UI
- Date: Sun, 9 Sep 2012 12:14:40 +0000 (UTC)
commit 743a1b5cc77e798ef6b95dd0564188b889558ca5
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Sat Sep 8 17:27:42 2012 +0200
Use translations from schema files in the UI
All GSettings schema files are translated by their respective packages,
so we can retrieve the translation by looking up the gettext-domain and
show the localized version of summary and description in the UI.
https://bugzilla.gnome.org/show_bug.cgi?id=683630
gnome-tweak-tool | 1 +
gtweak/gsettings.py | 15 +++++++++++++--
gtweak/tweaks/tweak_interface.py | 3 ---
gtweak/tweaks/tweak_windows.py | 1 -
4 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/gnome-tweak-tool b/gnome-tweak-tool
index 6102e1a..c377b01 100755
--- a/gnome-tweak-tool
+++ b/gnome-tweak-tool
@@ -57,6 +57,7 @@ if __name__ == '__main__':
gtweak.TWEAK_DIR = TWEAK_DIR
gtweak.DATA_DIR = DATA_DIR
gtweak.PKG_DATA_DIR = PKG_DATA_DIR
+ gtweak.LOCALE_DIR = LOCALE_DIR
gtweak.ENABLE_TEST = options.test
gtweak.APP_NAME = "gnome-tweak-tool"
gtweak.VERBOSE = options.verbose
diff --git a/gtweak/gsettings.py b/gtweak/gsettings.py
index 2739d6a..c87cb84 100644
--- a/gtweak/gsettings.py
+++ b/gtweak/gsettings.py
@@ -18,6 +18,7 @@
import logging
import os.path
import xml.dom.minidom
+import gettext
import gtweak
@@ -46,7 +47,17 @@ class _GSettingsSchema:
try:
dom = xml.dom.minidom.parse(schema_path)
+ global_gettext_domain = dom.documentElement.getAttribute('gettext-domain')
+ if global_gettext_domain:
+ # We can't know where the schema owner was installed, let's assume it's
+ # the same prefix as ours
+ gettext.bindtextdomain(global_gettext_domain, gtweak.LOCALE_DIR)
for schema in dom.getElementsByTagName("schema"):
+ gettext_domain = schema.getAttribute('gettext-domain')
+ if gettext_domain:
+ gettext.bindtextdomain(gettext_domain, gtweak.LOCALE_DIR)
+ else:
+ gettext_domain = global_gettext_domain
if schema_name == schema.getAttribute("id"):
for key in schema.getElementsByTagName("key"):
#summary is compulsory, description is optional
@@ -61,8 +72,8 @@ class _GSettingsSchema:
except:
description = ""
self._schema[key.getAttribute("name")] = {
- "summary" : summary,
- "description" : description
+ "summary" : gettext.dgettext(gettext_domain, summary),
+ "description" : gettext.dgettext(gettext_domain, description)
}
except:
logging.critical("Error parsing schema %s (%s)" % (schema_name, schema_path), exc_info=True)
diff --git a/gtweak/tweaks/tweak_interface.py b/gtweak/tweaks/tweak_interface.py
index 537ed48..65d197b 100644
--- a/gtweak/tweaks/tweak_interface.py
+++ b/gtweak/tweaks/tweak_interface.py
@@ -30,7 +30,6 @@ class GtkThemeSwitcher(GSettingsComboTweak):
"org.gnome.desktop.interface",
"gtk-theme",
make_combo_list_with_default(self._get_valid_themes(), "Adwaita"),
- summary=_("GTK+ theme"),
**options)
def _get_valid_themes(self):
@@ -48,7 +47,6 @@ class IconThemeSwitcher(GSettingsComboTweak):
"org.gnome.desktop.interface",
"icon-theme",
make_combo_list_with_default(self._get_valid_icon_themes(), "gnome"),
- summary=_("Icon theme"),
**options)
def _get_valid_icon_themes(self):
@@ -84,7 +82,6 @@ class KeyThemeSwitcher(GSettingsComboTweak):
self._get_valid_key_themes(),
"Default",
default_text=_("<i>Default</i>")),
- summary=_("Keybinding theme"),
**options)
def _get_valid_key_themes(self):
diff --git a/gtweak/tweaks/tweak_windows.py b/gtweak/tweaks/tweak_windows.py
index 90af82a..12f6fbf 100644
--- a/gtweak/tweaks/tweak_windows.py
+++ b/gtweak/tweaks/tweak_windows.py
@@ -28,7 +28,6 @@ class WindowThemeSwitcher(GSettingsComboTweak):
"org.gnome.desktop.wm.preferences",
"theme",
make_combo_list_with_default(self._get_valid_themes(), "Adwaita"),
- summary=_("Window theme"),
**options)
def _get_valid_themes(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]