[meld] Fix initialisation of translations under Windows



commit 2244954e4901e6c27b1b5509fd0467b189d64923
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Mon Mar 4 05:46:36 2013 +1000

    Fix initialisation of translations under Windows

 bin/meld |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/bin/meld b/bin/meld
index 4094176..f90adbb 100755
--- a/bin/meld
+++ b/bin/meld
@@ -88,19 +88,27 @@ locale_domain = "meld"
 locale_dir = meld.paths.locale_dir()
 
 gettext.bindtextdomain(locale_domain, locale_dir)
-locale.setlocale(locale.LC_ALL,'')
+locale.setlocale(locale.LC_ALL, '')
 gettext.textdomain(locale_domain)
 gettext.install(locale_domain, localedir=locale_dir, unicode=True)
 
 try:
-    locale.bindtextdomain(locale_domain, locale_dir)
-    locale.bind_textdomain_codeset(locale_domain, 'UTF-8')
-except AttributeError:
+    if os.name == 'nt':
+        from ctypes import cdll
+        libintl = cdll.intl
+        libintl.bindtextdomain(locale_domain, locale_dir)
+        libintl.bind_textdomain_codeset(locale_domain, 'UTF-8')
+    else:
+        locale.bindtextdomain(locale_domain, locale_dir)
+        locale.bind_textdomain_codeset(locale_domain, 'UTF-8')
+except AttributeError as e:
     # OS X doesn't appear to have bindtextdomain(). This will cause
     # gtk.Builder translations to fail.
     print "Couldn't bind the translation domain. Some translations won't work."
-except locale.Error:
+    print e
+except locale.Error as e:
     print "Couldn't bind the translation domain. Some translations won't work."
+    print e
 
 
 # Check requirements: Python 2.6, pygtk 2.14


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