Author: remi
Date: 2009-06-28 23:15:14 +0200 (Sun, 28 Jun 2009)
New Revision: 4924

Modified:
   software_suite_v3/smart-core/smart-server/trunk/util/i18n/I18n.py
Log:
* fixed a problem with translation requests with mixed encoding.

Modified: software_suite_v3/smart-core/smart-server/trunk/util/i18n/I18n.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/i18n/I18n.py   
2009-06-28 21:14:28 UTC (rev 4923)
+++ software_suite_v3/smart-core/smart-server/trunk/util/i18n/I18n.py   
2009-06-28 21:15:14 UTC (rev 4924)
@@ -99,6 +99,14 @@
         value = value.replace("'", "''")
         for i, argument in enumerate(arguments):
             trArg = str(argument)
+            try:
+                # Some applications sends a mixed encoding. For example :
+                # Weather gadget (in french) sends message in utf-8 with
+                # arguments in latin-1 ...
+                trArg = trArg.decode("latin-1", "ignore")
+                trArg = trArg.encode("utf-8", "ignore")
+            except:
+                pass
             if self.__data.has_key(trArg):
                 trArg = self.__data[trArg]
             value = value.replace("{%d}" % i, trArg)


------------------------------------------------------------------------------
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to