diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2010-07-12 15:31:50 +0200 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2010-07-12 15:31:50 +0200 |
commit | 85ce1d366eb685c655fc5f7ec2d45fbc05aad722 (patch) | |
tree | 8bc0b4af12e4c7d9b6a91d8c5d648512e874c94b /l10ntools | |
parent | 71d0aa83c9a1330c27b47cc836f4754a007815ae (diff) |
txtl10n: #i113008# add support for xtx files (single text files)
Diffstat (limited to 'l10ntools')
-rw-r--r-- | l10ntools/scripts/l10ntool.py | 4 | ||||
-rw-r--r-- | l10ntools/scripts/sdf.py | 2 | ||||
-rw-r--r-- | l10ntools/scripts/xtxex.py | 29 |
3 files changed, 24 insertions, 11 deletions
diff --git a/l10ntools/scripts/l10ntool.py b/l10ntools/scripts/l10ntool.py index caa15b7efd17..e98a8189e9b7 100644 --- a/l10ntools/scripts/l10ntool.py +++ b/l10ntools/scripts/l10ntool.py @@ -27,7 +27,7 @@ from optparse import OptionParser from sdf import SdfData -import string , sys , os +import sys , os class abstractL10nTool: _options = {} @@ -184,5 +184,5 @@ class abstractL10nTool: def get_filename_string(self, inputfile): absfile = os.path.realpath(os.path.abspath(inputfile)) absroot = os.path.realpath(os.path.abspath(self._options.project_root)) - return absfile[len(absroot):].replace('/','\\') + return absfile[len(absroot)+1:].replace('/','\\') diff --git a/l10ntools/scripts/sdf.py b/l10ntools/scripts/sdf.py index ce1077197622..1d7cc27f0733 100644 --- a/l10ntools/scripts/sdf.py +++ b/l10ntools/scripts/sdf.py @@ -25,8 +25,6 @@ # #************************************************************************* -import string - class MyOrderedDict(dict): _keylist = [] _valuelist = [] diff --git a/l10ntools/scripts/xtxex.py b/l10ntools/scripts/xtxex.py index 98ec1e86b596..a8677b10bf86 100644 --- a/l10ntools/scripts/xtxex.py +++ b/l10ntools/scripts/xtxex.py @@ -36,13 +36,21 @@ class xtxex(abstractL10nTool): def __init__(self): abstractL10nTool.__init__(self) - def merge_file(self, inputfilename, outputfilename, parsed_file_ref, lang,is_forced_lang, sdfdata): - print "merge_file lang " + lang +" file " + outputfilename + def merge_file(self, inputfilename, outputfilename, parsed_file_ref, lang, is_forced_lang, sdfdata): + # Special handling for en-US files + if lang == "en-US": + mod_outputfilename = outputfilename.replace("_en-US",'') + #print "DBG: merge_file lang " + lang +" file " + mod_outputfilename + self.copy_file(inputfilename, mod_outputfilename) + return + + # merge usual lang sdfline = self.prepare_sdf_line(inputfilename,lang) if sdfdata.has_key(sdfline.get_id()): line = sdfdata[sdfline.get_id()].text.replace("\\n", '\n') self.make_dirs(outputfilename) try: + #print "DBG: merge_file lang " + lang +" file " + outputfilename f = open(outputfilename, "w+") f.write(line) except IOError: @@ -51,12 +59,19 @@ class xtxex(abstractL10nTool): else: f.close() return + + # no sdf data found then copy en-US source file if is_forced_lang: - try: - shutil.copy(inputfilename, outputfilename) - except IOError: - print "ERROR: Can not copy file '" + inputfilename + "' to " + "'" + outputfilename + "'" - sys.exit(-1) + #print "DBG: merge_file lang " + lang +" file " + outputfilename + self.copy_file(inputfilename, outputfilename) + + def copy_file(self, inputfilename, outputfilename): + try: + #print "DBG: copy " + inputfilename + " to " + outputfilename + shutil.copy(inputfilename, outputfilename) + except IOError: + print "ERROR: Can not copy file '" + inputfilename + "' to " + "'" + outputfilename + "'" + sys.exit(-1) ##### Extract a single File def extract_file(self, inputfile): |