diff --git a/deluge/core/core.py b/deluge/core/core.py index 0f501310c..2200f6a9d 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -114,14 +114,17 @@ class Core( self.register_introspection_functions() # Initialize gettext - locale.setlocale(locale.LC_ALL, '') - if hasattr(locale, "bindtextdomain"): - locale.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n")) - if hasattr(locale, "textdomain"): - locale.textdomain("deluge") - gettext.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n")) - gettext.textdomain("deluge") - gettext.install("deluge", pkg_resources.resource_filename("deluge", "i18n")) + try: + locale.setlocale(locale.LC_ALL, '') + if hasattr(locale, "bindtextdomain"): + locale.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n")) + if hasattr(locale, "textdomain"): + locale.textdomain("deluge") + gettext.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n")) + gettext.textdomain("deluge") + gettext.install("deluge", pkg_resources.resource_filename("deluge", "i18n")) + except Exception, e: + log.error("Unable to initialize gettext/locale: %s", e) # Setup signals signal.signal(signal.SIGINT, self._shutdown) diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 67fdd486f..0675f5819 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -118,14 +118,17 @@ class GtkUI: gobject.threads_init() # Initialize gettext - locale.setlocale(locale.LC_ALL, '') - if hasattr(locale, "bindtextdomain"): - locale.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n")) - if hasattr(locale, "textdomain"): - locale.textdomain("deluge") - gettext.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n")) - gettext.textdomain("deluge") - gettext.install("deluge", pkg_resources.resource_filename("deluge", "i18n")) + try: + locale.setlocale(locale.LC_ALL, '') + if hasattr(locale, "bindtextdomain"): + locale.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n")) + if hasattr(locale, "textdomain"): + locale.textdomain("deluge") + gettext.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n")) + gettext.textdomain("deluge") + gettext.install("deluge", pkg_resources.resource_filename("deluge", "i18n")) + except Exception, e: + log.error("Unable to initialize gettext/locale: %s", e) # Setup signals try: diff --git a/deluge/ui/webui/deluge_webserver.py b/deluge/ui/webui/deluge_webserver.py index 30ff72001..0beab9b52 100644 --- a/deluge/ui/webui/deluge_webserver.py +++ b/deluge/ui/webui/deluge_webserver.py @@ -34,22 +34,17 @@ from webserver_common import CONFIG_DEFAULTS config = ConfigManager("webui06.conf", CONFIG_DEFAULTS) # Initialize gettext -if deluge.common.windows_check() or deluge.common.osx_check(): +try: locale.setlocale(locale.LC_ALL, '') -else: - locale.setlocale(locale.LC_MESSAGES, '') - locale.bindtextdomain("deluge", - pkg_resources.resource_filename( - "deluge", "i18n")) - locale.textdomain("deluge") - -gettext.bindtextdomain("deluge", - pkg_resources.resource_filename( - "deluge", "i18n")) -gettext.textdomain("deluge") -gettext.install("deluge", - pkg_resources.resource_filename( - "deluge", "i18n")) + if hasattr(locale, "bindtextdomain"): + locale.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n")) + if hasattr(locale, "textdomain"): + locale.textdomain("deluge") + gettext.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n")) + gettext.textdomain("deluge") + gettext.install("deluge", pkg_resources.resource_filename("deluge", "i18n")) +except Exception, e: + log.error("Unable to initialize gettext/locale: %s", e) components.register() #after gettext!!