Clean-up gettext code and make it more portable

This commit is contained in:
Andrew Resch 2008-11-29 21:21:05 +00:00
parent f42564b1aa
commit 0fe3d4d1af
2 changed files with 13 additions and 28 deletions

View file

@ -150,22 +150,15 @@ class Core(
self.register_introspection_functions()
# Initialize gettext
if deluge.common.windows_check() or deluge.common.osx_check():
locale.setlocale(locale.LC_ALL, '')
else:
locale.setlocale(locale.LC_MESSAGES, '')
locale.bindtextdomain("deluge",
pkg_resources.resource_filename(
"deluge", "i18n"))
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.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n"))
gettext.textdomain("deluge")
gettext.install("deluge",
pkg_resources.resource_filename(
"deluge", "i18n"))
gettext.install("deluge", pkg_resources.resource_filename("deluge", "i18n"))
# Setup signals
signal.signal(signal.SIGINT, self._shutdown)
signal.signal(signal.SIGTERM, self._shutdown)

View file

@ -102,22 +102,14 @@ class GtkUI:
gobject.threads_init()
# Initialize gettext
if deluge.common.windows_check() or deluge.common.osx_check():
locale.setlocale(locale.LC_ALL, '')
else:
locale.setlocale(locale.LC_MESSAGES, '')
locale.bindtextdomain("deluge",
pkg_resources.resource_filename(
"deluge", "i18n"))
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.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n"))
gettext.textdomain("deluge")
gettext.install("deluge",
pkg_resources.resource_filename(
"deluge", "i18n"))
gettext.install("deluge", pkg_resources.resource_filename("deluge", "i18n"))
# Setup signals
try: