From e194394479f7f2a50f56a346753ffa27dbc906f7 Mon Sep 17 00:00:00 2001 From: Denis Fomin <fominde@gmail.com> Date: Tue, 30 Aug 2011 15:23:16 +0300 Subject: [PATCH] imported patch 2011-08-27_00-06-54_r13163+.diff --- .../acronyms_expander/acronyms_expander.py | 4 +- plugins/plugin_installer/plugin_installer.py | 5 +-- src/plugins/gui.py | 3 +- src/plugins/pluginmanager.py | 4 ++ src/plugins/plugins_i18n.py | 39 +++++++++++++++++++ 5 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 src/plugins/plugins_i18n.py diff --git a/plugins/acronyms_expander/acronyms_expander.py b/plugins/acronyms_expander/acronyms_expander.py index 919f1a12c4..e325f67bf0 100644 --- a/plugins/acronyms_expander/acronyms_expander.py +++ b/plugins/acronyms_expander/acronyms_expander.py @@ -44,7 +44,7 @@ class AcronymsExpanderPlugin(GajimPlugin): } self.config_default_values = { - 'INVOKER': (' ', _('')), + 'INVOKER': (' ', ''), 'ACRONYMS': ({'RTFM': 'Read The Friendly Manual', '/slap': '/me slaps', 'PS-': 'plug-in system', @@ -53,7 +53,7 @@ class AcronymsExpanderPlugin(GajimPlugin): 'GW-': 'http://trac.gajim.org/', 'GTS-': 'http://trac.gajim.org/report', }, - _('')), + ''), } @log_calls('AcronymsExpanderPlugin') diff --git a/plugins/plugin_installer/plugin_installer.py b/plugins/plugin_installer/plugin_installer.py index b78572f635..ee0a744cf7 100644 --- a/plugins/plugin_installer/plugin_installer.py +++ b/plugins/plugin_installer/plugin_installer.py @@ -35,7 +35,6 @@ from plugins import GajimPlugin from plugins.helpers import log_calls, log from dialogs import WarningDialog, HigDialog from plugins.gui import GajimPluginConfigDialog -from common import i18n class PluginInstaller(GajimPlugin): @@ -74,7 +73,7 @@ class PluginInstaller(GajimPlugin): self.window.connect('destroy', self.on_win_destroy) self.GTK_BUILDER_FILE_PATH = self.local_file_path('config_dialog.ui') self.xml = gtk.Builder() - self.xml.set_translation_domain(i18n.APP) + self.xml.set_translation_domain('gajim_plugins') self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, ['hpaned2']) hpaned = self.xml.get_object('hpaned2') self.page_num = self.notebook.append_page(hpaned, @@ -228,7 +227,7 @@ class PluginInstaller(GajimPlugin): label.set_ellipsize(pango.ELLIPSIZE_END) self.plugin_homepage_linkbutton1.set_property('sensitive', True) desc_textbuffer = self.plugin_description_textview1.get_buffer() - desc_textbuffer.set_text(model.get_value(iter, 5)) + desc_textbuffer.set_text(_(model.get_value(iter, 5))) self.plugin_description_textview1.set_property('sensitive', True) else: self._clear_available_plugin_info() diff --git a/src/plugins/gui.py b/src/plugins/gui.py index d095b3da33..c24aa98de6 100644 --- a/src/plugins/gui.py +++ b/src/plugins/gui.py @@ -113,7 +113,8 @@ class PluginsWindow(object): self.plugin_homepage_linkbutton.set_property('sensitive', True) desc_textbuffer = self.plugin_description_textview.get_buffer() - desc_textbuffer.set_text(plugin.description) + from plugins.plugins_i18n import _ + desc_textbuffer.set_text(_(plugin.description)) self.plugin_description_textview.set_property('sensitive', True) self.uninstall_plugin_button.set_property('sensitive', gajim.PLUGINS_DIRS[1] in plugin.__path__) diff --git a/src/plugins/pluginmanager.py b/src/plugins/pluginmanager.py index f80e5f9917..e71042189b 100644 --- a/src/plugins/pluginmanager.py +++ b/src/plugins/pluginmanager.py @@ -393,6 +393,7 @@ class PluginManager(object): :todo: add scanning packages :todo: add scanning zipped modules ''' + from plugins.plugins_i18n import _ plugins_found = [] conf = ConfigParser.ConfigParser() fields = ('name', 'short_name', 'version', 'description', 'authors', @@ -460,6 +461,9 @@ class PluginManager(object): conf.remove_section('info') plugins_found.append(module_attr) + # set plugin localization + plugin_module = dir(module)[-1] + getattr(module, plugin_module)._ = _ except TypeError, type_error: pass diff --git a/src/plugins/plugins_i18n.py b/src/plugins/plugins_i18n.py new file mode 100644 index 0000000000..23e851e7e7 --- /dev/null +++ b/src/plugins/plugins_i18n.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# +## src/plugins/plugin_installer/plugins_i18n.py +## +## Copyright (C) 2010-2011 Denis Fomin <fominde AT gmail.com> +## +## This file is part of Gajim. +## +## Gajim is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation; version 3 only. +## +## Gajim is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Gajim. If not, see <http://www.gnu.org/licenses/>. +## +import locale +import gettext +from os import path as os_path +import os +from common import gajim + +APP = 'gajim_plugins' +plugins_locale_dir = os_path.join(gajim.PLUGINS_DIRS[1], 'locale') + +locale.setlocale(locale.LC_ALL, '') +locale.bindtextdomain(APP, plugins_locale_dir) +gettext.bindtextdomain(APP, plugins_locale_dir) +gettext.textdomain(APP) +try: + t = gettext.translation(APP, plugins_locale_dir) + _ = t.gettext +except IOError, msg: + from common import i18n + _ = gettext.gettext -- GitLab