[gnome-tweak-tool] Add l10n



commit d2b3a60009bc9d53362702dfeaa59f62f171712b
Author: John Stowers <john stowers gmail com>
Date:   Thu Jun 23 14:07:37 2011 +1200

    Add l10n

 NEWS                                    |    3 +++
 configure.ac                            |    1 +
 gnome-tweak-tool                        |   13 +++++++++++--
 gtweak/defs.py.in                       |    1 +
 gtweak/tweaks/tweak_font.py             |    2 +-
 gtweak/tweaks/tweak_interface.py        |    4 ++--
 gtweak/tweaks/tweak_nautilus.py         |    2 +-
 gtweak/tweaks/tweak_shell.py            |   28 ++++++++++++++--------------
 gtweak/tweaks/tweak_shell_extensions.py |   28 ++++++++++++++--------------
 gtweak/tweaks/tweak_windows.py          |    2 +-
 gtweak/utils.py                         |    2 +-
 po/POTFILES.in                          |    7 +++++++
 12 files changed, 57 insertions(+), 36 deletions(-)
---
diff --git a/NEWS b/NEWS
index 94e53f2..92f5694 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+3.1.0
+   * Mark many strings as translatable.
+
 3.0.5
    * More autostart desktop file fixes. Try harder to autostart nautilus when
      tweaking desktop handling.
diff --git a/configure.ac b/configure.ac
index 9cbdacf..ada6d40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,6 +27,7 @@ AS_AC_EXPAND(DATADIR, "${datadir}")
 AS_AC_EXPAND(PKGDATADIR, "${datadir}/${PACKAGE}")
 AS_AC_EXPAND(GSETTINGSSCHEMADIR, "${gsettingsschemadir}")
 AS_AC_EXPAND(TWEAKDIR, "${pythondir}/gtweak/tweaks")
+AS_AC_EXPAND(LOCALEDIR, "${localedir}")
 
 AC_CONFIG_FILES([ po/Makefile.in
 Makefile
diff --git a/gnome-tweak-tool b/gnome-tweak-tool
index a1f08b0..1ef5741 100755
--- a/gnome-tweak-tool
+++ b/gnome-tweak-tool
@@ -16,6 +16,8 @@
 import os.path
 import optparse
 import logging
+import locale
+import gettext
 
 import gi
 gi.require_version("Gtk", "3.0")
@@ -58,16 +60,17 @@ if __name__ == '__main__':
     options, args = parser.parse_args()
 
     try:
-        from gtweak.defs import GSETTINGS_SCHEMA_DIR, TWEAK_DIR, DATA_DIR, PKG_DATA_DIR
+        from gtweak.defs import GSETTINGS_SCHEMA_DIR, TWEAK_DIR, DATA_DIR, PKG_DATA_DIR, LOCALE_DIR
         _defs_present = True
     except ImportError:
-        GSETTINGS_SCHEMA_DIR = TWEAK_DIR = DATA_DIR = PKG_DATA_DIR = ""
+        GSETTINGS_SCHEMA_DIR = TWEAK_DIR = DATA_DIR = PKG_DATA_DIR = LOCALE_DIR = ""
         _defs_present = False
 
     #the supplied prefix always beats the contents of defs
     if options.prefix or not _defs_present:
         _prefix = options.prefix or "/usr"
         DATA_DIR = os.path.join(_prefix, "share")
+        LOCALE_DIR = os.path.join(_prefix, "share", "locale")
         GSETTINGS_SCHEMA_DIR = os.path.join(_prefix, "share", "glib-2.0", "schemas")
         _me = os.path.abspath(os.path.dirname(__file__))
         TWEAK_DIR = os.path.join(_me, "gtweak", "tweaks")
@@ -78,8 +81,14 @@ if __name__ == '__main__':
     gtweak.DATA_DIR = DATA_DIR
     gtweak.PKG_DATA_DIR = PKG_DATA_DIR
     gtweak.ENABLE_TEST = options.test
+    gtweak.APP_NAME = "gnome-tweak-tool"
 
     logging.basicConfig(format="%(levelname)-8s: %(message)s", level=logging.INFO)
 
+    locale.setlocale(locale.LC_ALL, None)
+    gettext.bindtextdomain(gtweak.APP_NAME, LOCALE_DIR)
+    gettext.textdomain(gtweak.APP_NAME)
+    gettext.install(gtweak.APP_NAME)
+
     MainWindow()
 
diff --git a/gtweak/defs.py.in b/gtweak/defs.py.in
index 030f555..12180db 100644
--- a/gtweak/defs.py.in
+++ b/gtweak/defs.py.in
@@ -3,3 +3,4 @@ PKG_DATA_DIR = "@PKGDATADIR@"
 GSETTINGS_SCHEMA_DIR = "@GSETTINGSSCHEMADIR@"
 TWEAK_DIR = "@TWEAKDIR@"
 VERSION = "@VERSION@"
+LOCALE_DIR = "@LOCALEDIR@"
diff --git a/gtweak/tweaks/tweak_font.py b/gtweak/tweaks/tweak_font.py
index 117e38d..a16aef6 100644
--- a/gtweak/tweaks/tweak_font.py
+++ b/gtweak/tweaks/tweak_font.py
@@ -24,7 +24,7 @@ sg = build_horizontal_sizegroup()
 
 TWEAK_GROUPS = (
         TweakGroup(
-            "Fonts",
+            _("Fonts"),
             GSettingsRangeTweak("org.gnome.desktop.interface", "text-scaling-factor", adjustment_step=0.1, size_group=sg),
             GSettingsFontButtonTweak("org.gnome.desktop.interface", "font-name", size_group=sg),
             GSettingsFontButtonTweak("org.gnome.desktop.interface", "document-font-name", size_group=sg),
diff --git a/gtweak/tweaks/tweak_interface.py b/gtweak/tweaks/tweak_interface.py
index 97e8982..31f778f 100644
--- a/gtweak/tweaks/tweak_interface.py
+++ b/gtweak/tweaks/tweak_interface.py
@@ -81,7 +81,7 @@ class KeyThemeSwitcher(GSettingsComboTweak):
             make_combo_list_with_default(
                 self._get_valid_key_themes(),
                 "Default",
-                default_text="<i>Default</i>"),
+                default_text=_("<i>Default</i>")),
             **options)
 
     def _get_valid_key_themes(self):
@@ -96,7 +96,7 @@ sg = build_horizontal_sizegroup()
 
 TWEAK_GROUPS = (
         TweakGroup(
-            "Interface",
+            _("Interface"),
             GSettingsSwitchTweak("org.gnome.desktop.interface", "menus-have-icons"),
             GSettingsSwitchTweak("org.gnome.desktop.interface", "buttons-have-icons"),
             GtkThemeSwitcher(size_group=sg),
diff --git a/gtweak/tweaks/tweak_nautilus.py b/gtweak/tweaks/tweak_nautilus.py
index 04272e4..5896ca1 100644
--- a/gtweak/tweaks/tweak_nautilus.py
+++ b/gtweak/tweaks/tweak_nautilus.py
@@ -45,7 +45,7 @@ class DesktopIconTweak(GSettingsSwitchTweak):
 
 TWEAK_GROUPS = (
         TweakGroup(
-            "File Manager",
+            _("File Manager"),
             DesktopIconTweak(),
             GSettingsSwitchTweak("org.gnome.nautilus.desktop", "computer-icon-visible", schema_filename="org.gnome.nautilus.gschema.xml"),
             GSettingsSwitchTweak("org.gnome.nautilus.desktop", "home-icon-visible", schema_filename="org.gnome.nautilus.gschema.xml"),
diff --git a/gtweak/tweaks/tweak_shell.py b/gtweak/tweaks/tweak_shell.py
index 445739e..9f8ffca 100644
--- a/gtweak/tweaks/tweak_shell.py
+++ b/gtweak/tweaks/tweak_shell.py
@@ -52,11 +52,11 @@ class ShellThemeTweak(Tweak):
         Tweak.__init__(self, "Shell Theme", "Install custom or user themes for gnome-shell", **options)
 
         #check the shell is running and the usertheme extension is present
-        error = "Unknown"
+        error = _("Unknown error")
         try:
             self._shell = GnomeShell()
         except:
-            error = "Shell not running"
+            error = _("Shell not running")
         try:
             extensions = self._shell.list_extensions()
             if ShellThemeTweak.THEME_EXT_NAME in extensions and extensions[ShellThemeTweak.THEME_EXT_NAME]["state"] == 1:
@@ -72,12 +72,12 @@ class ShellThemeTweak(Tweak):
 
                     error = None
                 except:
-                    error = "User Theme extension schema missing"
+                    error = _("Shell user-theme extension incorrectly installed")
 
             else:
-                error = "User Theme extension not enabled"
+                error = _("Shell user-theme extension not enabled")
         except Exception, e:
-            error = "Could not list shell extensions"
+            error = _("Could not list shell extensions")
 
         if error:
             cb = build_combo_box_text(None)
@@ -103,12 +103,12 @@ class ShellThemeTweak(Tweak):
                     *make_combo_list_with_default(
                         valid,
                         "",
-                        default_text="<i>Default</i>"))
+                        default_text=_("<i>Default</i>")))
             cb.connect('changed', self._on_combo_changed)
             self._combo = cb
 
             #a filechooser to install new themes
-            chooser = ZipFileChooserButton("Select a theme file")
+            chooser = ZipFileChooserButton(_("Select a theme"))
             chooser.connect("file-set", self._on_file_set)
 
             self.widget = build_label_beside_widget(self.name, chooser, cb)
@@ -155,9 +155,9 @@ class ShellThemeTweak(Tweak):
 
                 if ok:
                     if updated:
-                        self.notify_info("%s theme updated successfully" % theme_name)
+                        self.notify_info(_("%s theme updated successfully") % theme_name)
                     else:
-                        self.notify_info("%s theme installed successfully" % theme_name)
+                        self.notify_info(_("%s theme installed successfully") % theme_name)
 
                     #I suppose I could rely on updated as indicating whether to add the theme
                     #name to the combo, but just check to see if it is already there
@@ -165,12 +165,12 @@ class ShellThemeTweak(Tweak):
                     if theme_name not in [r[0] for r in model]:
                         model.append( (theme_name, theme_name) )
                 else:
-                    self.notify_error("Error installing theme")
+                    self.notify_error(_("Error installing theme"))
 
 
             except:
                 #does not look like a valid theme
-                self.notify_error("Invalid theme file")
+                self.notify_error(_("Invalid theme"))
                 logging.warning("Error parsing theme zip", exc_info=True)
 
         #set button back to default state
@@ -191,15 +191,15 @@ class ShellThemeTweak(Tweak):
         if not val:
             if self._usertheme_extension_version < "3.0.2":
                 self.notify_action_required(
-                    "The shell may need to be restarted to apply the theme",
-                    "Restart",
+                    _("The shell may need to be restarted to apply the theme"),
+                    _("Restart"),
                     lambda: self._shell.restart())
 
 sg = build_horizontal_sizegroup()
 
 TWEAK_GROUPS = (
         TweakGroup(
-            "Shell",
+            _("Shell"),
             GSettingsSwitchTweak("org.gnome.shell.clock", "show-date", schema_filename="org.gnome.shell.gschema.xml"),
             GSettingsSwitchTweak("org.gnome.shell.calendar", "show-weekdate", schema_filename="org.gnome.shell.gschema.xml"),
             ShowWindowButtons(size_group=sg),
diff --git a/gtweak/tweaks/tweak_shell_extensions.py b/gtweak/tweaks/tweak_shell_extensions.py
index 6d9bc47..02ffb87 100644
--- a/gtweak/tweaks/tweak_shell_extensions.py
+++ b/gtweak/tweaks/tweak_shell_extensions.py
@@ -38,16 +38,16 @@ class _ShellExtensionTweak(Tweak):
            state == GnomeShell.EXTENSION_STATE["DISABLED"]:
             sensitive = True
         elif state == GnomeShell.EXTENSION_STATE["ERROR"]:
-            warning = "Error loading"
+            warning = _("Error loading extension")
         elif state == GnomeShell.EXTENSION_STATE["OUT_OF_DATE"]:
-            warning = "Extension does not support shell version"
+            warning = _("Extension does not support shell version")
         else:
-            warning = "Unknown extension state"
+            warning = _("Unknown extension error")
             logging.critical(warning)
         sw.set_sensitive(sensitive)
 
         self.widget = build_label_beside_widget(
-                        "%s Extension" % ext["name"],
+                        _("%s Extension") % ext["name"],
                         sw,
                         warning=warning)
         self.widget_for_size_group = sw
@@ -59,8 +59,8 @@ class _ShellExtensionTweak(Tweak):
             self._settings.setting_remove_from_list(self.EXTENSION_DISABLED_KEY, uuid)
 
         self.notify_action_required(
-            "The shell must be restarted for changes to take effect",
-            "Restart",
+            _("The shell must be restarted for changes to take effect"),
+            _("Restart"),
             self._shell.restart)
 
 class _ShellExtensionInstallerTweak(Tweak):
@@ -68,11 +68,11 @@ class _ShellExtensionInstallerTweak(Tweak):
     EXTENSION_DIR = os.path.join(GLib.get_user_data_dir(), "gnome-shell", "extensions")
 
     def __init__(self, shell, **options):
-        Tweak.__init__(self, "Install Shell Extension", "", **options)
+        Tweak.__init__(self, _("Install Shell Extension"), "", **options)
 
         self._shell = shell
 
-        chooser = ZipFileChooserButton("Select a theme file")
+        chooser = ZipFileChooserButton(_("Select an extension"))
         chooser.connect("file-set", self._on_file_set)
 
         self.widget = build_label_beside_widget(self.name, chooser)
@@ -120,22 +120,22 @@ class _ShellExtensionInstallerTweak(Tweak):
 
                 if ok:
                     if updated:
-                        verb = "%s extension updated successfully" % extension_uuid
+                        verb = _("%s extension updated successfully") % extension_uuid
                     else:
-                        verb = "%s extension installed successfully" % extension_uuid
+                        verb = _("%s extension installed successfully") % extension_uuid
 
                     self.notify_action_required(
                         verb,
-                        "Restart",
+                        _("Restart"),
                         self._shell.restart)
 
                 else:
-                    self.notify_error("Error installing extension")
+                    self.notify_error(_("Error installing extension"))
 
 
             except:
                 #does not look like a valid theme
-                self.notify_error("Invalid extension file")
+                self.notify_error(_("Invalid extension"))
                 logging.warning("Error parsing theme zip", exc_info=True)
 
         #set button back to default state
@@ -168,7 +168,7 @@ class ShellExtensionTweakGroup(TweakGroup):
         except:
             logging.warning("Error detecting shell")
 
-        TweakGroup.__init__(self, "Shell Extensions", *extension_tweaks)
+        TweakGroup.__init__(self, _("Shell Extensions"), *extension_tweaks)
 
 TWEAK_GROUPS = (
         ShellExtensionTweakGroup(),
diff --git a/gtweak/tweaks/tweak_windows.py b/gtweak/tweaks/tweak_windows.py
index 275728e..aa3cc68 100644
--- a/gtweak/tweaks/tweak_windows.py
+++ b/gtweak/tweaks/tweak_windows.py
@@ -75,7 +75,7 @@ sg = build_horizontal_sizegroup()
 
 TWEAK_GROUPS = (
         TweakGroup(
-            "Windows",
+            _("Windows"),
             WindowThemeSwitcher(size_group=sg),
             ActionClickTitlebarTweak("/apps/metacity/general/action_double_click_titlebar", size_group=sg),
             ActionClickTitlebarTweak("/apps/metacity/general/action_middle_click_titlebar", size_group=sg),
diff --git a/gtweak/utils.py b/gtweak/utils.py
index 42d3502..3c4a82c 100644
--- a/gtweak/utils.py
+++ b/gtweak/utils.py
@@ -49,7 +49,7 @@ def make_combo_list_with_default(opts, default, title=True, default_text=None):
             name = t
 
         if t == default:
-            name = default_text or "%s <i>(default)</i>" % name
+            name = default_text or _("%s <i>(default)</i>") % name
 
         themes.append((t, name))
     return themes
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fc59940..beb9380 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,3 +2,10 @@
 [type: gettext/glade]data/shell.ui
 # files added by intltool-prepare
 data/gnome-tweak-tool.desktop.in
+gtweak/tweaks/tweak_font.py
+gtweak/tweaks/tweak_interface.py
+gtweak/tweaks/tweak_nautilus.py
+gtweak/tweaks/tweak_shell.py
+gtweak/tweaks/tweak_shell_extensions.py
+gtweak/tweaks/tweak_windows.py
+gtweak/utils.py



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]