[tuxdroid-svn] r5063 - in software_suite_v3/smart-core/smart-server/trunk: . util/i18n
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-07-06 11:54:51
|
Author: remi
Date: 2009-07-06 13:54:36 +0200 (Mon, 06 Jul 2009)
New Revision: 5063
Modified:
software_suite_v3/smart-core/smart-server/trunk/TDSService.py
software_suite_v3/smart-core/smart-server/trunk/util/i18n/I18n.py
Log:
* Fixed encoding bug with IE6
Modified: software_suite_v3/smart-core/smart-server/trunk/TDSService.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/TDSService.py 2009-07-06 08:43:28 UTC (rev 5062)
+++ software_suite_v3/smart-core/smart-server/trunk/TDSService.py 2009-07-06 11:54:36 UTC (rev 5063)
@@ -147,7 +147,7 @@
result += recurse(struct[key])
result += "</%s>" % nodeName
return result
- result = '<?xml version="1.0" ?>'
+ result = '<?xml version="1.0" encoding="UTF-8"?>'
if self.haveXsl:
result += '<?xml-stylesheet type="text/xsl" href="%s"?>' % self.xslPath
result += recurse(contentStruct)
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-07-06 08:43:28 UTC (rev 5062)
+++ software_suite_v3/smart-core/smart-server/trunk/util/i18n/I18n.py 2009-07-06 11:54:36 UTC (rev 5063)
@@ -9,6 +9,7 @@
import os
import locale
+import codecs
# ------------------------------------------------------------------------------
# Class to read and use i18n po files.
@@ -120,15 +121,27 @@
"""Update the internal data dictionary with the current po dictionary
and locale.
"""
+ def decodeUtf8Bom(text):
+ if text[:3] == codecs.BOM_UTF8:
+ text = text[3:]
+ (output, consumed) = codecs.utf_8_decode(text, "ignore", True)
+ return output
+
fileName = "%s.po" % self.__language
poFile = os.path.join(self.__poDirectory, fileName)
if os.path.isfile(poFile):
try:
f = open(poFile, "rb")
+ fileContent = f.read()
try:
+ u = decodeUtf8Bom(fileContent)
+ fileContent = u.encode("utf-8", "ignore")
+ except:
+ pass
+ try:
msgId = None
msgStr = None
- lines = f.read().split("\n")
+ lines = fileContent.split("\n")
for line in lines:
if line.find("msgid") == 0:
msgId = self.__extractContent(line)
|