* implement format function for LocalText
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
# System
|
# System
|
||||||
import xml.dom.minidom as mdom
|
import xml.dom.minidom as mdom
|
||||||
from xml.parsers.expat import ExpatError
|
from xml.parsers.expat import ExpatError
|
||||||
|
import locale
|
||||||
import codecs
|
import codecs
|
||||||
import types
|
import types
|
||||||
|
|
||||||
@@ -99,6 +100,17 @@ class LocalText(object):
|
|||||||
node.appendChild(newnode)
|
node.appendChild(newnode)
|
||||||
|
|
||||||
def format(self, errs):
|
def format(self, errs):
|
||||||
|
L = locale.getlocale()[0][0:2] # try to read language, pathetic isn't it?
|
||||||
|
if self.locs.has_key(L):
|
||||||
|
return self.locs[L]
|
||||||
|
elif self.locs.has_key('en'):
|
||||||
|
# fallback to English, blah
|
||||||
|
return self.locs['en']
|
||||||
|
elif self.locs.has_key('tr'):
|
||||||
|
# fallback to Turkish
|
||||||
|
return self.locs['tr']
|
||||||
|
else:
|
||||||
|
errs.append("Tag '%s' should have at least an English or Turkish version\n" % d[2])
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
# FIXME: use something like the below to return a default
|
# FIXME: use something like the below to return a default
|
||||||
|
|||||||
Reference in New Issue
Block a user