translation.py only worked properly on Linux - Fixed.
This commit is contained in:
+69
-68
@@ -5,79 +5,80 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import codecs
|
||||||
|
|
||||||
translations = {'cz': [('\\200', 'á'),
|
translations = {'cz': [('\\200', u'á'),
|
||||||
('\\201', 'č'),
|
('\\201', u'č'),
|
||||||
('\\201', 'Č'),
|
('\\201', u'Č'),
|
||||||
('\\202', 'é'),
|
('\\202', u'é'),
|
||||||
('\\203', 'ě'),
|
('\\203', u'ě'),
|
||||||
('\\204', 'í'),
|
('\\204', u'í'),
|
||||||
('\\205', 'ó'),
|
('\\205', u'ó'),
|
||||||
('\\206', 'ř'),
|
('\\206', u'ř'),
|
||||||
('\\207', 'š'),
|
('\\207', u'š'),
|
||||||
('\\207', 'Š'),
|
('\\207', u'Š'),
|
||||||
('\\210', 'ú'),
|
('\\210', u'ú'),
|
||||||
('\\211', 'ů'),
|
('\\211', u'ů'),
|
||||||
('\\212', 'ý'),
|
('\\212', u'ý'),
|
||||||
('\\213', 'Á'),
|
('\\213', u'Á'),
|
||||||
('\\214', 'Í'),
|
('\\214', u'Í'),
|
||||||
('\\215', 'Ř'),
|
('\\215', u'Ř'),
|
||||||
('\\216', 'Ý'),
|
('\\216', u'Ý'),
|
||||||
('\\217', 'ž'),
|
('\\217', u'ž'),
|
||||||
('\\217', 'Ž'),
|
('\\217', u'Ž'),
|
||||||
('\\220', 'É')],
|
('\\220', u'É')],
|
||||||
|
|
||||||
'de': [('\\200', 'Ä'),
|
'de': [('\\200', u'Ä'),
|
||||||
('\\201', 'ä'),
|
('\\201', u'ä'),
|
||||||
('\\202', 'Ö'),
|
('\\202', u'Ö'),
|
||||||
('\\203', 'ö'),
|
('\\203', u'ö'),
|
||||||
('\\204', 'Ü'),
|
('\\204', u'Ü'),
|
||||||
('\\205', 'ü'),
|
('\\205', u'ü'),
|
||||||
('\\206', 'ß')],
|
('\\206', u'ß')],
|
||||||
|
|
||||||
'es': [('\\200', 'Ñ'),
|
'es': [('\\200', u'Ñ'),
|
||||||
('\\201', 'ñ')],
|
('\\201', u'ñ')],
|
||||||
|
|
||||||
'fr': [('\\200', 'é'),
|
'fr': [('\\200', u'é'),
|
||||||
('\\201', 'è'),
|
('\\201', u'è'),
|
||||||
('\\202', 'à'),
|
('\\202', u'à'),
|
||||||
('\\203', 'î'),
|
('\\203', u'î'),
|
||||||
('\\204', 'ç')],
|
('\\204', u'ç')],
|
||||||
|
|
||||||
'it': [('\\200', 'à'),
|
'it': [('\\200', u'à'),
|
||||||
('\\201', 'ù')],
|
('\\201', u'ù')],
|
||||||
|
|
||||||
'pt': [('\\200', 'Á'),
|
'pt': [('\\200', u'Á'),
|
||||||
('\\201', 'á'),
|
('\\201', u'á'),
|
||||||
('\\202', 'Â'),
|
('\\202', u'Â'),
|
||||||
('\\203', 'â'),
|
('\\203', u'â'),
|
||||||
('\\204', 'Ã'),
|
('\\204', u'Ã'),
|
||||||
('\\205', 'ã'),
|
('\\205', u'ã'),
|
||||||
('\\206', 'À'),
|
('\\206', u'À'),
|
||||||
('\\207', 'à'),
|
('\\207', u'à'),
|
||||||
('\\210', 'Ç'),
|
('\\210', u'Ç'),
|
||||||
('\\211', 'ç'),
|
('\\211', u'ç'),
|
||||||
('\\212', 'É'),
|
('\\212', u'É'),
|
||||||
('\\213', 'é'),
|
('\\213', u'é'),
|
||||||
('\\214', 'Ê'),
|
('\\214', u'Ê'),
|
||||||
('\\215', 'ê'),
|
('\\215', u'ê'),
|
||||||
('\\216', 'Í'),
|
('\\216', u'Í'),
|
||||||
('\\217', 'í'),
|
('\\217', u'í'),
|
||||||
('\\218', 'Ó'),
|
('\\218', u'Ó'),
|
||||||
('\\219', 'ó'),
|
('\\219', u'ó'),
|
||||||
('\\220', 'Ô'),
|
('\\220', u'Ô'),
|
||||||
('\\221', 'ô'),
|
('\\221', u'ô'),
|
||||||
('\\222', 'Õ'),
|
('\\222', u'Õ'),
|
||||||
('\\223', 'õ'),
|
('\\223', u'õ'),
|
||||||
('\\224', 'Ú'),
|
('\\224', u'Ú'),
|
||||||
('\\225', 'ú'),],
|
('\\225', u'ú'),],
|
||||||
|
|
||||||
'se': [('\\200', 'å'),
|
'se': [('\\200', u'å'),
|
||||||
('\\201', 'ä'),
|
('\\201', u'ä'),
|
||||||
('\\202', 'ö'),
|
('\\202', u'ö'),
|
||||||
('\\203', 'Å'),
|
('\\203', u'Å'),
|
||||||
('\\204', 'Ä'),
|
('\\204', u'Ä'),
|
||||||
('\\205', 'Ö')],
|
('\\205', u'Ö')],
|
||||||
}
|
}
|
||||||
|
|
||||||
# Take care of command line options
|
# Take care of command line options
|
||||||
@@ -93,7 +94,7 @@ if args.language not in translations:
|
|||||||
system.exit()
|
system.exit()
|
||||||
|
|
||||||
# Read the input file into a buffer
|
# 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()
|
text = in_file.read()
|
||||||
in_file.close()
|
in_file.close()
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ for before, after in translations[args.language]:
|
|||||||
text = text.replace(after, before)
|
text = text.replace(after, before)
|
||||||
|
|
||||||
# Write the result to a temporary file
|
# 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.write( text )
|
||||||
out_file.close()
|
out_file.close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user