From 04037a57c45893a4bef3f2a6fb40751a96fdac8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Wed, 12 Oct 2005 12:24:10 +0000 Subject: [PATCH] * implement format function for LocalText --- pisi/xmlfile.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pisi/xmlfile.py b/pisi/xmlfile.py index 867268dc..bbc1fd2c 100644 --- a/pisi/xmlfile.py +++ b/pisi/xmlfile.py @@ -34,6 +34,7 @@ # System import xml.dom.minidom as mdom from xml.parsers.expat import ExpatError +import locale import codecs import types @@ -99,7 +100,18 @@ class LocalText(object): node.appendChild(newnode) def format(self, errs): - return '' + 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 '' # FIXME: use something like the below to return a default #L = language