# HG changeset patch # User Aziz K?ksal # Date 1194896441 -3600 # Node ID f25985f6b222b7e96e5adc82b313db0a54daec1f # Parent 044b5393f8bcdea9bba3549c2043fbc667e87bcd Translator: catalogues can be saved to disk now. diff -r 044b5393f8bc -r f25985f6b222 trunk/src/translator/langfile.py --- a/trunk/src/translator/langfile.py Mon Nov 12 17:18:30 2007 +0100 +++ b/trunk/src/translator/langfile.py Mon Nov 12 20:40:41 2007 +0100 @@ -4,6 +4,11 @@ import yaml from errors import LoadingError +# Avoid that all unicode strings are tagged with "!!python/unicode". +def unicode_representer(dumper, data): + return dumper.represent_scalar(u'tag:yaml.org,2002:str', data) +yaml.add_representer(unicode, unicode_representer) + def newLangFile(langCode, authors, license): return { "LangCode":langCode, @@ -84,10 +89,9 @@ return {"ID":ID,"Text":"","Annot":"","LastEd":""} def save(self): - #langFile = open(self.filePath, "w") - print "Saved", self.filePath - #print yaml.dump(self.doc, allow_unicode=True) - #langFile.close() + langFile = open(self.filePath, "w") + yaml.dump(self.doc, stream=langFile, allow_unicode=True) + langFile.close() def getFileName(self): from os import path