translation.py only worked properly on Linux - Fixed.

This commit is contained in:
kjell.kernen@gmail.com
2013-06-19 20:16:39 +00:00
parent e416fa4871
commit 5a157471fd
+69 -68
View File
@@ -5,79 +5,80 @@
import argparse
import os
import os.path
import codecs
translations = {'cz': [('\\200', 'á'),
('\\201', 'č'),
('\\201', 'Č'),
('\\202', 'é'),
('\\203', 'ě'),
('\\204', 'í'),
('\\205', 'ó'),
('\\206', 'ř'),
('\\207', 'š'),
('\\207', 'Š'),
('\\210', 'ú'),
('\\211', 'ů'),
('\\212', 'ý'),
('\\213', 'Á'),
('\\214', 'Í'),
('\\215', 'Ř'),
('\\216', 'Ý'),
('\\217', 'ž'),
('\\217', 'Ž'),
('\\220', 'É')],
translations = {'cz': [('\\200', u'á'),
('\\201', u'č'),
('\\201', u'Č'),
('\\202', u'é'),
('\\203', u'ě'),
('\\204', u'í'),
('\\205', u'ó'),
('\\206', u'ř'),
('\\207', u'š'),
('\\207', u'Š'),
('\\210', u'ú'),
('\\211', u'ů'),
('\\212', u'ý'),
('\\213', u'Á'),
('\\214', u'Í'),
('\\215', u'Ř'),
('\\216', u'Ý'),
('\\217', u'ž'),
('\\217', u'Ž'),
('\\220', u'É')],
'de': [('\\200', 'Ä'),
('\\201', 'ä'),
('\\202', 'Ö'),
('\\203', 'ö'),
('\\204', 'Ü'),
('\\205', 'ü'),
('\\206', 'ß')],
'de': [('\\200', u'Ä'),
('\\201', u'ä'),
('\\202', u'Ö'),
('\\203', u'ö'),
('\\204', u'Ü'),
('\\205', u'ü'),
('\\206', u'ß')],
'es': [('\\200', 'Ñ'),
('\\201', 'ñ')],
'es': [('\\200', u'Ñ'),
('\\201', u'ñ')],
'fr': [('\\200', 'é'),
('\\201', 'è'),
('\\202', 'à'),
('\\203', 'î'),
('\\204', 'ç')],
'fr': [('\\200', u'é'),
('\\201', u'è'),
('\\202', u'à'),
('\\203', u'î'),
('\\204', u'ç')],
'it': [('\\200', 'à'),
('\\201', 'ù')],
'it': [('\\200', u'à'),
('\\201', u'ù')],
'pt': [('\\200', 'Á'),
('\\201', 'á'),
('\\202', 'Â'),
('\\203', 'â'),
('\\204', 'Ã'),
('\\205', 'ã'),
('\\206', 'À'),
('\\207', 'à'),
('\\210', 'Ç'),
('\\211', 'ç'),
('\\212', 'É'),
('\\213', 'é'),
('\\214', 'Ê'),
('\\215', 'ê'),
('\\216', 'Í'),
('\\217', 'í'),
('\\218', 'Ó'),
('\\219', 'ó'),
('\\220', 'Ô'),
('\\221', 'ô'),
('\\222', 'Õ'),
('\\223', 'õ'),
('\\224', 'Ú'),
('\\225', 'ú'),],
'pt': [('\\200', u'Á'),
('\\201', u'á'),
('\\202', u'Â'),
('\\203', u'â'),
('\\204', u'Ã'),
('\\205', u'ã'),
('\\206', u'À'),
('\\207', u'à'),
('\\210', u'Ç'),
('\\211', u'ç'),
('\\212', u'É'),
('\\213', u'é'),
('\\214', u'Ê'),
('\\215', u'ê'),
('\\216', u'Í'),
('\\217', u'í'),
('\\218', u'Ó'),
('\\219', u'ó'),
('\\220', u'Ô'),
('\\221', u'ô'),
('\\222', u'Õ'),
('\\223', u'õ'),
('\\224', u'Ú'),
('\\225', u'ú'),],
'se': [('\\200', 'å'),
('\\201', 'ä'),
('\\202', 'ö'),
('\\203', 'Å'),
('\\204', 'Ä'),
('\\205', 'Ö')],
'se': [('\\200', u'å'),
('\\201', u'ä'),
('\\202', u'ö'),
('\\203', u'Å'),
('\\204', u'Ä'),
('\\205', u'Ö')],
}
# Take care of command line options
@@ -93,7 +94,7 @@ if args.language not in translations:
system.exit()
# Read the input file into a buffer
in_file = open( args.input, 'r')
in_file = codecs.open( args.input, "r", "utf-8" )
text = in_file.read()
in_file.close()
@@ -105,7 +106,7 @@ for before, after in translations[args.language]:
text = text.replace(after, before)
# Write the result to a temporary file
out_file = open( args.output, 'w')
out_file = codecs.open(args.output, 'w', 'utf-8')
out_file.write( text )
out_file.close()