changeset 480:f25985f6b222

Translator: catalogues can be saved to disk now.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Mon, 12 Nov 2007 20:40:41 +0100
parents 044b5393f8bc
children 04adc4e3fdda
files trunk/src/translator/langfile.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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