From 068a5d9293e092cbe73d8a707e4f45a623d99ccc Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 7 Jul 2010 15:29:56 +0200 Subject: txtl10n: #i113008# add support for xtx files --- l10ntools/source/localize.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index 6cecb0972cb7..8e2fbee2bc85 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -56,7 +56,7 @@ const char *ExeTable[][5] = { //{ "src", "transex3", "-UTF8 -e", "negative", "noiso" }, //{ "hrc", "transex3", "-UTF8 -e", "positive", "noiso" }, - //{ "lng", "lngex", "-UTF8 -e", "negative", "noiso" }, + { "xtx", "xtxex", "", "negative", "noiso" }, { "ulf", "ulfex", " -e", "negative", "noiso" }, { "xrb", "xmlex", "-UTF8 -e", "negative", "iso" }, { "xxl", "xmlex", "-UTF8 -e", "negative", "iso" }, @@ -326,7 +326,7 @@ void SourceTreeLocalizer::WorkOnFile( } if( bQuiet2 ){ - sCommand +=" -QQ "; + //sCommand +=" -QQ "; } //printf("DBG: %s\n",sCommand.GetBuffer()); if (system(sCommand.GetBuffer()) == -1) -- cgit v1.2.3 From bb7dd792818f8404d6e756505469d17350eebd83 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 7 Jul 2010 15:30:32 +0200 Subject: txtl10n: remove some noisy output / code cleanup --- l10ntools/source/cfglex.l | 16 +--------------- l10ntools/source/cfgmerge.cxx | 6 ++---- l10ntools/source/export.cxx | 1 - l10ntools/source/helpmerge.cxx | 11 ----------- l10ntools/source/lngex.cxx | 10 ---------- l10ntools/source/srclex.l | 6 ------ l10ntools/source/xrmlex.l | 5 ----- l10ntools/source/xrmmerge.cxx | 2 -- 8 files changed, 3 insertions(+), 54 deletions(-) diff --git a/l10ntools/source/cfglex.l b/l10ntools/source/cfglex.l index cc92632620be..d1b076d493b9 100644 --- a/l10ntools/source/cfglex.l +++ b/l10ntools/source/cfglex.l @@ -169,10 +169,6 @@ main( int argc, char* argv[]) FILE *pFile; pOutput = GetOutputFile( argc, argv ); - if( !isQuiet() ){ - fprintf( stdout, "\nCfgEx 0.9 Copyright 2000, 2010 Oracle and/or its affiliates. All Rights Reserved.\n" ); - fprintf( stdout, "===================================================================================\n" ); - } if ( !pOutput ) { fprintf( stdout, "Syntax: CFGEX[-p Prj][-r PrjRoot]-i FileIn [-o FileOut][-m DataBase][-e][-b][-u][-f][-d DoneFile][-g[:dtd] ][-L l1,l2,...]\n" ); @@ -213,20 +209,10 @@ main( int argc, char* argv[]) nRetValue = GetError(); EndCfgExport(); - if( !isQuiet() ){ - fprintf( stdout, "\n===================================\n\n" ); - } removeTempFile(); /* return error level */ return nRetValue; } -/*""]*"-->" { - bText = 0; - WorkOnTokenSet( COMMEND, yytext ); -}*/ -/*" { - bText = 0; - WorkOnTokenSet( CFG_TAG, yytext ); -}*/ + diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx index 170c2922d9ce..3e421d2d1046 100644 --- a/l10ntools/source/cfgmerge.cxx +++ b/l10ntools/source/cfgmerge.cxx @@ -247,7 +247,7 @@ extern FILE *GetCfgFile() if ( !pFile ){ fprintf( stderr, "Error: Could not open file %s\n", sInputFileName.GetBuffer()); - exit( 13 ); + exit( -13 ); } else { // this is a valid file which can be opened, so @@ -264,8 +264,6 @@ extern FILE *GetCfgFile() // printf("sFullEntry = %s\n",sFullEntry.GetBuffer()); sActFileName = sFullEntry.Copy( sPrjEntry.Len() + 1 ); // printf("sActFileName = %s\n",sActFileName.GetBuffer()); - if( !bQuiet ) - fprintf( stdout, "\nProcessing File %s ...\n", sInputFileName.GetBuffer()); sActFileName.SearchAndReplaceAll( "/", "\\" ); @@ -615,7 +613,7 @@ CfgOutputParser::CfgOutputParser( const ByteString &rOutputFile ) Error( sError ); delete pOutputStream; pOutputStream = NULL; - exit( 13 ); + exit( -13 ); } } diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index 59f29525eda4..589c962c112c 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -282,7 +282,6 @@ extern FILE *GetNextFile() // (e.g.: source\ui\src\menue.src) sActFileName = sFullEntry.Copy( sPrjEntry.Len() + 1 ); - if( !bQuiet ) fprintf( stdout, "\nProcessing File %s ...\n", sOrigFile.GetBuffer()); sActFileName.SearchAndReplaceAll( "/", "\\" ); sFile = sActFileName; diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx index 0ab7e6eb5c2e..15cb1e311002 100644 --- a/l10ntools/source/helpmerge.cxx +++ b/l10ntools/source/helpmerge.cxx @@ -181,17 +181,6 @@ bool HelpParser::CreateSDF( ByteString sActFileName = makeAbsolutePath( sHelpFile , rRoot_in ); -/* DirEntry aEntry( String( sHelpFile, RTL_TEXTENCODING_ASCII_US )); - aEntry.ToAbs(); - String sFullEntry = aEntry.GetFull(); - aEntry += DirEntry( String( "..", RTL_TEXTENCODING_ASCII_US )); - aEntry += DirEntry( rRoot_in ); - ByteString sPrjEntry( aEntry.GetFull(), gsl_getSystemTextEncoding()); - ByteString sActFileName( - sFullEntry.Copy( sPrjEntry.Len() + 1 ), gsl_getSystemTextEncoding()); - - sActFileName.SearchAndReplaceAll( "/", "\\" ); -*/ XMLHashMap* aXMLStrHM = file->GetStrings(); LangHashMap* pElem; XMLElement* pXMLElement = NULL; diff --git a/l10ntools/source/lngex.cxx b/l10ntools/source/lngex.cxx index c593b85d4932..27136dc8797f 100644 --- a/l10ntools/source/lngex.cxx +++ b/l10ntools/source/lngex.cxx @@ -170,7 +170,6 @@ BOOL ParseCommandLine( int argc, char* argv[]) void Help() /*****************************************************************************/ { - //fprintf( stdout, "Syntax:ULFEX[-p Prj][-r PrjRoot]-i FileIn -o FileOut[-m DataBase][-e][-b][-u][-NOUTF8][-ULF][-L l1,l2,...]\n" ); fprintf( stdout, "Syntax:ULFEX[-p Prj][-r PrjRoot]-i FileIn -o FileOut[-m DataBase][-L l1,l2,...]\n" ); fprintf( stdout, " Prj: Project\n" ); fprintf( stdout, " PrjRoot: Path to project root (..\\.. etc.)\n" ); @@ -199,15 +198,8 @@ int _cdecl main( int argc, char *argv[] ) Help(); return 1; } - if( !bQuiet ){ - fprintf( stdout, "\nUlfEx 1 Copyright 2000, 2010 Oracle and/or its affiliates. All Rights Reserved.\n" ); - fprintf( stdout, "=================================================================================\n" ); - fprintf( stdout, "\nProcessing File %s ...\n", sInputFile.GetBuffer()); - }else - { fprintf(stdout, "."); fflush( stdout ); - } if ( sOutputFile.Len()) { LngParser aParser( sInputFile, bUTF8, bULF , bQuiet ); @@ -217,7 +209,5 @@ int _cdecl main( int argc, char *argv[] ) aParser.CreateSDF( sOutputFile, sPrj, sPrjRoot ); } - if( !bQuiet ) fprintf( stdout, "\n=================================================\n\n" ); - return 0; } diff --git a/l10ntools/source/srclex.l b/l10ntools/source/srclex.l index 473da8b5d511..eb2b6af78b34 100644 --- a/l10ntools/source/srclex.l +++ b/l10ntools/source/srclex.l @@ -259,10 +259,6 @@ main( int argc, char* argv[]) FILE *pFile; pOutput = GetOutputFile( argc, argv ); - if( !isQuiet() ){ - fprintf( stdout, "\nTransEx 3.1 Copyright 2000, 2010 Oracle and/or its affiliates. All Rights Reserved.\n" ); - fprintf( stdout, "=====================================================================================\n" ); - } if ( !pOutput ) { fprintf( stdout, "Syntax:TRANSEX[-p Prj][-r PrjRoot]-i FileIn...[-o FileOut][-m DataBase][-e][-b][-u][-L l1,l2,...]\n" ); @@ -301,8 +297,6 @@ main( int argc, char* argv[]) nRetValue = GetError(); EndExport(); - if( !isQuiet() ) fprintf( stdout, "\n===================================\n\n" ); - /* return error level */ return nRetValue; } diff --git a/l10ntools/source/xrmlex.l b/l10ntools/source/xrmlex.l index 4770a851c741..6229525d7e84 100644 --- a/l10ntools/source/xrmlex.l +++ b/l10ntools/source/xrmlex.l @@ -180,10 +180,6 @@ main( int argc, char* argv[]) FILE *pFile; pOutput = GetOutputFile( argc, argv ); - if( !isQuiet() ){ - fprintf( stdout, "\nXrmEx 0.9 Copyright 2000, 2010 Oracle and/or its affiliates. All Rights Reserved.\n" ); - fprintf( stdout, "===================================================================================\n" ); - } if ( !pOutput ) { fprintf( stdout, "Syntax: XRMEX[-p Prj][-r PrjRoot]-i FileIn [-o FileOut][-m DataBase][-e][-b][-u][-NOUTF8][-L l1,l2,...]\n" ); @@ -222,7 +218,6 @@ main( int argc, char* argv[]) nRetValue = GetError(); EndXrmExport(); - if( !isQuiet() ) fprintf( stdout, "\n===================================\n\n" ); removeTempFile(); /* return error level */ return nRetValue; diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx index b77f75ea04e5..dc3d2fe6a283 100644 --- a/l10ntools/source/xrmmerge.cxx +++ b/l10ntools/source/xrmmerge.cxx @@ -252,8 +252,6 @@ extern FILE *GetXrmFile() // (e.g.: source\ui\src\menue.src) sActFileName = sFullEntry.Copy( sPrjEntry.Len() + 1 ); - if( !bQuiet ) - fprintf( stdout, "\nProcessing File %s ...\n", sInputFileName.GetBuffer()); sActFileName.SearchAndReplaceAll( "/", "\\" ); -- cgit v1.2.3 From fb9f27fc9881ad5670bfe4d9f96438bf2322b24d Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 7 Jul 2010 15:35:17 +0200 Subject: l10ntxt: #i113008# add support for xtx files (single text files) --- l10ntools/scripts/const.py | 39 +++++++ l10ntools/scripts/l10ntool.py | 188 +++++++++++++++++++++++++++++++++ l10ntools/scripts/sdf.py | 240 ++++++++++++++++++++++++++++++++++++++++++ l10ntools/scripts/xtxex | 47 +++++++++ l10ntools/scripts/xtxex.py | 92 ++++++++++++++++ 5 files changed, 606 insertions(+) create mode 100644 l10ntools/scripts/const.py create mode 100644 l10ntools/scripts/l10ntool.py create mode 100644 l10ntools/scripts/sdf.py create mode 100755 l10ntools/scripts/xtxex create mode 100644 l10ntools/scripts/xtxex.py diff --git a/l10ntools/scripts/const.py b/l10ntools/scripts/const.py new file mode 100644 index 000000000000..2d514eabdab6 --- /dev/null +++ b/l10ntools/scripts/const.py @@ -0,0 +1,39 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +# Pseudo const +class _const: + class ConstError(TypeError): pass + def __setattr__(self, name, value): + if self.__dict__.has_key(name): + raise self.ConstError, "Can't rebind const(%s)"%name + self.__dict__[name] = value + +import sys +sys.modules[__name__] = _const() + + diff --git a/l10ntools/scripts/l10ntool.py b/l10ntools/scripts/l10ntool.py new file mode 100644 index 000000000000..caa15b7efd17 --- /dev/null +++ b/l10ntools/scripts/l10ntool.py @@ -0,0 +1,188 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +from optparse import OptionParser +from sdf import SdfData +import string , sys , os + +class abstractL10nTool: + _options = {} + _args = "" + _resource_type = "" + _source_language = "en-US" + + ##### Implement these abstract methods + + ##### Nameing scheme for the output files + def get_outputfile_format_str(self): + # filename,fileNoExt,language,extension,pathPrefix,pathPostFix,path + return "{path}/{fileNoExt}_{language}.{extension}" + + ################################# Merge single files ########################################### + + ##### Merge a single file + def merge_file(self, inputfilename, outputfilename, parsed_file_ref, lang, is_forced_lang, sdfdata): + pass + + ##### Helper for parse-once-use-often like parsing a xml file is needed implement it here + def parse_file(self, filename): + return None + + ################### Merge one big file containing all strings in all languages ################# + def merge_one_big_file(self, inputfile, outputfilename, parsed_file_ref, lang, sdfdata): + pass + + ################### Extract a single File ###################################################### + def extract_file(self, inputfile): + pass + + ################################################################################################ + + def format_outputfile(self, filename, language): + extension = filename[filename.rfind('.')+1:] + file = filename[:filename.rfind('.')] + return self.get_outputfile_format_str().format( + filename=filename, fileNoExt=file, language=language, extension=extension, path_prefix=self._options.path_prefix, + path_postfix=self._options.path_postfix, path=self.get_path()) + + def get_path(self): + if self._options.outputfile.find('/') == -1: + return "" + else: + return self._options.outputfile[:self._options.outputfile.rfind('/')] + + def merge(self, sdfdata): + langset,forcedset, foundset = set(), set() , set() + + if self._options.languages: langset = set(self._options.languages) + if self._options.forcedlanguages: forcedset = set(self._options.forcedlanguages) + if sdfdata.get_languages_found_in_sdf(): foundset = sdfdata.get_languages_found_in_sdf() + + if self.has_multi_inputfiles(): + filelist = self.read_inputfile_list() + else: + filelist = self._options.inputfile + + for inputfile in filelist: + ref = self.parse_file(inputfile) + # Don't write that files if there is no l10n present + if ((langset & foundset) - forcedset): # all langs given and found in sdf without enforced + [self.merge_file(inputfile,self.format_outputfile(inputfile, lang), ref, lang, False, sdfdata) for lang in ((langset & foundset) - forcedset)] + # Always write those files even if there is no l10n available + if forcedset: # all enforced langs + [self.merge_file(inputfile, self.format_outputfile(inputfile, lang), ref, lang, True, sdfdata) for lang in forcedset] + # In case a big file have to be written + if ((langset & foundset) | forcedset): # all langs given ,found in sdf and enforced ones + self.merge_one_big_file(inputfile, self.format_outputfile(inputfile, lang), ref, ((langset & foundset) | forcedset), sdfdata) + + def has_multi_inputfiles(self): + return self._options.inputfile[0] == '@' + + def extract(self): + try: + f = open(self._options.outputfile, "w+") + f.write(self.extract_file(self._options.inputfile)) + except IOError: + print "ERROR: Can not write file " + self._options.outputfile + else: + f.close() + + # Parse the common options + def parse_options(self): + parser = OptionParser() + parser.add_option("-i", "--inputfile", dest="inputfile", metavar="FILE", help="resource file to read" ) + parser.add_option("-o", "--outputfile", dest="outputfile", metavar="FILE", help="extracted sdf or merged file" ) + parser.add_option("-m", "--inputsdffile", dest="input_sdf_file", metavar="FILE", help="merge this sdf file" ) + parser.add_option("-x", "--pathprefix", dest="path_prefix", metavar="PATH", help="" ) + parser.add_option("-y", "--pathpostfix", dest="path_postfix", metavar="PATH", help="" ) + parser.add_option("-p", "--projectname", dest="project_name", metavar="NAME", help="" ) + parser.add_option("-r", "--projectroot", dest="project_root", metavar="PATH", help="" ) + parser.add_option("-f", "--forcedlanguages", dest="forcedlanguages", metavar="ISOCODE[,ISOCODE]", help="Always merge those langs even if no l10n is available for those langs" ) + parser.add_option("-l", "--languages", dest="languages", metavar="ISOCODE[,ISOCODE]", help="Merge those langs if l10n is found for each") + parser.add_option("-q", "--quiet", action="store_true", dest="quietmode", help="",default=False) + (self._options, self.args) = parser.parse_args() + + # -l "de,pr,pt-BR" => [ "de" , "pt" , "pt-BR" ] + parse_complex_arg = lambda arg: arg.split(",") + if self._options.forcedlanguages: self._options.forcedlanguages = parse_complex_arg(self._options.forcedlanguages) + if self._options.languages: self._options.languages = parse_complex_arg(self._options.languages) + self.test_options() + + def __init__(self): + self.parse_options() + if self._options.input_sdf_file != None and len(self._options.input_sdf_file): + sdfdata = SdfData(self._options.input_sdf_file) + sdfdata.read() + self.merge(sdfdata) + else: + self.extract() + + def make_dirs(self, filename): + dir = filename[:filename.rfind('/')] + if os.path.exists(dir): + if os.path.isfile(dir): + print "ERROR: There is a file '"+dir+"' where I want create a directory" + sys.exit(-1) + else: + return + else: + try: + print "DBG: make_dir " + str(dir) + os.makedirs(dir) + except IOError: + print "Error: Can not create dir " + dir + sys.exit(-1) + + def test_options(self): + opt = self._options + is_valid = lambda x: x != None and len(x) > 0 + return is_valid(opt.project_root) and is_valid(opt.project_name) and is_valid(opt.languages) and \ + ( is_valid(opt.inputfile) and (( is_valid(opt.path_prefix) and is_valid(opt.path_postfix) ) or is_valid(opt.outputfile)) and \ + ( ( is_valid(opt.input_sdf_file) and ( is_valid(opt.outputfile) or ( is_valid(opt.path_prefix) and is_valid(opt.path_postfix) ) or \ + ( is_valid(opt.inputfile) and is_valid(opt.outputFile)) )))) + print "Strange options ..." + sys.exit( -1 ) + + + def read_inputfile_list(self): + if self.has_multi_inputfiles(): + lines = [] + try: + f = open(self._options.inputfile[1:], "r") + lines = [line.strip('\n') for line in f.readlines()] + except IOError: + print "ERROR: Can not read file list " + self._options.inputfile[2:] + sys.exit(-1) + else: + f.close() + return lines + + 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('/','\\') + diff --git a/l10ntools/scripts/sdf.py b/l10ntools/scripts/sdf.py new file mode 100644 index 000000000000..ce1077197622 --- /dev/null +++ b/l10ntools/scripts/sdf.py @@ -0,0 +1,240 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +import string + +class MyOrderedDict(dict): + _keylist = [] + _valuelist = [] + + #correct?!? + def __init__(self, defaults={}): + dict.__init__(self) + for n,v in defaults.items(): + self[n] = v + #def __getitem__(self): + # pass + + def __setitem__(self, key, value): + self._keylist.append(key) + self._valuelist.append(value) + return dict.__setitem__(self, key, value) + + def __delattr__(self, key): + self._keylist.__delattr__(key) + self._valuelist.__delattr__(dict[key]) + return dict.__delattr__(self, key) + + def __delitem__(self, key): + self._keylist.__delitem__(key) + self._valuelist.__delitem__(dict[key]) + return dict.__delitem__(self, key) + + def __iter(self): + return zip(self._keylist, self._valuelist) + + def __iterkeys__(self): + return self._keylist + + def __iteritems__(self): + return self._valuelist + + def items(self): + return zip(self._keylist,self._valuelist) + + def keys(self): + return self._keylist + + def __keysattr__(self): + return self._keylist + + def pop(self, key): + self._keylist.pop(key) + self._valuelist.pop(key) + return dict.__pop__(self, key) + + def popitem(self): + raise NotImplementedError("popitem") + + def clear(self): + self._keylist.clear() + self._valuelist.clear() + return dict.clear() + + def copy(self): + # correct?!? + newobj = MyOrderedDict(self) + newobj._keylist = self._keylist + newobj._valuelist = self._valuelist + return newobj + +class SdfData: + _filename = ""; + _dict = MyOrderedDict() + #_dict = {} + _languages_found = []; + + def __init__ (self, filename=""): + self._filename = filename + + def __getitem__(self, key): + if self._dict.has_key(key): + return self._dict[key] + else: + return None + + def has_key(self, key): + return self._dict.has_key(key) + + def __setitem__(self, key, value): + self._dict[key] = value + + def get_languages_found_in_sdf(self): + return set(self._languages_found) + + def read(self): + try: + f = open(self._filename, "r") + lines = [line.rstrip('\n') for line in f.readlines()] + except IOError: + print "ERROR: Trying to read "+ self._filename + raise + else: + f.close() + for line in lines: + entity = SdfEntity() + entity.set_properties(line) + self._dict[entity.get_id()] = entity + self._languages_found.append(entity.langid) + + def write(self, filename): + try: + f = open(filename, "w+") + for value in self._dict.itervalues(): + #f.write( repr(value)+"\n" ) + f.write(value + "\n") + except IOError: + print "ERROR: Trying to write " + filename + raise + else: + f.close() + + + +import sys +class SdfEntity: + # Sdf format columns + project = "" + source_file = "" + dummy1 = "" + resource_type = "" + gid = "" + lid = "" + helpid = "" + platform = "" + dummy2 = "" + langid = "" + text = "" + helptext = "" + quickhelptext = "" + title = "" + date = "" + + import const + const._PROJECT_POS = 0 + const._SOURCE_FILE_POS = 1 + const._DUMMY1_POS = 2 + const._RESOURCE_TYPE_POS = 3 + const._GID_POS = 4 + const._LID_POS = 5 + const._HELPID_POS = 6 + const._PLATFORM_POS = 7 + const._DUMMY2_POS = 8 + const._LANGID_POS = 9 + const._TEXT_POS = 10 + const._HELPTEXT_POS = 11 + const._QUICKHELPTEXT_POS = 12 + const._TITLE_POS = 13 + const._DATE_POS = 14 + + + + def __init__(self, project="", source_file="", dummy1="", resource_type="", gid="", lid="", helpid="", platform="", dummy2="", langid="", + text="", helptext="", quickhelptext="", title="", date="2002-02-02 02:02:02"): + self.project = project; + self.source_file = source_file; + self.dummy1 = dummy1; + self.resource_type = resource_type; + self.gid = gid; + self.lid = lid; + self.helpid = helpid; + self.platform = platform; + self.dummy2 = dummy2; + self.langid = langid; + self.text = text; + self.helptext = helptext; + self.quickhelptext = quickhelptext; + self.title = title; + self.date = date; + + def set_properties(self, line): + splitted = line.split("\t") + if len(splitted) == 15: + self.project = splitted[ self.const._PROJECT_POS ] + self.source_file = splitted[ self.const._SOURCE_FILE_POS ] + self.dummy1 = splitted[ self.const._DUMMY1_POS ] + self.resource_type = splitted[ self.const._RESOURCE_TYPE_POS ] + self.gid = splitted[ self.const._GID_POS ] + self.lid = splitted[ self.const._LID_POS ] + self.helpid = splitted[ self.const._HELPID_POS ] + self.platform = splitted[ self.const._PLATFORM_POS ] + self.dummy2 = splitted[ self.const._DUMMY2_POS ] + self.langid = splitted[ self.const._LANGID_POS ] + self.text = splitted[ self.const._TEXT_POS ] + self.helptext = splitted[ self.const._HELPTEXT_POS ] + self.quickhelptext = splitted[ self.const._QUICKHELPTEXT_POS ] + self.title = splitted[ self.const._TITLE_POS ] + self.date = splitted[ self.const._DATE_POS ] + #else: + # print "Offending line '"+line+"'" + # print "ERROR: Something is broken here! Line has {0} tabs".format( len(splitted) ) + # sys.exit( -1 ) + + def get_file_id(self): + return self.project + "\\" + self.source_file + + def get_resource_path(self): + return self.source_file[0:self.source_file.rfind( "\\" )-1] + + #def __repr__(self): + def __str__(self): + return ''.join([self.project, "\t", self.source_file, "\t", self.dummy1, "\t", self.resource_type, "\t" , + self.gid, "\t", self.lid, "\t", self.helpid, "\t", self.platform, "\t", self.dummy2, "\t" , self.langid, + "\t", self.text, "\t", self.helptext, "\t", self.quickhelptext, "\t" , self.title, "\t", self.date ]) + + def get_id(self): + return ''.join([self.project, self.gid, self.lid, self.source_file, self.resource_type, self.platform, self.helpid, self.langid]) diff --git a/l10ntools/scripts/xtxex b/l10ntools/scripts/xtxex new file mode 100755 index 000000000000..cc9dac01fca2 --- /dev/null +++ b/l10ntools/scripts/xtxex @@ -0,0 +1,47 @@ +#!/bin/sh +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +if [ x${SOLARENV}x = xx ]; then + echo No environment found, please use 'setsolar' +exit 1 +fi + +# localize.pl calls localize_sl in solver bin directory which depends on dynamic +# libraries in solver lib directory but has no correct RPATH (or equivalent): +if [ "${OS?}" = MACOSX ]; then + export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH+${DYLD_LIBRARY_PATH}:}${SOLARVERSION?}/${INPATH?}/lib${UPDMINOREXT} +else + export LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${SOLARVERSION?}/${INPATH?}/lib${UPDMINOREXT} +fi + +if [ x${SOLARVER}x = xx -o x${UPDMINOREXT}x = xx ]; then + exec python $SOLARVERSION/$INPATH/bin/xtxex.py "$@" +else + exec python $SOLARVERSION/$INPATH/bin$UPDMINOREXT/xtxex.py "$@" +fi + diff --git a/l10ntools/scripts/xtxex.py b/l10ntools/scripts/xtxex.py new file mode 100644 index 000000000000..98ec1e86b596 --- /dev/null +++ b/l10ntools/scripts/xtxex.py @@ -0,0 +1,92 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +from l10ntool import abstractL10nTool +from sdf import SdfEntity +import sys +import shutil + +class xtxex(abstractL10nTool): + _resourceType = "xtx" + + 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 + 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: + f = open(outputfilename, "w+") + f.write(line) + except IOError: + print "ERROR: Can not write file " + outputfilename + sys.exit(-1) + else: + f.close() + return + if is_forced_lang: + try: + 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): + lines = [] + try: + f = open(inputfile, "r") + lines = f.readlines() + except IOError: + print "ERROR: Can not open file " + inputfile + sys.exit(-1) + else: + f.close() + # remove legal header + lines = [line for line in lines if len(line) > 0 and not line[0] == '#'] + # escape all returns + lines = [line.replace('\n', "\\n") for line in lines] + line = ''.join(lines) + sdf_entity = self.prepare_sdf_line(inputfile); + sdf_entity.text = line + return str(sdf_entity) + + ##### Nameing scheme for the output files + def get_outputfile_format_str(self): + # filename,fileNoExt,language,extension,pathPrefix,pathPostFix,path + return "{path}/{fileNoExt}_{language}.{extension}" + + def prepare_sdf_line(self, inputfile="", lang=""): + if lang == "": + lang = self._source_language + return SdfEntity(project=self._options.project_name, source_file=self.get_filename_string(inputfile), + resource_type=self._resource_type, gid="none", lid="none", langid=lang,text="") + +run = xtxex() -- cgit v1.2.3 From 71d0aa83c9a1330c27b47cc836f4754a007815ae Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 7 Jul 2010 15:36:02 +0200 Subject: l10ntxt: #i113008# add support for xtx files (single text files) --- l10ntools/prj/d.lst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/l10ntools/prj/d.lst b/l10ntools/prj/d.lst index 0b6a43444613..e20114a1ed0d 100644 --- a/l10ntools/prj/d.lst +++ b/l10ntools/prj/d.lst @@ -47,6 +47,11 @@ mkdir: %_DEST%\bin%_EXT%\help\com\sun\star\help ..\scripts\localize %_DEST%\bin%_EXT%\localize ..\scripts\fast_merge.pl %_DEST%\bin%_EXT%\fast_merge.pl ..\scripts\keyidGen.pl %_DEST%\bin%_EXT%\keyidGen.pl +..\scripts\const.py %_DEST%\bin%_EXT%\const.py +..\scripts\l10ntool.py %_DEST%\bin%_EXT%\l10ntool.py +..\scripts\xtxex.py %_DEST%\bin%_EXT%\xtxex.py +..\scripts\sdf.py %_DEST%\bin%_EXT%\sdf.py +..\scripts\xtxex %_DEST%\bin%_EXT%\xtxex ..\inc\export.hxx %_DEST%\inc%_EXT%\l10ntools\export.hxx ..\inc\l10ntools\directory.hxx %_DEST%\inc%_EXT%\l10ntools\directory.hxx -- cgit v1.2.3 From 85ce1d366eb685c655fc5f7ec2d45fbc05aad722 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Mon, 12 Jul 2010 15:31:50 +0200 Subject: txtl10n: #i113008# add support for xtx files (single text files) --- l10ntools/scripts/l10ntool.py | 4 ++-- l10ntools/scripts/sdf.py | 2 -- 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): -- cgit v1.2.3 From cd9c760cfb830cdc991ae5d2c8bee15a6166f496 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Tue, 13 Jul 2010 17:42:44 +0200 Subject: txtl10n: #113125# Support of help tree files in the L10N process --- l10ntools/source/localize.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index 8e2fbee2bc85..420fa3a8d484 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -53,9 +53,7 @@ namespace transex3 const char *ExeTable[][5] = { { "src", "transex3", " -UTF8 -e", "negative", "noiso" }, { "hrc", "transex3", " -UTF8 -e", "positive", "noiso" }, - //{ "src", "transex3", "-UTF8 -e", "negative", "noiso" }, - //{ "hrc", "transex3", "-UTF8 -e", "positive", "noiso" }, - + { "xht", "xhtex", "", "negative", "noiso" }, { "xtx", "xtxex", "", "negative", "noiso" }, { "ulf", "ulfex", " -e", "negative", "noiso" }, { "xrb", "xmlex", "-UTF8 -e", "negative", "iso" }, -- cgit v1.2.3 From 17022b70d98093f0d33e119f6c59725c66674561 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Tue, 13 Jul 2010 17:56:32 +0200 Subject: txtl10n: #i113008# #i113125# Support of help tree files and single txt files in the L10N process --- l10ntools/prj/d.lst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/l10ntools/prj/d.lst b/l10ntools/prj/d.lst index e20114a1ed0d..9594dc416c8e 100644 --- a/l10ntools/prj/d.lst +++ b/l10ntools/prj/d.lst @@ -47,11 +47,13 @@ mkdir: %_DEST%\bin%_EXT%\help\com\sun\star\help ..\scripts\localize %_DEST%\bin%_EXT%\localize ..\scripts\fast_merge.pl %_DEST%\bin%_EXT%\fast_merge.pl ..\scripts\keyidGen.pl %_DEST%\bin%_EXT%\keyidGen.pl -..\scripts\const.py %_DEST%\bin%_EXT%\const.py -..\scripts\l10ntool.py %_DEST%\bin%_EXT%\l10ntool.py -..\scripts\xtxex.py %_DEST%\bin%_EXT%\xtxex.py -..\scripts\sdf.py %_DEST%\bin%_EXT%\sdf.py +..\scripts\tool\const.py %_DEST%\bin%_EXT%\const.py +..\scripts\tool\l10ntool.py %_DEST%\bin%_EXT%\l10ntool.py +..\scripts\tool\xtxex.py %_DEST%\bin%_EXT%\xtxex.py +..\scripts\tool\sdf.py %_DEST%\bin%_EXT%\sdf.py +..\scripts\tool\xhtex.py %_DEST%\bin%_EXT%\xhtex.py ..\scripts\xtxex %_DEST%\bin%_EXT%\xtxex +..\scripts\xhtex %_DEST%\bin%_EXT%\xhtex ..\inc\export.hxx %_DEST%\inc%_EXT%\l10ntools\export.hxx ..\inc\l10ntools\directory.hxx %_DEST%\inc%_EXT%\l10ntools\directory.hxx -- cgit v1.2.3 From a25f2a7a55a7611b75dc6721fa52426c466d4be0 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Tue, 13 Jul 2010 17:58:25 +0200 Subject: txtl10n: #i113008# #i113125# Support of help tree files and single txt files in the L10N process --- l10ntools/scripts/tool/const.py | 39 +++++++ l10ntools/scripts/tool/l10ntool.py | 204 +++++++++++++++++++++++++++++++++ l10ntools/scripts/tool/sdf.py | 224 +++++++++++++++++++++++++++++++++++++ l10ntools/scripts/tool/xhtex.py | 133 ++++++++++++++++++++++ l10ntools/scripts/tool/xtxex.py | 89 +++++++++++++++ 5 files changed, 689 insertions(+) create mode 100644 l10ntools/scripts/tool/const.py create mode 100644 l10ntools/scripts/tool/l10ntool.py create mode 100644 l10ntools/scripts/tool/sdf.py create mode 100644 l10ntools/scripts/tool/xhtex.py create mode 100644 l10ntools/scripts/tool/xtxex.py diff --git a/l10ntools/scripts/tool/const.py b/l10ntools/scripts/tool/const.py new file mode 100644 index 000000000000..2d514eabdab6 --- /dev/null +++ b/l10ntools/scripts/tool/const.py @@ -0,0 +1,39 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +# Pseudo const +class _const: + class ConstError(TypeError): pass + def __setattr__(self, name, value): + if self.__dict__.has_key(name): + raise self.ConstError, "Can't rebind const(%s)"%name + self.__dict__[name] = value + +import sys +sys.modules[__name__] = _const() + + diff --git a/l10ntools/scripts/tool/l10ntool.py b/l10ntools/scripts/tool/l10ntool.py new file mode 100644 index 000000000000..66afc309a1fb --- /dev/null +++ b/l10ntools/scripts/tool/l10ntool.py @@ -0,0 +1,204 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +from optparse import OptionParser +from sdf import SdfData +import sys +import os +import shutil + +class abstractL10nTool: + _options = {} + _args = "" + _resource_type = "" + _source_language = "en-US" + + ##### Implement these abstract methods + + ##### Nameing scheme for the output files + def get_outputfile_format_str(self): + # filename,fileNoExt,language,extension,pathPrefix,pathPostFix,path + #return "{path}/{fileNoExt}_{language}.{extension}" + return self._options.pattern + + ################################# Merge single files ########################################### + + ##### Merge a single file + def merge_file(self, inputfilename, outputfilename, parsed_file_ref, lang, is_forced_lang, sdfdata): + pass + + ##### Helper for parse-once-use-often like parsing a xml file is needed implement it here + def parse_file(self, filename): + return None + + ################### Merge one big file containing all strings in all languages ################# + def merge_one_big_file(self, inputfile, outputfilename, parsed_file_ref, lang, sdfdata): + pass + + ################### Extract a single File ###################################################### + def extract_file(self, inputfile): + pass + + ################################################################################################ + + def format_outputfile(self, filename, language): + extension = filename[filename.rfind('.')+1:] + file = filename[:filename.rfind('.')] + return self.get_outputfile_format_str().replace('[', '{').replace(']','}').format( + filename=filename, fileNoExt=file, language=language, extension=extension, path_prefix=self._options.path_prefix, + path_postfix=self._options.path_postfix, path=self.get_path()) + + def get_path(self): + if self._options.outputfile.find('/') == -1: + return "" + else: + return self._options.outputfile[:self._options.outputfile.rfind('/')] + + def merge(self, sdfdata): + langset,forcedset, foundset = set(), set() , set() + + if self._options.languages: + langset = set(self._options.languages) + if self._options.forcedlanguages: + forcedset = set(self._options.forcedlanguages) + if sdfdata.get_languages_found_in_sdf(): + foundset = sdfdata.get_languages_found_in_sdf() + + if self.has_multi_inputfiles(): + filelist = self.read_inputfile_list() + else: + filelist = self._options.inputfile + + for inputfile in filelist: + ref = self.parse_file(inputfile) + # Don't write that files if there is no l10n present + if ((langset & foundset) - forcedset): # all langs given and found in sdf without enforced + [self.merge_file(inputfile,self.format_outputfile(inputfile, lang), ref, lang, False, sdfdata) for lang in ((langset & foundset) - forcedset)] + # Always write those files even if there is no l10n available + if forcedset: # all enforced langs + [self.merge_file(inputfile, self.format_outputfile(inputfile, lang), ref, lang, True, sdfdata) for lang in forcedset] + # In case a big file have to be written + if ((langset & foundset) | forcedset): # all langs given ,found in sdf and enforced ones + self.merge_one_big_file(inputfile, self.format_outputfile(inputfile, lang), ref, ((langset & foundset) | forcedset), sdfdata) + + def has_multi_inputfiles(self): + return self._options.inputfile[0] == '@' + + def copy_file(self, inputfilename, outputfilename): + try: + shutil.copy(inputfilename, outputfilename) + except IOError: + print "ERROR: Can not copy file '" + inputfilename + "' to " + "'" + outputfilename + "'" + sys.exit(-1) + + def extract(self): + try: + f = open(self._options.outputfile, "w+") + f.write(self.extract_file(self._options.inputfile)) + except IOError: + print "ERROR: Can not write file " + self._options.outputfile + else: + f.close() + + # Parse the common options + def parse_options(self): + parser = OptionParser() + parser.add_option("-i", "--inputfile", dest="inputfile", metavar="FILE", help="resource file to read" ) + parser.add_option("-o", "--outputfile", dest="outputfile", metavar="FILE", help="extracted sdf or merged file" ) + parser.add_option("-m", "--inputsdffile", dest="input_sdf_file", metavar="FILE", help="merge this sdf file" ) + parser.add_option("-x", "--pathprefix", dest="path_prefix", metavar="PATH", help="" ) + parser.add_option("-y", "--pathpostfix", dest="path_postfix", metavar="PATH", help="" ) + parser.add_option("-p", "--projectname", dest="project_name", metavar="NAME", help="" ) + parser.add_option("-r", "--projectroot", dest="project_root", metavar="PATH", help="" ) + parser.add_option("-f", "--forcedlanguages", dest="forcedlanguages", metavar="ISOCODE[,ISOCODE]", help="Always merge those langs even if no l10n is available for those langs" ) + parser.add_option("-l", "--languages", dest="languages", metavar="ISOCODE[,ISOCODE]", help="Merge those langs if l10n is found for each") + parser.add_option("-s", "--pattern", dest="pattern", metavar="", help="" ) + parser.add_option("-q", "--quiet", action="store_true", dest="quietmode", help="",default=False) + (self._options, self.args) = parser.parse_args() + + # -l "de,pr,pt-BR" => [ "de" , "pt" , "pt-BR" ] + parse_complex_arg = lambda arg: arg.split(",") + + if self._options.forcedlanguages: + self._options.forcedlanguages = parse_complex_arg(self._options.forcedlanguages) + if self._options.languages: + self._options.languages = parse_complex_arg(self._options.languages) + self.test_options() + + def __init__(self): + self.parse_options() + if self._options.input_sdf_file != None and len(self._options.input_sdf_file): + sdfdata = SdfData(self._options.input_sdf_file) + sdfdata.read() + self.merge(sdfdata) + else: + self.extract() + + def make_dirs(self, filename): + dir = filename[:filename.rfind('/')] + if os.path.exists(dir): + if os.path.isfile(dir): + print "ERROR: There is a file '"+dir+"' where I want create a directory" + sys.exit(-1) + else: + return + else: + try: + print "DBG: make_dir " + str(dir) + os.makedirs(dir) + except IOError: + print "Error: Can not create dir " + dir + sys.exit(-1) + + def test_options(self): + opt = self._options + is_valid = lambda x: x != None and len(x) > 0 + return is_valid(opt.project_root) and is_valid(opt.project_name) and is_valid(opt.languages) and \ + ( is_valid(opt.inputfile) and (( is_valid(opt.path_prefix) and is_valid(opt.path_postfix) ) or is_valid(opt.outputfile)) and \ + ( ( is_valid(opt.input_sdf_file) and ( is_valid(opt.outputfile) or ( is_valid(opt.path_prefix) and is_valid(opt.path_postfix) ) or \ + ( is_valid(opt.inputfile) and is_valid(opt.outputFile)) )))) + print "Strange options ..." + sys.exit( -1 ) + + def read_inputfile_list(self): + if self.has_multi_inputfiles(): + lines = [] + try: + f = open(self._options.inputfile[1:], "r") + lines = [line.strip('\n') for line in f.readlines()] + except IOError: + print "ERROR: Can not read file list " + self._options.inputfile[2:] + sys.exit(-1) + else: + f.close() + return lines + + 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)+1:].replace('/','\\') + diff --git a/l10ntools/scripts/tool/sdf.py b/l10ntools/scripts/tool/sdf.py new file mode 100644 index 000000000000..33bf90b4ea68 --- /dev/null +++ b/l10ntools/scripts/tool/sdf.py @@ -0,0 +1,224 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +class MyOrderedDict(dict): + _keylist = [] + _valuelist = [] + + def __init__(self, defaults={}): + dict.__init__(self) + for n,v in defaults.items(): + self[n] = v + + def __setitem__(self, key, value): + self._keylist.append(key) + self._valuelist.append(value) + return dict.__setitem__(self, key, value) + + def __delattr__(self, key): + self._keylist.__delattr__(key) + self._valuelist.__delattr__(dict[key]) + return dict.__delattr__(self, key) + + def __delitem__(self, key): + self._keylist.__delitem__(key) + self._valuelist.__delitem__(dict[key]) + return dict.__delitem__(self, key) + + def __iter(self): + return zip(self._keylist, self._valuelist) + + def __iterkeys__(self): + return self._keylist + + def __iteritems__(self): + return self._valuelist + + def items(self): + return zip(self._keylist,self._valuelist) + + def keys(self): + return self._keylist + + def __keysattr__(self): + return self._keylist + + def pop(self, key): + self._keylist.pop(key) + self._valuelist.pop(key) + return dict.__pop__(self, key) + + def popitem(self): + raise NotImplementedError("popitem") + + def clear(self): + self._keylist.clear() + self._valuelist.clear() + return dict.clear() + + def copy(self): + newobj = MyOrderedDict(self) + newobj._keylist = self._keylist + newobj._valuelist = self._valuelist + return newobj + +class SdfData: + _filename = ""; + _dict = MyOrderedDict() + _languages_found = []; + + def __init__ (self, filename=""): + self._filename = filename + + def __getitem__(self, key): + if self._dict.has_key(key): + return self._dict[key] + else: + return None + + def has_key(self, key): + return self._dict.has_key(key) + + def __setitem__(self, key, value): + self._dict[key] = value + + def get_languages_found_in_sdf(self): + return set(self._languages_found) + + def read(self): + try: + f = open(self._filename, "r") + lines = [line.rstrip('\n') for line in f.readlines()] + except IOError: + print "ERROR: Trying to read "+ self._filename + raise + else: + f.close() + for line in lines: + entity = SdfEntity() + entity.set_properties(line) + self._dict[entity.get_id()] = entity + self._languages_found.append(entity.langid) + + def write(self, filename): + try: + f = open(filename, "w+") + for value in self._dict.itervalues(): + #f.write( repr(value)+"\n" ) + f.write(value + "\n") + except IOError: + print "ERROR: Trying to write " + filename + raise + else: + f.close() + +import sys +class SdfEntity: + # Sdf format columns + project = "" + source_file = "" + dummy1 = "" + resource_type = "" + gid = "" + lid = "" + helpid = "" + platform = "" + dummy2 = "" + langid = "" + text = "" + helptext = "" + quickhelptext = "" + title = "" + date = "" + + import const + const._PROJECT_POS = 0 + const._SOURCE_FILE_POS = 1 + const._DUMMY1_POS = 2 + const._RESOURCE_TYPE_POS = 3 + const._GID_POS = 4 + const._LID_POS = 5 + const._HELPID_POS = 6 + const._PLATFORM_POS = 7 + const._DUMMY2_POS = 8 + const._LANGID_POS = 9 + const._TEXT_POS = 10 + const._HELPTEXT_POS = 11 + const._QUICKHELPTEXT_POS = 12 + const._TITLE_POS = 13 + const._DATE_POS = 14 + + def __init__(self, project="", source_file="", dummy1="", resource_type="", gid="", lid="", helpid="", platform="", dummy2="", langid="", + text="", helptext="", quickhelptext="", title="", date="2002-02-02 02:02:02"): + self.project = project; + self.source_file = source_file; + self.dummy1 = dummy1; + self.resource_type = resource_type; + self.gid = gid; + self.lid = lid; + self.helpid = helpid; + self.platform = platform; + self.dummy2 = dummy2; + self.langid = langid; + self.text = text; + self.helptext = helptext; + self.quickhelptext = quickhelptext; + self.title = title; + self.date = date; + + def set_properties(self, line): + splitted = line.split("\t") + if len(splitted) == 15: + self.project = splitted[ self.const._PROJECT_POS ] + self.source_file = splitted[ self.const._SOURCE_FILE_POS ] + self.dummy1 = splitted[ self.const._DUMMY1_POS ] + self.resource_type = splitted[ self.const._RESOURCE_TYPE_POS ] + self.gid = splitted[ self.const._GID_POS ] + self.lid = splitted[ self.const._LID_POS ] + self.helpid = splitted[ self.const._HELPID_POS ] + self.platform = splitted[ self.const._PLATFORM_POS ] + self.dummy2 = splitted[ self.const._DUMMY2_POS ] + self.langid = splitted[ self.const._LANGID_POS ] + self.text = splitted[ self.const._TEXT_POS ] + self.helptext = splitted[ self.const._HELPTEXT_POS ] + self.quickhelptext = splitted[ self.const._QUICKHELPTEXT_POS ] + self.title = splitted[ self.const._TITLE_POS ] + self.date = splitted[ self.const._DATE_POS ] + + def get_file_id(self): + return self.project + "\\" + self.source_file + + def get_resource_path(self): + return self.source_file[0:self.source_file.rfind( "\\" )-1] + + def __str__(self): + return ''.join([self.project, "\t", self.source_file, "\t", self.dummy1, "\t", self.resource_type, "\t" , + self.gid, "\t", self.lid, "\t", self.helpid, "\t", self.platform, "\t", self.dummy2, "\t" , self.langid, + "\t", self.text, "\t", self.helptext, "\t", self.quickhelptext, "\t" , self.title, "\t", self.date ]) + + def get_id(self): + return ''.join([self.project, self.gid, self.lid, self.source_file, self.resource_type, self.platform, self.helpid, self.langid]) diff --git a/l10ntools/scripts/tool/xhtex.py b/l10ntools/scripts/tool/xhtex.py new file mode 100644 index 000000000000..99e0f39259a2 --- /dev/null +++ b/l10ntools/scripts/tool/xhtex.py @@ -0,0 +1,133 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +from l10ntool import abstractL10nTool +from sdf import SdfEntity +import sys +import xml.dom.minidom + +class xhtex(abstractL10nTool): + _resource_type = "xht" + _sdfdata = () + _lang = "" + + # Extract methods + def extract_topic(self, list, inputfile): + topics = [] + for elem in list: + if elem.childNodes[0].nodeType == elem.TEXT_NODE: + topics.append(self.prepare_sdf_line(id=elem.getAttribute("id").strip(), text=elem.childNodes[0].data, inputfile=inputfile)) + return topics + + def extract_title(self, list, inputfile): + titles = [] + for elem in list: + titles.append(self.prepare_sdf_line(id=elem.getAttribute("id").strip(), text=elem.getAttribute("title").strip(), inputfile=inputfile)) + return titles + + # Merge methods + def merge_topic(self, list, sdfdata, lang, inputfilename, dom): + for elem in list: + if elem.childNodes[0].nodeType == elem.TEXT_NODE and elem.getAttribute("id").strip(): + obj = self.prepare_sdf_line(inputfile=inputfilename, lang=lang, id=elem.getAttribute("id").strip()) + if sdfdata[obj.get_id()]: + elem.childNodes[0].data = str(sdfdata[obj.get_id()].text) + + def merge_title(self, list, sdfdata, lang, inputfilename): + for elem in list: + obj = self.prepare_sdf_line(inputfile=inputfilename, lang=lang, id=elem.getAttribute("id").strip()) + if elem.getAttribute("id").strip() and sdfdata[obj.get_id()]: + elem.setAttribute("title", str(sdfdata[obj.get_id()].text)) + + # L10N tool + def __init__(self): + abstractL10nTool.__init__(self) + + def parse_file(self, filename): + document = "" + try: + f = open(filename, "r+") + document = f.read() + except IOError: + print "ERROR: Can not read file " + filename + sys.exit(-1) + else: + f.close() + return xml.dom.minidom.parseString(document) + + + def merge_file(self, inputfilename, outputfilename, parsed_file_ref, lang,is_forced_lang, sdfdata): + if lang == "en-US": + mod_outputfilename = outputfilename.replace("_en-US",'') + self.copy_file(inputfilename, mod_outputfilename) + return + dom = parsed_file_ref.cloneNode(True) + #dom = self.parse_file(inputfilename) # in case cloneNode is buggy just parse it always + + self.merge_topic(dom.getElementsByTagName("topic"), sdfdata, lang, inputfilename, dom) + self.merge_title(dom.getElementsByTagName("node"), sdfdata, lang, inputfilename) + self.merge_title(dom.getElementsByTagName("help_section"), sdfdata, lang, inputfilename) + self.make_dirs(outputfilename) + try: + f = open(outputfilename, "w+") + str = dom.toxml() + f.write(str) + except IOError: + print "ERROR: Can not write file " + outputfilename + sys.exit(-1) + else: + f.close() + + ##### Helper for parse-once-use-often like parsing a xml file is needed implement it here + def parse_file(self, filename): + document = "" + try: + f = open(filename,"r+") + document = f.read() + except IOError: + print "ERROR: Can not read file " + filename + else: + f.close() + return xml.dom.minidom.parseString(document) + + ##### Extract a single File + def extract_file(self, inputfile): + sdf_data = [] + dom = self.parse_file(inputfile) + sdf_data.extend(self.extract_topic(dom.getElementsByTagName("topic"), inputfile)) + sdf_data.extend(self.extract_title(dom.getElementsByTagName("help_section"), inputfile)) + sdf_data.extend(self.extract_title(dom.getElementsByTagName("node"), inputfile)) + return ''.join([str(line)+"\n" for line in sdf_data]) + + def prepare_sdf_line(self, inputfile="", lang="" , id="" , text=""): + if lang == "": + lang = self._source_language + return SdfEntity(project=self._options.project_name, source_file=self.get_filename_string(inputfile), + resource_type=self._resource_type, gid=id, lid="", langid=lang,text=text) + +run = xhtex() + diff --git a/l10ntools/scripts/tool/xtxex.py b/l10ntools/scripts/tool/xtxex.py new file mode 100644 index 000000000000..bb11e337d37a --- /dev/null +++ b/l10ntools/scripts/tool/xtxex.py @@ -0,0 +1,89 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +from l10ntool import abstractL10nTool +from sdf import SdfEntity +import sys +import shutil + +class xtxex(abstractL10nTool): + _resource_type = "xtx" + + def __init__(self): + abstractL10nTool.__init__(self) + + 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",'') + 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: + f = open(outputfilename, "w+") + f.write(line) + except IOError: + print "ERROR: Can not write file " + outputfilename + sys.exit(-1) + else: + f.close() + return + # no sdf data found then copy en-US source file + if is_forced_lang: + self.copy_file(inputfilename, outputfilename) + + ##### Extract a single File + def extract_file(self, inputfile): + lines = [] + try: + f = open(inputfile, "r") + lines = f.readlines() + except IOError: + print "ERROR: Can not open file " + inputfile + sys.exit(-1) + else: + f.close() + # remove legal header + lines = [line for line in lines if len(line) > 0 and not line[0] == '#'] + # escape all returns + lines = [line.replace('\n', "\\n") for line in lines] + line = ''.join(lines) + sdf_entity = self.prepare_sdf_line(inputfile); + sdf_entity.text = line + return str(sdf_entity) + + def prepare_sdf_line(self, inputfile="", lang=""): + if lang == "": + lang = self._source_language + return SdfEntity(project=self._options.project_name, source_file=self.get_filename_string(inputfile), + resource_type=self._resource_type, gid="none", lid="none", langid=lang,text="") + +run = xtxex() -- cgit v1.2.3 From 81864751ef5e6e51906d5bae7de39cf19505e868 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Tue, 13 Jul 2010 18:00:06 +0200 Subject: txtl10n: #i113008# #i113125# Support of help tree files and single txt files in the L10N process --- l10ntools/scripts/const.py | 39 ------- l10ntools/scripts/l10ntool.py | 188 --------------------------------- l10ntools/scripts/sdf.py | 238 ------------------------------------------ l10ntools/scripts/xhtex | 47 +++++++++ l10ntools/scripts/xtxex.py | 107 ------------------- 5 files changed, 47 insertions(+), 572 deletions(-) delete mode 100644 l10ntools/scripts/const.py delete mode 100644 l10ntools/scripts/l10ntool.py delete mode 100644 l10ntools/scripts/sdf.py create mode 100755 l10ntools/scripts/xhtex delete mode 100644 l10ntools/scripts/xtxex.py diff --git a/l10ntools/scripts/const.py b/l10ntools/scripts/const.py deleted file mode 100644 index 2d514eabdab6..000000000000 --- a/l10ntools/scripts/const.py +++ /dev/null @@ -1,39 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -# Pseudo const -class _const: - class ConstError(TypeError): pass - def __setattr__(self, name, value): - if self.__dict__.has_key(name): - raise self.ConstError, "Can't rebind const(%s)"%name - self.__dict__[name] = value - -import sys -sys.modules[__name__] = _const() - - diff --git a/l10ntools/scripts/l10ntool.py b/l10ntools/scripts/l10ntool.py deleted file mode 100644 index e98a8189e9b7..000000000000 --- a/l10ntools/scripts/l10ntool.py +++ /dev/null @@ -1,188 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -from optparse import OptionParser -from sdf import SdfData -import sys , os - -class abstractL10nTool: - _options = {} - _args = "" - _resource_type = "" - _source_language = "en-US" - - ##### Implement these abstract methods - - ##### Nameing scheme for the output files - def get_outputfile_format_str(self): - # filename,fileNoExt,language,extension,pathPrefix,pathPostFix,path - return "{path}/{fileNoExt}_{language}.{extension}" - - ################################# Merge single files ########################################### - - ##### Merge a single file - def merge_file(self, inputfilename, outputfilename, parsed_file_ref, lang, is_forced_lang, sdfdata): - pass - - ##### Helper for parse-once-use-often like parsing a xml file is needed implement it here - def parse_file(self, filename): - return None - - ################### Merge one big file containing all strings in all languages ################# - def merge_one_big_file(self, inputfile, outputfilename, parsed_file_ref, lang, sdfdata): - pass - - ################### Extract a single File ###################################################### - def extract_file(self, inputfile): - pass - - ################################################################################################ - - def format_outputfile(self, filename, language): - extension = filename[filename.rfind('.')+1:] - file = filename[:filename.rfind('.')] - return self.get_outputfile_format_str().format( - filename=filename, fileNoExt=file, language=language, extension=extension, path_prefix=self._options.path_prefix, - path_postfix=self._options.path_postfix, path=self.get_path()) - - def get_path(self): - if self._options.outputfile.find('/') == -1: - return "" - else: - return self._options.outputfile[:self._options.outputfile.rfind('/')] - - def merge(self, sdfdata): - langset,forcedset, foundset = set(), set() , set() - - if self._options.languages: langset = set(self._options.languages) - if self._options.forcedlanguages: forcedset = set(self._options.forcedlanguages) - if sdfdata.get_languages_found_in_sdf(): foundset = sdfdata.get_languages_found_in_sdf() - - if self.has_multi_inputfiles(): - filelist = self.read_inputfile_list() - else: - filelist = self._options.inputfile - - for inputfile in filelist: - ref = self.parse_file(inputfile) - # Don't write that files if there is no l10n present - if ((langset & foundset) - forcedset): # all langs given and found in sdf without enforced - [self.merge_file(inputfile,self.format_outputfile(inputfile, lang), ref, lang, False, sdfdata) for lang in ((langset & foundset) - forcedset)] - # Always write those files even if there is no l10n available - if forcedset: # all enforced langs - [self.merge_file(inputfile, self.format_outputfile(inputfile, lang), ref, lang, True, sdfdata) for lang in forcedset] - # In case a big file have to be written - if ((langset & foundset) | forcedset): # all langs given ,found in sdf and enforced ones - self.merge_one_big_file(inputfile, self.format_outputfile(inputfile, lang), ref, ((langset & foundset) | forcedset), sdfdata) - - def has_multi_inputfiles(self): - return self._options.inputfile[0] == '@' - - def extract(self): - try: - f = open(self._options.outputfile, "w+") - f.write(self.extract_file(self._options.inputfile)) - except IOError: - print "ERROR: Can not write file " + self._options.outputfile - else: - f.close() - - # Parse the common options - def parse_options(self): - parser = OptionParser() - parser.add_option("-i", "--inputfile", dest="inputfile", metavar="FILE", help="resource file to read" ) - parser.add_option("-o", "--outputfile", dest="outputfile", metavar="FILE", help="extracted sdf or merged file" ) - parser.add_option("-m", "--inputsdffile", dest="input_sdf_file", metavar="FILE", help="merge this sdf file" ) - parser.add_option("-x", "--pathprefix", dest="path_prefix", metavar="PATH", help="" ) - parser.add_option("-y", "--pathpostfix", dest="path_postfix", metavar="PATH", help="" ) - parser.add_option("-p", "--projectname", dest="project_name", metavar="NAME", help="" ) - parser.add_option("-r", "--projectroot", dest="project_root", metavar="PATH", help="" ) - parser.add_option("-f", "--forcedlanguages", dest="forcedlanguages", metavar="ISOCODE[,ISOCODE]", help="Always merge those langs even if no l10n is available for those langs" ) - parser.add_option("-l", "--languages", dest="languages", metavar="ISOCODE[,ISOCODE]", help="Merge those langs if l10n is found for each") - parser.add_option("-q", "--quiet", action="store_true", dest="quietmode", help="",default=False) - (self._options, self.args) = parser.parse_args() - - # -l "de,pr,pt-BR" => [ "de" , "pt" , "pt-BR" ] - parse_complex_arg = lambda arg: arg.split(",") - if self._options.forcedlanguages: self._options.forcedlanguages = parse_complex_arg(self._options.forcedlanguages) - if self._options.languages: self._options.languages = parse_complex_arg(self._options.languages) - self.test_options() - - def __init__(self): - self.parse_options() - if self._options.input_sdf_file != None and len(self._options.input_sdf_file): - sdfdata = SdfData(self._options.input_sdf_file) - sdfdata.read() - self.merge(sdfdata) - else: - self.extract() - - def make_dirs(self, filename): - dir = filename[:filename.rfind('/')] - if os.path.exists(dir): - if os.path.isfile(dir): - print "ERROR: There is a file '"+dir+"' where I want create a directory" - sys.exit(-1) - else: - return - else: - try: - print "DBG: make_dir " + str(dir) - os.makedirs(dir) - except IOError: - print "Error: Can not create dir " + dir - sys.exit(-1) - - def test_options(self): - opt = self._options - is_valid = lambda x: x != None and len(x) > 0 - return is_valid(opt.project_root) and is_valid(opt.project_name) and is_valid(opt.languages) and \ - ( is_valid(opt.inputfile) and (( is_valid(opt.path_prefix) and is_valid(opt.path_postfix) ) or is_valid(opt.outputfile)) and \ - ( ( is_valid(opt.input_sdf_file) and ( is_valid(opt.outputfile) or ( is_valid(opt.path_prefix) and is_valid(opt.path_postfix) ) or \ - ( is_valid(opt.inputfile) and is_valid(opt.outputFile)) )))) - print "Strange options ..." - sys.exit( -1 ) - - - def read_inputfile_list(self): - if self.has_multi_inputfiles(): - lines = [] - try: - f = open(self._options.inputfile[1:], "r") - lines = [line.strip('\n') for line in f.readlines()] - except IOError: - print "ERROR: Can not read file list " + self._options.inputfile[2:] - sys.exit(-1) - else: - f.close() - return lines - - 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)+1:].replace('/','\\') - diff --git a/l10ntools/scripts/sdf.py b/l10ntools/scripts/sdf.py deleted file mode 100644 index 1d7cc27f0733..000000000000 --- a/l10ntools/scripts/sdf.py +++ /dev/null @@ -1,238 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -class MyOrderedDict(dict): - _keylist = [] - _valuelist = [] - - #correct?!? - def __init__(self, defaults={}): - dict.__init__(self) - for n,v in defaults.items(): - self[n] = v - #def __getitem__(self): - # pass - - def __setitem__(self, key, value): - self._keylist.append(key) - self._valuelist.append(value) - return dict.__setitem__(self, key, value) - - def __delattr__(self, key): - self._keylist.__delattr__(key) - self._valuelist.__delattr__(dict[key]) - return dict.__delattr__(self, key) - - def __delitem__(self, key): - self._keylist.__delitem__(key) - self._valuelist.__delitem__(dict[key]) - return dict.__delitem__(self, key) - - def __iter(self): - return zip(self._keylist, self._valuelist) - - def __iterkeys__(self): - return self._keylist - - def __iteritems__(self): - return self._valuelist - - def items(self): - return zip(self._keylist,self._valuelist) - - def keys(self): - return self._keylist - - def __keysattr__(self): - return self._keylist - - def pop(self, key): - self._keylist.pop(key) - self._valuelist.pop(key) - return dict.__pop__(self, key) - - def popitem(self): - raise NotImplementedError("popitem") - - def clear(self): - self._keylist.clear() - self._valuelist.clear() - return dict.clear() - - def copy(self): - # correct?!? - newobj = MyOrderedDict(self) - newobj._keylist = self._keylist - newobj._valuelist = self._valuelist - return newobj - -class SdfData: - _filename = ""; - _dict = MyOrderedDict() - #_dict = {} - _languages_found = []; - - def __init__ (self, filename=""): - self._filename = filename - - def __getitem__(self, key): - if self._dict.has_key(key): - return self._dict[key] - else: - return None - - def has_key(self, key): - return self._dict.has_key(key) - - def __setitem__(self, key, value): - self._dict[key] = value - - def get_languages_found_in_sdf(self): - return set(self._languages_found) - - def read(self): - try: - f = open(self._filename, "r") - lines = [line.rstrip('\n') for line in f.readlines()] - except IOError: - print "ERROR: Trying to read "+ self._filename - raise - else: - f.close() - for line in lines: - entity = SdfEntity() - entity.set_properties(line) - self._dict[entity.get_id()] = entity - self._languages_found.append(entity.langid) - - def write(self, filename): - try: - f = open(filename, "w+") - for value in self._dict.itervalues(): - #f.write( repr(value)+"\n" ) - f.write(value + "\n") - except IOError: - print "ERROR: Trying to write " + filename - raise - else: - f.close() - - - -import sys -class SdfEntity: - # Sdf format columns - project = "" - source_file = "" - dummy1 = "" - resource_type = "" - gid = "" - lid = "" - helpid = "" - platform = "" - dummy2 = "" - langid = "" - text = "" - helptext = "" - quickhelptext = "" - title = "" - date = "" - - import const - const._PROJECT_POS = 0 - const._SOURCE_FILE_POS = 1 - const._DUMMY1_POS = 2 - const._RESOURCE_TYPE_POS = 3 - const._GID_POS = 4 - const._LID_POS = 5 - const._HELPID_POS = 6 - const._PLATFORM_POS = 7 - const._DUMMY2_POS = 8 - const._LANGID_POS = 9 - const._TEXT_POS = 10 - const._HELPTEXT_POS = 11 - const._QUICKHELPTEXT_POS = 12 - const._TITLE_POS = 13 - const._DATE_POS = 14 - - - - def __init__(self, project="", source_file="", dummy1="", resource_type="", gid="", lid="", helpid="", platform="", dummy2="", langid="", - text="", helptext="", quickhelptext="", title="", date="2002-02-02 02:02:02"): - self.project = project; - self.source_file = source_file; - self.dummy1 = dummy1; - self.resource_type = resource_type; - self.gid = gid; - self.lid = lid; - self.helpid = helpid; - self.platform = platform; - self.dummy2 = dummy2; - self.langid = langid; - self.text = text; - self.helptext = helptext; - self.quickhelptext = quickhelptext; - self.title = title; - self.date = date; - - def set_properties(self, line): - splitted = line.split("\t") - if len(splitted) == 15: - self.project = splitted[ self.const._PROJECT_POS ] - self.source_file = splitted[ self.const._SOURCE_FILE_POS ] - self.dummy1 = splitted[ self.const._DUMMY1_POS ] - self.resource_type = splitted[ self.const._RESOURCE_TYPE_POS ] - self.gid = splitted[ self.const._GID_POS ] - self.lid = splitted[ self.const._LID_POS ] - self.helpid = splitted[ self.const._HELPID_POS ] - self.platform = splitted[ self.const._PLATFORM_POS ] - self.dummy2 = splitted[ self.const._DUMMY2_POS ] - self.langid = splitted[ self.const._LANGID_POS ] - self.text = splitted[ self.const._TEXT_POS ] - self.helptext = splitted[ self.const._HELPTEXT_POS ] - self.quickhelptext = splitted[ self.const._QUICKHELPTEXT_POS ] - self.title = splitted[ self.const._TITLE_POS ] - self.date = splitted[ self.const._DATE_POS ] - #else: - # print "Offending line '"+line+"'" - # print "ERROR: Something is broken here! Line has {0} tabs".format( len(splitted) ) - # sys.exit( -1 ) - - def get_file_id(self): - return self.project + "\\" + self.source_file - - def get_resource_path(self): - return self.source_file[0:self.source_file.rfind( "\\" )-1] - - #def __repr__(self): - def __str__(self): - return ''.join([self.project, "\t", self.source_file, "\t", self.dummy1, "\t", self.resource_type, "\t" , - self.gid, "\t", self.lid, "\t", self.helpid, "\t", self.platform, "\t", self.dummy2, "\t" , self.langid, - "\t", self.text, "\t", self.helptext, "\t", self.quickhelptext, "\t" , self.title, "\t", self.date ]) - - def get_id(self): - return ''.join([self.project, self.gid, self.lid, self.source_file, self.resource_type, self.platform, self.helpid, self.langid]) diff --git a/l10ntools/scripts/xhtex b/l10ntools/scripts/xhtex new file mode 100755 index 000000000000..e6f7cf9f2003 --- /dev/null +++ b/l10ntools/scripts/xhtex @@ -0,0 +1,47 @@ +#!/bin/sh +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +if [ x${SOLARENV}x = xx ]; then + echo No environment found, please use 'setsolar' +exit 1 +fi + +# localize.pl calls localize_sl in solver bin directory which depends on dynamic +# libraries in solver lib directory but has no correct RPATH (or equivalent): +if [ "${OS?}" = MACOSX ]; then + export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH+${DYLD_LIBRARY_PATH}:}${SOLARVERSION?}/${INPATH?}/lib${UPDMINOREXT} +else + export LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${SOLARVERSION?}/${INPATH?}/lib${UPDMINOREXT} +fi + +if [ x${SOLARVER}x = xx -o x${UPDMINOREXT}x = xx ]; then + exec python $SOLARVERSION/$INPATH/bin/xhtex.py "$@" +else + exec python $SOLARVERSION/$INPATH/bin$UPDMINOREXT/xhtex.py "$@" +fi + diff --git a/l10ntools/scripts/xtxex.py b/l10ntools/scripts/xtxex.py deleted file mode 100644 index a8677b10bf86..000000000000 --- a/l10ntools/scripts/xtxex.py +++ /dev/null @@ -1,107 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -from l10ntool import abstractL10nTool -from sdf import SdfEntity -import sys -import shutil - -class xtxex(abstractL10nTool): - _resourceType = "xtx" - - def __init__(self): - abstractL10nTool.__init__(self) - - 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: - print "ERROR: Can not write file " + outputfilename - sys.exit(-1) - else: - f.close() - return - - # no sdf data found then copy en-US source file - if is_forced_lang: - #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): - lines = [] - try: - f = open(inputfile, "r") - lines = f.readlines() - except IOError: - print "ERROR: Can not open file " + inputfile - sys.exit(-1) - else: - f.close() - # remove legal header - lines = [line for line in lines if len(line) > 0 and not line[0] == '#'] - # escape all returns - lines = [line.replace('\n', "\\n") for line in lines] - line = ''.join(lines) - sdf_entity = self.prepare_sdf_line(inputfile); - sdf_entity.text = line - return str(sdf_entity) - - ##### Nameing scheme for the output files - def get_outputfile_format_str(self): - # filename,fileNoExt,language,extension,pathPrefix,pathPostFix,path - return "{path}/{fileNoExt}_{language}.{extension}" - - def prepare_sdf_line(self, inputfile="", lang=""): - if lang == "": - lang = self._source_language - return SdfEntity(project=self._options.project_name, source_file=self.get_filename_string(inputfile), - resource_type=self._resource_type, gid="none", lid="none", langid=lang,text="") - -run = xtxex() -- cgit v1.2.3 From 31236973b376567a7acf33962385329855f89665 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 14 Jul 2010 16:59:49 +0200 Subject: txtl10n: #i113008# #i113125# Python 2.3.x compatible --- l10ntools/scripts/tool/l10ntool.py | 20 ++-- l10ntools/scripts/tool/pseudo.py | 184 +++++++++++++++++++++++++++++++++++++ l10ntools/scripts/tool/sdf.py | 65 +------------ l10ntools/scripts/tool/xhtex.py | 1 + 4 files changed, 202 insertions(+), 68 deletions(-) create mode 100644 l10ntools/scripts/tool/pseudo.py diff --git a/l10ntools/scripts/tool/l10ntool.py b/l10ntools/scripts/tool/l10ntool.py index 66afc309a1fb..42e8a6b4e428 100644 --- a/l10ntools/scripts/tool/l10ntool.py +++ b/l10ntools/scripts/tool/l10ntool.py @@ -27,6 +27,8 @@ from optparse import OptionParser from sdf import SdfData +from pseudo import PseudoSet + import sys import os import shutil @@ -68,9 +70,15 @@ class abstractL10nTool: def format_outputfile(self, filename, language): extension = filename[filename.rfind('.')+1:] file = filename[:filename.rfind('.')] - return self.get_outputfile_format_str().replace('[', '{').replace(']','}').format( - filename=filename, fileNoExt=file, language=language, extension=extension, path_prefix=self._options.path_prefix, - path_postfix=self._options.path_postfix, path=self.get_path()) + + # Python 2.3.x friendly + return self.get_outputfile_format_str().replace('[', '%(').replace(']',')s') % \ + { 'filename': filename, 'fileNoExt': file, 'language': language, 'extension': extension, 'path_prefix': self._options.path_prefix, + 'path_postfix': self._options.path_postfix, 'path': self.get_path() } + + #return self.get_outputfile_format_str().replace('[', '{').replace(']','}').format( + # filename=filename, fileNoExt=file, language=language, extension=extension, path_prefix=self._options.path_prefix, + # path_postfix=self._options.path_postfix, path=self.get_path()) def get_path(self): if self._options.outputfile.find('/') == -1: @@ -79,12 +87,12 @@ class abstractL10nTool: return self._options.outputfile[:self._options.outputfile.rfind('/')] def merge(self, sdfdata): - langset,forcedset, foundset = set(), set() , set() + langset,forcedset, foundset = PseudoSet(), PseudoSet() , PseudoSet() if self._options.languages: - langset = set(self._options.languages) + langset = PseudoSet(self._options.languages) if self._options.forcedlanguages: - forcedset = set(self._options.forcedlanguages) + forcedset = PseudoSet(self._options.forcedlanguages) if sdfdata.get_languages_found_in_sdf(): foundset = sdfdata.get_languages_found_in_sdf() diff --git a/l10ntools/scripts/tool/pseudo.py b/l10ntools/scripts/tool/pseudo.py new file mode 100644 index 000000000000..ee23b22f4e79 --- /dev/null +++ b/l10ntools/scripts/tool/pseudo.py @@ -0,0 +1,184 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +# to support macosx baseline machines from Cretaceous period + +# incomplete set() class implementation of Python 2.4 +class PseudoSet: + _list = [] + + def __str__(self): + return str(self._list) + + def __init__(self, newlist=[]): + self._list = self._remove_dupes(newlist) + + def __or__(self, other): + tmplist = [] + if self._list != None and other != None: + tmplist.extend(self._list) + tmplist.extend(other) + return PseudoSet(self._remove_dupes(tmplist)) + else: + print "__or__(None)" + + def __sub__(self,other): + tmplist = [] + if self._list != None and other != None: + tmplist.extend(self._list) + [tmplist.remove(key) for key in other if key in tmplist] + else: + print __sub__(none) + return PseudoSet(tmplist) + + def __and__(self, other): + tmplist = [] + if other != None and self._list != None: + [tmplist.append(key) for key in self._list if key in other] + return PseudoSet(tmplist) + else: + print "__and__(None)" + + def __iter__(self): + return self._list.__iter__() + + def __items__(self): + return self._list.items() + + def __keys__(self): + return keys(self._list) + + def _remove_dupes(self, list): + tmpdict = {} + for key in list: + tmpdict[key] = 1 + return tmpdict.keys() + +# incomplete OrderedDict() class implementation +class PseudoOrderedDict(dict): + _keylist = [] + _valuelist = [] + + def __init__(self, defaults={}): + dict.__init__(self) + for n,v in defaults.items(): + self[n] = v + + def __setitem__(self, key, value): + self._keylist.append(key) + self._valuelist.append(value) + return dict.__setitem__(self, key, value) + + def __delattr__(self, key): + self._keylist.__delattr__(key) + self._valuelist.__delattr__(dict[key]) + return dict.__delattr__(self, key) + + def __delitem__(self, key): + self._keylist.__delitem__(key) + self._valuelist.__delitem__(dict[key]) + return dict.__delitem__(self, key) + + def __iter__(self): + raise NotImplementedError("__iter__") + + def __iterkeys__(self): + return self._keylist + + def iteritems(self): + #return self._valuelist + return zip(self._keylist, self._valuelist) + + def items(self): + return zip(self._keylist,self._valuelist) + + def __keys__(self): + return self._keylist + + def keys(self): + return self._keylist + + def __keysattr__(self): + return self._keylist + + def pop(self, key): + self._keylist.pop(key) + self._valuelist.pop(key) + return dict.__pop__(self, key) + + def popitem(self): + raise NotImplementedError("popitem") + +def _testdriver_set(): + list, list1 = [] ,[] + list.append("a") + list.append("b") + list.append("c") + + list1.append("a") + list1.append("b") + list1.append("d") + list1.append("e") + list1.append("e") + + if "a" in list: + print "YEAH!" + + a = PseudoSet(list) + b = PseudoSet(list1) + + print "a="+str(a) + print "b="+str(b) + print "a|b=" + str(a|b) + print "a="+str(a) + print "b="+str(b) + print "a&b=" + str(a&b) + print "a="+str(a) + print "b="+str(b) + print "a-b" + str(a-b) + + for key in a: + print key + +def _testdriver_dict(): + d = PseudoOrderedDict() + d["a"] = 1 + d["b"] = 2 + d["c"] = 3 + d["d"] = 4 + d["e"] = 5 + d["f"] = 6 + + print "a="+str(d["a"]) + print "e="+str(d["e"]) + for key,value in d.iteritems(): + print "d["+key+"]="+str(d[key]) + print "key="+str(key)+" value="+str(value) + + print "keys="+str(d.keys()) + +#_testdriver_dict() diff --git a/l10ntools/scripts/tool/sdf.py b/l10ntools/scripts/tool/sdf.py index 33bf90b4ea68..2afcbaf4bb1f 100644 --- a/l10ntools/scripts/tool/sdf.py +++ b/l10ntools/scripts/tool/sdf.py @@ -25,70 +25,11 @@ # #************************************************************************* -class MyOrderedDict(dict): - _keylist = [] - _valuelist = [] - - def __init__(self, defaults={}): - dict.__init__(self) - for n,v in defaults.items(): - self[n] = v - - def __setitem__(self, key, value): - self._keylist.append(key) - self._valuelist.append(value) - return dict.__setitem__(self, key, value) - - def __delattr__(self, key): - self._keylist.__delattr__(key) - self._valuelist.__delattr__(dict[key]) - return dict.__delattr__(self, key) +from pseudo import PseudoSet,PseudoOrderedDict - def __delitem__(self, key): - self._keylist.__delitem__(key) - self._valuelist.__delitem__(dict[key]) - return dict.__delitem__(self, key) - - def __iter(self): - return zip(self._keylist, self._valuelist) - - def __iterkeys__(self): - return self._keylist - - def __iteritems__(self): - return self._valuelist - - def items(self): - return zip(self._keylist,self._valuelist) - - def keys(self): - return self._keylist - - def __keysattr__(self): - return self._keylist - - def pop(self, key): - self._keylist.pop(key) - self._valuelist.pop(key) - return dict.__pop__(self, key) - - def popitem(self): - raise NotImplementedError("popitem") - - def clear(self): - self._keylist.clear() - self._valuelist.clear() - return dict.clear() - - def copy(self): - newobj = MyOrderedDict(self) - newobj._keylist = self._keylist - newobj._valuelist = self._valuelist - return newobj - class SdfData: _filename = ""; - _dict = MyOrderedDict() + _dict = PseudoOrderedDict() _languages_found = []; def __init__ (self, filename=""): @@ -107,7 +48,7 @@ class SdfData: self._dict[key] = value def get_languages_found_in_sdf(self): - return set(self._languages_found) + return PseudoSet(self._languages_found) def read(self): try: diff --git a/l10ntools/scripts/tool/xhtex.py b/l10ntools/scripts/tool/xhtex.py index 99e0f39259a2..c876b9f7c2a0 100644 --- a/l10ntools/scripts/tool/xhtex.py +++ b/l10ntools/scripts/tool/xhtex.py @@ -83,6 +83,7 @@ class xhtex(abstractL10nTool): def merge_file(self, inputfilename, outputfilename, parsed_file_ref, lang,is_forced_lang, sdfdata): if lang == "en-US": mod_outputfilename = outputfilename.replace("_en-US",'') + self.make_dirs(mod_outputfilename) self.copy_file(inputfilename, mod_outputfilename) return dom = parsed_file_ref.cloneNode(True) -- cgit v1.2.3 From a1b4b65e3514c8ac3c21bae04ceeccc90eb29bfa Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 14 Jul 2010 17:00:39 +0200 Subject: txtl10n: #i113008# #i113125# Python 2.3.x compatible --- l10ntools/prj/d.lst | 1 + 1 file changed, 1 insertion(+) diff --git a/l10ntools/prj/d.lst b/l10ntools/prj/d.lst index 9594dc416c8e..53c846832fca 100644 --- a/l10ntools/prj/d.lst +++ b/l10ntools/prj/d.lst @@ -52,6 +52,7 @@ mkdir: %_DEST%\bin%_EXT%\help\com\sun\star\help ..\scripts\tool\xtxex.py %_DEST%\bin%_EXT%\xtxex.py ..\scripts\tool\sdf.py %_DEST%\bin%_EXT%\sdf.py ..\scripts\tool\xhtex.py %_DEST%\bin%_EXT%\xhtex.py +..\scripts\tool\pseudo.py %_DEST%\bin%_EXT%\pseudo.py ..\scripts\xtxex %_DEST%\bin%_EXT%\xtxex ..\scripts\xhtex %_DEST%\bin%_EXT%\xhtex -- cgit v1.2.3 From f72e6b7a877f3d5326bb3c9dad53aa1913b0ed2e Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 14 Jul 2010 17:06:23 +0200 Subject: txtl10n: #i113008# #i113125# cleanup --- l10ntools/scripts/tool/l10ntool.py | 3 +-- l10ntools/scripts/tool/xhtex.py | 8 ++++---- l10ntools/scripts/tool/xtxex.py | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/l10ntools/scripts/tool/l10ntool.py b/l10ntools/scripts/tool/l10ntool.py index 42e8a6b4e428..70d88674f07b 100644 --- a/l10ntools/scripts/tool/l10ntool.py +++ b/l10ntools/scripts/tool/l10ntool.py @@ -33,7 +33,7 @@ import sys import os import shutil -class abstractL10nTool: +class AbstractL10nTool: _options = {} _args = "" _resource_type = "" @@ -176,7 +176,6 @@ class abstractL10nTool: return else: try: - print "DBG: make_dir " + str(dir) os.makedirs(dir) except IOError: print "Error: Can not create dir " + dir diff --git a/l10ntools/scripts/tool/xhtex.py b/l10ntools/scripts/tool/xhtex.py index c876b9f7c2a0..ab6e1dd14631 100644 --- a/l10ntools/scripts/tool/xhtex.py +++ b/l10ntools/scripts/tool/xhtex.py @@ -25,12 +25,12 @@ # #************************************************************************* -from l10ntool import abstractL10nTool +from l10ntool import AbstractL10nTool from sdf import SdfEntity import sys import xml.dom.minidom -class xhtex(abstractL10nTool): +class Xhtex(AbstractL10nTool): _resource_type = "xht" _sdfdata = () _lang = "" @@ -65,7 +65,7 @@ class xhtex(abstractL10nTool): # L10N tool def __init__(self): - abstractL10nTool.__init__(self) + AbstractL10nTool.__init__(self) def parse_file(self, filename): document = "" @@ -130,5 +130,5 @@ class xhtex(abstractL10nTool): return SdfEntity(project=self._options.project_name, source_file=self.get_filename_string(inputfile), resource_type=self._resource_type, gid=id, lid="", langid=lang,text=text) -run = xhtex() +run = Xhtex() diff --git a/l10ntools/scripts/tool/xtxex.py b/l10ntools/scripts/tool/xtxex.py index bb11e337d37a..317fb5cc7ff0 100644 --- a/l10ntools/scripts/tool/xtxex.py +++ b/l10ntools/scripts/tool/xtxex.py @@ -25,16 +25,16 @@ # #************************************************************************* -from l10ntool import abstractL10nTool +from l10ntool import AbstractL10nTool from sdf import SdfEntity import sys import shutil -class xtxex(abstractL10nTool): +class Xtxex(AbstractL10nTool): _resource_type = "xtx" def __init__(self): - abstractL10nTool.__init__(self) + AbstractL10nTool.__init__(self) def merge_file(self, inputfilename, outputfilename, parsed_file_ref, lang, is_forced_lang, sdfdata): # Special handling for en-US files @@ -86,4 +86,4 @@ class xtxex(abstractL10nTool): return SdfEntity(project=self._options.project_name, source_file=self.get_filename_string(inputfile), resource_type=self._resource_type, gid="none", lid="none", langid=lang,text="") -run = xtxex() +run = Xtxex() -- cgit v1.2.3 From 420279385334ce45af842ac28b66146029e56c83 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 14 Jul 2010 17:08:59 +0200 Subject: txtl10n: #i113008# #i113125# cleanup --- l10ntools/scripts/tool/pseudo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10ntools/scripts/tool/pseudo.py b/l10ntools/scripts/tool/pseudo.py index ee23b22f4e79..0956325e31db 100644 --- a/l10ntools/scripts/tool/pseudo.py +++ b/l10ntools/scripts/tool/pseudo.py @@ -52,7 +52,7 @@ class PseudoSet: tmplist.extend(self._list) [tmplist.remove(key) for key in other if key in tmplist] else: - print __sub__(none) + print "__sub__(none)" return PseudoSet(tmplist) def __and__(self, other): -- cgit v1.2.3 From 2c40a12f3307ac3a72f6036a9a2f8939fd7b77c8 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 14 Jul 2010 17:39:22 +0200 Subject: txtl10n: #i113008# #i113125# skip on empty string --- l10ntools/scripts/tool/xhtex.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/l10ntools/scripts/tool/xhtex.py b/l10ntools/scripts/tool/xhtex.py index ab6e1dd14631..c427a7feccdd 100644 --- a/l10ntools/scripts/tool/xhtex.py +++ b/l10ntools/scripts/tool/xhtex.py @@ -39,14 +39,15 @@ class Xhtex(AbstractL10nTool): def extract_topic(self, list, inputfile): topics = [] for elem in list: - if elem.childNodes[0].nodeType == elem.TEXT_NODE: + if elem.childNodes[0].nodeType == elem.TEXT_NODE and len(elem.childNodes[0].data.strip()): topics.append(self.prepare_sdf_line(id=elem.getAttribute("id").strip(), text=elem.childNodes[0].data, inputfile=inputfile)) return topics def extract_title(self, list, inputfile): titles = [] for elem in list: - titles.append(self.prepare_sdf_line(id=elem.getAttribute("id").strip(), text=elem.getAttribute("title").strip(), inputfile=inputfile)) + if len(elem.getAttribute("title").strip()): + titles.append(self.prepare_sdf_line(id=elem.getAttribute("id").strip(), text=elem.getAttribute("title").strip(), inputfile=inputfile)) return titles # Merge methods -- cgit v1.2.3 From 9edb131f425e23ea9e9645fee441975959cfd02b Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 14 Jul 2010 17:46:14 +0200 Subject: txtl10n: #i113008# #i113125# skip on empty string --- l10ntools/scripts/tool/xtxex.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/l10ntools/scripts/tool/xtxex.py b/l10ntools/scripts/tool/xtxex.py index 317fb5cc7ff0..2c5f132530a6 100644 --- a/l10ntools/scripts/tool/xtxex.py +++ b/l10ntools/scripts/tool/xtxex.py @@ -76,10 +76,14 @@ class Xtxex(AbstractL10nTool): # escape all returns lines = [line.replace('\n', "\\n") for line in lines] line = ''.join(lines) - sdf_entity = self.prepare_sdf_line(inputfile); - sdf_entity.text = line - return str(sdf_entity) - + test = str(line) + if len(test.strip()): + sdf_entity = self.prepare_sdf_line(inputfile); + sdf_entity.text = line + return str(sdf_entity) + else: + return "" + def prepare_sdf_line(self, inputfile="", lang=""): if lang == "": lang = self._source_language -- cgit v1.2.3 From a7a69a2a901654928b90ba40202612d778126682 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Tue, 20 Jul 2010 13:11:02 +0200 Subject: txtl10n: #i113008# #i113125# rename .xht to .tree --- l10ntools/source/localize.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index 420fa3a8d484..853dcc97dc3e 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -53,7 +53,7 @@ namespace transex3 const char *ExeTable[][5] = { { "src", "transex3", " -UTF8 -e", "negative", "noiso" }, { "hrc", "transex3", " -UTF8 -e", "positive", "noiso" }, - { "xht", "xhtex", "", "negative", "noiso" }, + { "tree", "xhtex", "", "negative", "noiso" }, { "xtx", "xtxex", "", "negative", "noiso" }, { "ulf", "ulfex", " -e", "negative", "noiso" }, { "xrb", "xmlex", "-UTF8 -e", "negative", "iso" }, -- cgit v1.2.3 From 031cd19797688ee3e3eb5ccd12e6e6abfa8bca88 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 21 Jul 2010 19:07:24 +0200 Subject: txtl10n: #i113008# #i113125# don't die by empty sdf file --- l10ntools/java/jpropex/java/SdfEntity.java | 41 +++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/l10ntools/java/jpropex/java/SdfEntity.java b/l10ntools/java/jpropex/java/SdfEntity.java index 52dc61ca40ca..a05ddf7c2304 100644 --- a/l10ntools/java/jpropex/java/SdfEntity.java +++ b/l10ntools/java/jpropex/java/SdfEntity.java @@ -98,23 +98,30 @@ public class SdfEntity implements Cloneable{ public void setProperties( String line ){ - String[] splitted = line.split("\t"); - - setProject( splitted[ SdfEntity.PROJECT_POS ] ); - setSource_file( splitted[ SdfEntity.SOURCE_FILE_POS ] ); - setDummy1( splitted[ SdfEntity.DUMMY1_POS ] ); - setResource_type( splitted[ SdfEntity.RESOURCE_TYPE_POS ] ); - setGid( splitted[ SdfEntity.GID_POS ] ); - setLid( splitted[ SdfEntity.LID_POS ] ); - setHelpid( splitted[ SdfEntity.HELPID_POS ] ); - setPlatform( splitted[ SdfEntity.PLATFORM_POS ] ); - setDummy2( splitted[ SdfEntity.DUMMY2_POS ] ); - setLangid( splitted[ SdfEntity.LANGID_POS ] ); - setText( splitted[ SdfEntity.TEXT_POS ] ); - setHelptext( splitted[ SdfEntity.HELPTEXT_POS ] ); - setQuickhelptext( splitted[ SdfEntity.QUICKHELPTEXT_POS ] ); - setTitle( splitted[ SdfEntity.TITLE_POS ] ); - setDate( splitted[ SdfEntity.DATE_POS ] ); + String test = new String( line ); + test.trim(); + if( line != null && test.length()>0 ) + { + String[] splitted = line.split("\t"); + if( splitted.length == 15 ) + { + setProject( splitted[ SdfEntity.PROJECT_POS ] ); + setSource_file( splitted[ SdfEntity.SOURCE_FILE_POS ] ); + setDummy1( splitted[ SdfEntity.DUMMY1_POS ] ); + setResource_type( splitted[ SdfEntity.RESOURCE_TYPE_POS ] ); + setGid( splitted[ SdfEntity.GID_POS ] ); + setLid( splitted[ SdfEntity.LID_POS ] ); + setHelpid( splitted[ SdfEntity.HELPID_POS ] ); + setPlatform( splitted[ SdfEntity.PLATFORM_POS ] ); + setDummy2( splitted[ SdfEntity.DUMMY2_POS ] ); + setLangid( splitted[ SdfEntity.LANGID_POS ] ); + setText( splitted[ SdfEntity.TEXT_POS ] ); + setHelptext( splitted[ SdfEntity.HELPTEXT_POS ] ); + setQuickhelptext( splitted[ SdfEntity.QUICKHELPTEXT_POS ] ); + setTitle( splitted[ SdfEntity.TITLE_POS ] ); + setDate( splitted[ SdfEntity.DATE_POS ] ); + } + } } public String getFileId(){ -- cgit v1.2.3 From 6d40e92dcf681213d86fbadbe1c7fc65fbe88ad7 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Thu, 22 Jul 2010 09:48:43 +0200 Subject: txtl10n: #i113008# #i113125# don't die by empty sdf file --- l10ntools/java/jpropex/java/SdfEntity.java | 39 +++++++++++++----------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/l10ntools/java/jpropex/java/SdfEntity.java b/l10ntools/java/jpropex/java/SdfEntity.java index a05ddf7c2304..c2f6a5d788b1 100644 --- a/l10ntools/java/jpropex/java/SdfEntity.java +++ b/l10ntools/java/jpropex/java/SdfEntity.java @@ -98,29 +98,24 @@ public class SdfEntity implements Cloneable{ public void setProperties( String line ){ - String test = new String( line ); - test.trim(); - if( line != null && test.length()>0 ) + if( line != null ) { - String[] splitted = line.split("\t"); - if( splitted.length == 15 ) - { - setProject( splitted[ SdfEntity.PROJECT_POS ] ); - setSource_file( splitted[ SdfEntity.SOURCE_FILE_POS ] ); - setDummy1( splitted[ SdfEntity.DUMMY1_POS ] ); - setResource_type( splitted[ SdfEntity.RESOURCE_TYPE_POS ] ); - setGid( splitted[ SdfEntity.GID_POS ] ); - setLid( splitted[ SdfEntity.LID_POS ] ); - setHelpid( splitted[ SdfEntity.HELPID_POS ] ); - setPlatform( splitted[ SdfEntity.PLATFORM_POS ] ); - setDummy2( splitted[ SdfEntity.DUMMY2_POS ] ); - setLangid( splitted[ SdfEntity.LANGID_POS ] ); - setText( splitted[ SdfEntity.TEXT_POS ] ); - setHelptext( splitted[ SdfEntity.HELPTEXT_POS ] ); - setQuickhelptext( splitted[ SdfEntity.QUICKHELPTEXT_POS ] ); - setTitle( splitted[ SdfEntity.TITLE_POS ] ); - setDate( splitted[ SdfEntity.DATE_POS ] ); - } + String[] splitted = line.split("\t",15); + setProject( splitted[ SdfEntity.PROJECT_POS ] ); + setSource_file( splitted[ SdfEntity.SOURCE_FILE_POS ] ); + setDummy1( splitted[ SdfEntity.DUMMY1_POS ] ); + setResource_type( splitted[ SdfEntity.RESOURCE_TYPE_POS ] ); + setGid( splitted[ SdfEntity.GID_POS ] ); + setLid( splitted[ SdfEntity.LID_POS ] ); + setHelpid( splitted[ SdfEntity.HELPID_POS ] ); + setPlatform( splitted[ SdfEntity.PLATFORM_POS ] ); + setDummy2( splitted[ SdfEntity.DUMMY2_POS ] ); + setLangid( splitted[ SdfEntity.LANGID_POS ] ); + setText( splitted[ SdfEntity.TEXT_POS ] ); + setHelptext( splitted[ SdfEntity.HELPTEXT_POS ] ); + setQuickhelptext( splitted[ SdfEntity.QUICKHELPTEXT_POS ] ); + setTitle( splitted[ SdfEntity.TITLE_POS ] ); + setDate( splitted[ SdfEntity.DATE_POS ] ); } } -- cgit v1.2.3 From 92fe5813fbcedeb034c6fa85f56bafa2113f142d Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Thu, 22 Jul 2010 15:13:04 +0200 Subject: txtl10n: removed obsolete dir --- transex3/java/jpropex/build.xml | 169 ---------- transex3/java/jpropex/java/JPropEx.java | 400 ----------------------- transex3/java/jpropex/java/Main.java | 38 --- transex3/java/jpropex/java/NoLocalizeFilter.java | 55 ---- transex3/java/jpropex/java/OrderedHashMap.java | 96 ------ transex3/java/jpropex/java/SdfData.java | 108 ------ transex3/java/jpropex/java/SdfEntity.java | 254 -------------- transex3/java/jpropex/jpropex | 10 - transex3/java/jpropex/jpropex.MF | 1 - transex3/java/jpropex/makefile.mk | 36 -- 10 files changed, 1167 deletions(-) delete mode 100755 transex3/java/jpropex/build.xml delete mode 100644 transex3/java/jpropex/java/JPropEx.java delete mode 100644 transex3/java/jpropex/java/Main.java delete mode 100644 transex3/java/jpropex/java/NoLocalizeFilter.java delete mode 100644 transex3/java/jpropex/java/OrderedHashMap.java delete mode 100644 transex3/java/jpropex/java/SdfData.java delete mode 100644 transex3/java/jpropex/java/SdfEntity.java delete mode 100755 transex3/java/jpropex/jpropex delete mode 100755 transex3/java/jpropex/jpropex.MF delete mode 100755 transex3/java/jpropex/makefile.mk diff --git a/transex3/java/jpropex/build.xml b/transex3/java/jpropex/build.xml deleted file mode 100755 index d74fb3975d0f..000000000000 --- a/transex3/java/jpropex/build.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/transex3/java/jpropex/java/JPropEx.java b/transex3/java/jpropex/java/JPropEx.java deleted file mode 100644 index 20175febe5d5..000000000000 --- a/transex3/java/jpropex/java/JPropEx.java +++ /dev/null @@ -1,400 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -import java.util.*; -import java.io.*; - -public class JPropEx -{ - private String inputFileArg; - private String outputFileArg; - private String pathPrefixArg; - private String pathPostfixArg; - private String projectArg; - private String rootArg; - private Vector forcedLangsArg; - private Vector langsArg; - private String inputSdfFileArg; - private boolean isQuiet = false; - private final String resourceType = "javaproperties"; - private final String sourceLanguage = "en-US"; - //private SdfData data; - - public JPropEx() - { - //data = new SdfData(); - } - - public JPropEx( String args[] ) - { - super(); - parseArguments( args ); - testArguments(); - if( inputSdfFileArg != null && inputSdfFileArg.length() > 0 ) - merge(); - else - extract(); - } - - private String getSimpleArg( String[] args , int x ) - { - if( x < args.length ) x++; - else - { - System.err.println("ERROR: Missing arg for "+args[ x ]+"\n"); - help(); - } - return args[ x ]; - } - private Vector getComplexArg( String[] args , int x ) - { - if( x < args.length ) x++; - else - { - System.err.println("ERROR: Missing arg for "+args[ x ]+"\n"); - help(); - } - String value = args[ x ]; - Vector values = new Vector( Arrays.asList( value.split(",") ) ); - return values; - } - - private void help() - { - System.out.println("jpropex extract / merge java properties files"); - System.exit( -1 ); - } - - private void extract() - { - SdfData data = new SdfData(); - java.util.Properties prop = loadProp( inputFileArg ); - - // Get a prototype that already contains the most common settings - SdfEntity dolly = prepareSdfObj(); - String key; - SdfEntity currentStr; - String value; - for( Enumeration e = prop.propertyNames() ; e.hasMoreElements() ; ) - { - key = (String) e.nextElement(); - currentStr = (SdfEntity) dolly.clone(); - // Set the new LID and the string text - currentStr.setLid( key ); - value = prop.getProperty( key , "" ); - //if( value.equals("") ) System.err.println("Warning: in file "+inputFileArg+" the string with the key "+key+" has a empty string!"); - currentStr.setText( (prop.getProperty( key )).replaceAll("\t" , " " ) ); // TODO: Quoting!!!! - data.add( currentStr ); - } - data.write( outputFileArg ); - } - - private SdfEntity prepareSdfObj() - { - String path = makeAbs( inputFileArg ); - path = path.replace( rootArg + "/" , "" ); - path = path.replace("/","\\"); - return new SdfEntity( projectArg , path , "" /* dummy1 */ , resourceType , "", "" , "" , "" , "" /* dummy2 */ , - sourceLanguage , "", "" , "" , "" , "2002-02-02 02:02:02" ); - } - - private void merge() - { - SdfData data = getSdfData(); - if( inputFileArg.startsWith("@") ) - { - // Read files - Vector fileList = readFileList( inputFileArg ); - for( Enumeration e = fileList.elements(); e.hasMoreElements(); ) - mergeFile( (String) e.nextElement() , data ); - } - else - { - // Single file - mergeFile( inputFileArg , data ); - } - } - - private Vector readFileList( String filename ) - { - Vector lines = new Vector(); - try - { - BufferedReader in = new BufferedReader( new FileReader( filename.substring( 1 ) ) ); - while( in.ready() ) - lines.add( in.readLine() ); - } - catch( IOException e ) - { - System.out.println("ERROR: Can't open file '"+filename.substring( 1 )+"'"); - System.exit( -1 ); - } - return lines; - } - - private void mergeFile( String filename , SdfData data ) - { - java.util.Properties sourceProp = loadProp( filename ); - Vector langs = getLanguages( data ); - HashMap props = new HashMap(); - // Create a properties object for every language - for( Enumeration e = langs.elements(); e.hasMoreElements();) - { - - props.put( (String)e.nextElement() , new java.util.Properties() ); - } - // Get a prototype that already contains the most common settings - - SdfEntity dolly = prepareSdfObj(); - String key; - String sourceString; - SdfEntity curStr; - SdfEntity curEntity; - SdfEntity mergedEntity; - String curLang; - for( Enumeration e = sourceProp.propertyNames() ; e.hasMoreElements() ; ) // For all property keys - { - key = (String) e.nextElement(); - sourceString = sourceProp.getProperty( key ); - curStr = (SdfEntity) dolly.clone(); - curStr.setLid( key ); - for( Enumeration lang = langs.elements(); lang.hasMoreElements(); ) // merge in every language - { - curEntity = (SdfEntity) curStr.clone(); - curLang = (String) lang.nextElement(); - curEntity.setLangid( curLang ); - mergedEntity = data.get( curEntity ); - if( mergedEntity == null ) - { - // if case there is not translation the fallback to the en-US source string - ( (java.util.Properties) props.get( curLang )).setProperty( curEntity.getLid() , sourceString ); - } - else - { - // Set the merged text from the sdf file - ( (java.util.Properties) props.get( curLang )).setProperty( mergedEntity.getLid() , mergedEntity.getText() ); // TODO: Quoting ??? - } - } - - } - // Now write them out - String lang; - for( Iterator i = props.keySet().iterator() ; i.hasNext() ; ) - { - lang = (String) i.next(); - writeSinglePropertiesFile( filename , (java.util.Properties) props.get( lang ) , lang ); - } - } - private void writeSinglePropertiesFile( String filename , java.util.Properties prop , String lang ) - { - // Prepare path to file - int filenameIdx = filename.lastIndexOf( "/" ) > 0 ? filename.lastIndexOf( "/" )+1 : 0 ; - String path = new String(); - String name = new String(); - if( pathPrefixArg != null && pathPrefixArg.length()>0 && pathPostfixArg != null && pathPostfixArg.length()>0 ) - { - path = new StringBuffer().append( pathPrefixArg ).append( "/" ).append( lang ).append( "/" ).append( pathPostfixArg ).append( "/" ).toString(); - name = new StringBuffer().append( filename.substring( filenameIdx , filename.lastIndexOf( ".properties" ) ) ) - .append( "_" ).append( lang.replaceAll("-","_") ).append( ".properties" ).toString(); - } - else if( outputFileArg != null && outputFileArg.length()>0 ) - { - name = outputFileArg; - name += new StringBuffer().append( inputFileArg.substring( filenameIdx , filename.lastIndexOf( ".properties" ) ) ) - .append( "_" ).append( lang.replaceAll("-","_") ).append( ".properties" ).toString(); - - //name = outputFileArg; - } - else - { - System.err.println("ERROR: No outputfile specified .. either -o or -x -y !"); - System.exit( -1 ); - } - - File dir = new File( path ); - try - { - if( !dir.exists() && path.length()>0 ) - { - if( !dir.mkdirs() ) - { - System.out.println("ERROR: Can't create directory '"+path+"' !!!"); - System.exit( -1 ); - } - } - } - catch( SecurityException e ) - { - System.out.println("ERROR: Can't create directory '"+path+"'!!!Wrong Permissions?"); - System.exit( -1 ); - } - path += name; - // Write the properties file - System.out.println("DBG: Writing to "+path); - try{ - BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream( path ) ); - if( prop == null ) - System.out.println("DBG: prop == null!!!"); - prop.store( out , "" ); // Legal headers? - } - catch( IOException e ) - { - System.out.println("ERROR: Can't write file '"+path+"' !!!!"); - System.exit( -1 ); - } - } - - private SdfData getSdfData() - { - SdfData data = new SdfData( inputSdfFileArg ); - data.read(); - return data; - } - private Vector getLanguages( SdfData data ) - { - Vector langs = new Vector(); - - if( ((String)langsArg.get( 0 )).equalsIgnoreCase( "all" ) ) // for "-l all" use all languages found in the -m sdf file - langs.addAll( data.getLanguages() ); - else - langs.addAll( langsArg ); // use the langs giving by -l - - if( forcedLangsArg != null ) - langs.addAll( forcedLangsArg ); - - return removeDupes( langs ); - } - private Vector removeDupes( Vector vec ) - { - Collection coll = new LinkedHashSet( vec ); - return new Vector( coll ); - } - private java.util.Properties loadProp( String filename ) - { - java.util.Properties prop = new java.util.Properties(); - try - { - prop.load( new BufferedInputStream( new NoLocalizeFilter( new FileInputStream( filename ) ) ) ); - } - catch( IOException e ) - { - System.err.println("ERROR: Can't read file '"+filename+"'!!!"); - } - return prop; - } - private void parseArguments( String[] args ) - { - - if( args.length == 0 ) - { - System.out.println("ERROR: No args???"); - help(); - System.exit( -1 ); - } - for( int x = 0; x < args.length ; x++ ) - { - if( args[ x ].equalsIgnoreCase("-i") ) - { - // Input resource file - inputFileArg = getSimpleArg( args , x ); - } - else if( args[ x ].equalsIgnoreCase("-o") ) - { - // Output sdf file - outputFileArg = getSimpleArg( args , x ); - } - else if( args[ x ].equalsIgnoreCase("-x") ) - { - // path prefix - pathPrefixArg = getSimpleArg( args , x ); - } - else if( args[ x ].equalsIgnoreCase("-y") ) - { - // path postfix - pathPostfixArg = getSimpleArg( args , x ); - } - else if( args[ x ].equalsIgnoreCase("-p") ) - { - // project - projectArg = getSimpleArg( args , x ); - } - else if( args[ x ].equalsIgnoreCase("-r") ) - { - // root - rootArg = getSimpleArg( args , x ); - rootArg = makeAbs( rootArg ); - } - else if( args[ x ].equalsIgnoreCase("-lf") ) - { - // forced langs - forcedLangsArg = getComplexArg( args , x ); - } - else if( args[ x ].equalsIgnoreCase("-l") ) - { - // langs - langsArg = getComplexArg( args , x ); - } - else if( args[ x ].equalsIgnoreCase("-m") ) - { - // input sdf file - inputSdfFileArg = getSimpleArg( args , x ); - } - else if( args[ x ].equalsIgnoreCase("-qq") ) - { - isQuiet = true; - } - } - } - private String makeAbs( String path ) - { - File file; - try - { - file = new File( path ); - return file.getCanonicalPath(); - }catch( IOException e ) - { - e.printStackTrace(); - System.exit( -1 ); - } - return null; - } - private boolean testArguments() - { - // nice merge - if( inputSdfFileArg != null && inputSdfFileArg.length()>0 ) - // nice merge - return projectArg != null && rootArg != null && inputFileArg != null && pathPrefixArg != null && pathPostfixArg != null && langsArg != null && - projectArg.length()>0 && rootArg.length()>0 && inputFileArg.length()>0 && pathPrefixArg.length()>0 && pathPostfixArg.length()>0 && langsArg.size()>0 ; - else - // nice extract - return projectArg != null && rootArg != null && inputFileArg != null && outputFileArg != null && langsArg != null && - projectArg.length()>0 && rootArg.length()>0 && inputFileArg.length()>0 && outputFileArg.length()>0 && langsArg.size()>0; - } - -} diff --git a/transex3/java/jpropex/java/Main.java b/transex3/java/jpropex/java/Main.java deleted file mode 100644 index 23dc477ddec3..000000000000 --- a/transex3/java/jpropex/java/Main.java +++ /dev/null @@ -1,38 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -class Main -{ - - public static void main( String args[] ) - { - JPropEx jpropex = new JPropEx( args ); - //jpropex.init(); - } -} - diff --git a/transex3/java/jpropex/java/NoLocalizeFilter.java b/transex3/java/jpropex/java/NoLocalizeFilter.java deleted file mode 100644 index c1e62fc951a8..000000000000 --- a/transex3/java/jpropex/java/NoLocalizeFilter.java +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -import java.io.*; -import java.util.regex.*; - -// exit if the sequence x-no-localize is found in stream! -public class NoLocalizeFilter extends FilterInputStream -{ - InputStream in; -// Pattern p = Pattern.compile("[\\s]*#[\\s]*x-no-translate"); - - public NoLocalizeFilter( InputStream in ) { - super(in); - this.in = in; - } - public int read(byte[] b, int off, int len) throws IOException - { - String search = new String( b ); -// Matcher m = p.matcher( search ); - if( search.contains("x-no-translate" ) ) // TODO: fixme! - { -// System.out.println("found x-no-translate"); - in.close(); - close(); - System.exit( 0 ); - } - return in.read( b , off , len ); - } -} diff --git a/transex3/java/jpropex/java/OrderedHashMap.java b/transex3/java/jpropex/java/OrderedHashMap.java deleted file mode 100644 index a462d598b307..000000000000 --- a/transex3/java/jpropex/java/OrderedHashMap.java +++ /dev/null @@ -1,96 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -import java.util.*; - -// LinkedHashMap implrementation -public class OrderedHashMap -{ - private HashMap hm = new HashMap(); - private LinkedList list = new LinkedList(); - - public Iterator iterator() { return list.iterator(); } - - public boolean isEmpty() { return hm.isEmpty(); } - public Object get( Object key ) { return hm.get( key ); } - public Object get( int index ) { return hm.get( list.get( index ) ); } - public Iterator keys() { return list.iterator(); } - public Object add( Object key , Object value ) - { - list.add( key ); - return hm.put( key, value ); - } - public Object add( int index , Object key , Object value ) - { - list.add( index , key ); - return hm.put( key, value ); - } - public Object remove( Object key ) - { - list.remove( list.indexOf( key ) ); - return hm.remove( key ); - } - public void move( int idxFrom , int idxTo ) - { - Object key = list.get( idxFrom ); - list.remove( idxFrom ); - list.add( idxTo , key ); - } - public void move( Object key , int idxTo ) - { - move( list.indexOf( key ) , idxTo ); - } - public int size() - { - return hm.size(); - } - public Enumeration elements() - { - return new OHMenum( this ); - } -} - -final class OHMenum implements Enumeration -{ - OrderedHashMap ohm; - int index = 0; - - private OHMenum(){}; - public OHMenum( OrderedHashMap ohm ){ - this.ohm = ohm ; - } - - public boolean hasMoreElements() - { - return index < ohm.size(); - } - public Object nextElement() - { - return ohm.get( index++ ); - } -} diff --git a/transex3/java/jpropex/java/SdfData.java b/transex3/java/jpropex/java/SdfData.java deleted file mode 100644 index 60f218c0ae15..000000000000 --- a/transex3/java/jpropex/java/SdfData.java +++ /dev/null @@ -1,108 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -import java.util.*; -import java.io.*; - -public class SdfData -{ - private String filename; - private OrderedHashMap ohm; - private LinkedHashSet languagesFound; - - public SdfData() - { - languagesFound = new LinkedHashSet(); - ohm = new OrderedHashMap(); - languagesFound = new LinkedHashSet(); - } - public SdfData( String filename ){ - this(); - this.filename = filename; - } - - public LinkedHashSet getLanguages() - { - return languagesFound; - } - public SdfEntity get( SdfEntity obj ) - { - return (SdfEntity) ohm.get( (String)obj.getId() ); - } - public SdfEntity get( String key ){ - return (SdfEntity) ohm.get( key ); - } - public void add( SdfEntity obj ) - { - ohm.add( obj.getId() , obj ); - } - - public void read() - { - BufferedReader in; - try - { - in = new BufferedReader( new FileReader( filename ) ); - SdfEntity entity; - while( in.ready() ) - { - String line = in.readLine(); - if( line.length() > 0 ) - { - entity = new SdfEntity( line ); - ohm.add( entity.getId() , entity ); // test if is valid - languagesFound.add( entity.getLangid() ); - } - } - in.close(); - } - catch( IOException e ) - { - System.out.println("Error: reading file " + filename); - System.exit( -1 ); - } - } - public void write( String filename ) - { - FileWriter out; - try - { - out = new FileWriter( filename , true ); // Always append - for( Enumeration e = ohm.elements(); e.hasMoreElements(); ) - { - out.write( ( (SdfEntity) e.nextElement() ).toString() + "\n" ); - } - out.close(); - } - catch( IOException e ) - { - System.out.println("Error: Can't write to file " + filename); - System.exit( -1 ); - } - } -} diff --git a/transex3/java/jpropex/java/SdfEntity.java b/transex3/java/jpropex/java/SdfEntity.java deleted file mode 100644 index e2c1606ee7c2..000000000000 --- a/transex3/java/jpropex/java/SdfEntity.java +++ /dev/null @@ -1,254 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -public class SdfEntity implements Cloneable{ - private String project = new String(""); - private String source_file = new String(""); - private String dummy1 = new String(""); - private String resource_type= new String(""); - private String gid = new String(""); - private String lid = new String(""); - private String helpid = new String(""); - private String platform = new String(""); - private String dummy2 = new String(""); - private String langid = new String(""); - private String text = new String(""); - private String helptext = new String(""); - private String quickhelptext= new String(""); - private String title = new String(""); - private String date = new String(""); - - public static int PROJECT_POS = 0; - public static int SOURCE_FILE_POS = 1; - public static int DUMMY1_POS = 2; - public static int RESOURCE_TYPE_POS = 3; - public static int GID_POS = 4; - public static int LID_POS = 5; - public static int HELPID_POS = 6; - public static int PLATFORM_POS = 7; - public static int DUMMY2_POS = 8; - public static int LANGID_POS = 9; - public static int TEXT_POS = 10; - public static int HELPTEXT_POS = 11; - public static int QUICKHELPTEXT_POS = 12; - public static int TITLE_POS = 13; - public static int DATE_POS = 14; - - public Object clone() - { - try - { - return super.clone(); - } - catch( CloneNotSupportedException e ) - { - System.out.println("ERROR: Can not clone, soemthing is broken here ...."); - System.exit( -1 ); - } - return null; // dummy - } - - public SdfEntity( String line ){ - // isValid? - setProperties( line ) ; - } - public SdfEntity(String project, String source_file, String dummy1, String resource_type, String gid, String lid, String helpid, String platform, String dummy2, String langid, String text, String helptext, String quickhelptext, String title , String date) { - super(); - this.project = project; - this.source_file = source_file; - this.dummy1 = dummy1; - this.resource_type = resource_type; - this.gid = gid; - this.lid = lid; - this.helpid = helpid; - this.platform = platform; - this.dummy2 = dummy2; - this.langid = langid; - this.text = text; - this.helptext = helptext; - this.quickhelptext = quickhelptext; - this.title = title; - this.date = date; - } - - public void setProperties( String line ){ - - String[] splitted = line.split("\t"); - - setProject( splitted[ SdfEntity.PROJECT_POS ] ); - setSource_file( splitted[ SdfEntity.SOURCE_FILE_POS ] ); - setDummy1( splitted[ SdfEntity.DUMMY1_POS ] ); - setResource_type( splitted[ SdfEntity.RESOURCE_TYPE_POS ] ); - setGid( splitted[ SdfEntity.GID_POS ] ); - setLid( splitted[ SdfEntity.LID_POS ] ); - setHelpid( splitted[ SdfEntity.HELPID_POS ] ); - setPlatform( splitted[ SdfEntity.PLATFORM_POS ] ); - setDummy2( splitted[ SdfEntity.DUMMY2_POS ] ); - setLangid( splitted[ SdfEntity.LANGID_POS ] ); - setText( splitted[ SdfEntity.TEXT_POS ] ); - setHelptext( splitted[ SdfEntity.HELPTEXT_POS ] ); - setQuickhelptext( splitted[ SdfEntity.QUICKHELPTEXT_POS ] ); - setTitle( splitted[ SdfEntity.TITLE_POS ] ); - setDate( splitted[ SdfEntity.DATE_POS ] ); - } - - public String getFileId(){ - return project+"\\"+source_file; - } - public String getResourcePath(){ - return source_file.substring(0 , source_file.lastIndexOf( "\\" )-1 ); - } - public String toString(){ - return project+"\t"+source_file+"\t"+dummy1+"\t"+resource_type+"\t"+gid+"\t" - +lid+"\t"+helpid+"\t"+platform+"\t"+dummy2+"\t"+langid+"\t" - +text+"\t"+helptext+"\t"+quickhelptext+"\t"+title+"\t"+date; - } - public String getId(){ - return project+gid+lid+source_file+resource_type+platform+helpid; - } - - public String getDummy1() { - return dummy1; - } - - public void setDummy1(String dummy1) { - this.dummy1 = dummy1; - } - - public String getPlatform() { - return platform; - } - - public void setPlatform(String platform) { - this.platform = platform; - } - - public String getDummy2() { - return dummy2; - } - - public void setDummy2(String dummy2) { - this.dummy2 = dummy2; - } - - public String getGid() { - return gid; - } - - public void setGid(String gid) { - this.gid = gid; - } - - public String getHelpid() { - return helpid; - } - - public void setHelpid(String helpid) { - this.helpid = helpid; - } - - public String getHelptext() { - return helptext; - } - - public void setHelptext(String helptext) { - this.helptext = helptext; - } - - public String getLangid() { - return langid; - } - - public void setLangid(String langid) { - this.langid = langid; - } - - public String getLid() { - return lid; - } - - public void setLid(String lid) { - this.lid = lid; - } - - public String getProject() { - return project; - } - - public void setProject(String project) { - this.project = project; - } - - public String getQuickhelptext() { - return quickhelptext; - } - - public void setQuickhelptext(String quickhelptext) { - this.quickhelptext = quickhelptext; - } - - public String getResource_type() { - return resource_type; - } - - public void setResource_type(String resource_type) { - this.resource_type = resource_type; - } - - public String getSource_file() { - return source_file; - } - - public void setSource_file(String source_file) { - this.source_file = source_file; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - public String getDate() { - return date; - } - public void setDate(String date) { - this.date = date; - } - - -} diff --git a/transex3/java/jpropex/jpropex b/transex3/java/jpropex/jpropex deleted file mode 100755 index 2d62d13b093e..000000000000 --- a/transex3/java/jpropex/jpropex +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -if [ x${SOLARENV}x = xx ]; then - echo No environment found, please use 'configure' or 'setsolar' - exit 1 -fi -if [ x${JAVA_HOME}x = xx ]; then - echo No Java found! - exit 1 -fi -exec java -DSOLARSRC=${SOLARSRC} -DWORK_STAMP=${WORK_STAMP} -DUSE_SHELL= -jar ${SOLARVER}/${INPATH}/bin${UPDMINOREXT}/jpropex.jar "$@" diff --git a/transex3/java/jpropex/jpropex.MF b/transex3/java/jpropex/jpropex.MF deleted file mode 100755 index 3e22e7e9bfbf..000000000000 --- a/transex3/java/jpropex/jpropex.MF +++ /dev/null @@ -1 +0,0 @@ -Main-Class: Main diff --git a/transex3/java/jpropex/makefile.mk b/transex3/java/jpropex/makefile.mk deleted file mode 100755 index f86d2c830025..000000000000 --- a/transex3/java/jpropex/makefile.mk +++ /dev/null @@ -1,36 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - - -PRJ=../.. -PRJNAME=transex3 -TARGET=jpropex - -.INCLUDE : ant.mk - -ALLTAR : ANTBUILD - -- cgit v1.2.3 From 5ddf16d8358a38c0098d3060dcee90c518f0dd85 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Thu, 22 Jul 2010 17:13:19 +0200 Subject: txtl10n: #i113008# #i113125# cleanup / removed unused lines --- l10ntools/scripts/xhtex | 8 -------- l10ntools/scripts/xtxex | 8 -------- 2 files changed, 16 deletions(-) diff --git a/l10ntools/scripts/xhtex b/l10ntools/scripts/xhtex index e6f7cf9f2003..659cd06e16d4 100755 --- a/l10ntools/scripts/xhtex +++ b/l10ntools/scripts/xhtex @@ -31,14 +31,6 @@ if [ x${SOLARENV}x = xx ]; then exit 1 fi -# localize.pl calls localize_sl in solver bin directory which depends on dynamic -# libraries in solver lib directory but has no correct RPATH (or equivalent): -if [ "${OS?}" = MACOSX ]; then - export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH+${DYLD_LIBRARY_PATH}:}${SOLARVERSION?}/${INPATH?}/lib${UPDMINOREXT} -else - export LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${SOLARVERSION?}/${INPATH?}/lib${UPDMINOREXT} -fi - if [ x${SOLARVER}x = xx -o x${UPDMINOREXT}x = xx ]; then exec python $SOLARVERSION/$INPATH/bin/xhtex.py "$@" else diff --git a/l10ntools/scripts/xtxex b/l10ntools/scripts/xtxex index cc9dac01fca2..28529506e3a2 100755 --- a/l10ntools/scripts/xtxex +++ b/l10ntools/scripts/xtxex @@ -31,14 +31,6 @@ if [ x${SOLARENV}x = xx ]; then exit 1 fi -# localize.pl calls localize_sl in solver bin directory which depends on dynamic -# libraries in solver lib directory but has no correct RPATH (or equivalent): -if [ "${OS?}" = MACOSX ]; then - export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH+${DYLD_LIBRARY_PATH}:}${SOLARVERSION?}/${INPATH?}/lib${UPDMINOREXT} -else - export LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${SOLARVERSION?}/${INPATH?}/lib${UPDMINOREXT} -fi - if [ x${SOLARVER}x = xx -o x${UPDMINOREXT}x = xx ]; then exec python $SOLARVERSION/$INPATH/bin/xtxex.py "$@" else -- cgit v1.2.3 From 3a7826b9ff0ddcfc9032c5ef707f754ae4abd3d2 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Thu, 22 Jul 2010 17:53:11 +0200 Subject: txtl10n: cleanup / remove all -QQ and quiet parts --- l10ntools/inc/lngmerge.hxx | 2 +- l10ntools/source/cfglex.l | 1 - l10ntools/source/cfgmerge.cxx | 9 --------- l10ntools/source/export.cxx | 11 ----------- l10ntools/source/helpex.cxx | 8 +------- l10ntools/source/lngex.cxx | 10 +--------- l10ntools/source/lngmerge.cxx | 5 ++--- l10ntools/source/localize.cxx | 38 +++++++++----------------------------- l10ntools/source/xrmmerge.cxx | 9 --------- 9 files changed, 14 insertions(+), 79 deletions(-) diff --git a/l10ntools/inc/lngmerge.hxx b/l10ntools/inc/lngmerge.hxx index 923da89988b6..843d1a6de3d2 100644 --- a/l10ntools/inc/lngmerge.hxx +++ b/l10ntools/inc/lngmerge.hxx @@ -58,7 +58,7 @@ private: const ByteString &rPrj , const ByteString &rRoot , const ByteString &sActFileName , const ByteString &sID ); public: - LngParser( const ByteString &rLngFile, BOOL bUTF8, BOOL bULFFormat, bool bQuiet_in ); + LngParser( const ByteString &rLngFile, BOOL bUTF8, BOOL bULFFormat ); ~LngParser(); BOOL CreateSDF( const ByteString &rSDFFile, const ByteString &rPrj, const ByteString &rRoot ); diff --git a/l10ntools/source/cfglex.l b/l10ntools/source/cfglex.l index d1b076d493b9..3fc3aa5b965c 100644 --- a/l10ntools/source/cfglex.l +++ b/l10ntools/source/cfglex.l @@ -177,7 +177,6 @@ main( int argc, char* argv[]) fprintf( stdout, " FileIn: Source files (*.src)\n" ); fprintf( stdout, " FileOut: Destination file (*.*)\n" ); fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" ); - fprintf( stdout, " -QQ: quiet output\n" ); fprintf( stdout, " -e: Disable writing errorlog\n" ); fprintf( stdout, " -b: Break when Token \"HelpText\" found in source\n" ); fprintf( stdout, " -u: [english] and [german] are allowed, Id is Taken from DataBase \n" ); diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx index 3e421d2d1046..e8feee1fe3c8 100644 --- a/l10ntools/source/cfgmerge.cxx +++ b/l10ntools/source/cfgmerge.cxx @@ -59,7 +59,6 @@ BOOL bMergeMode; BOOL bErrorLog; BOOL bForce; BOOL bUTF8; -bool bQuiet; ByteString sPrj; ByteString sPrjRoot; ByteString sInputFileName; @@ -83,7 +82,6 @@ extern char *GetOutputFile( int argc, char* argv[]) bErrorLog = TRUE; bForce = FALSE; bUTF8 = TRUE; - bQuiet = false; sPrj = ""; sPrjRoot = ""; sInputFileName = ""; @@ -128,9 +126,6 @@ extern char *GetOutputFile( int argc, char* argv[]) nState = STATE_FORCE; bForce = TRUE; } - else if ( sSwitch == "-QQ" ) { - bQuiet = true; - } else if ( sSwitch == "-L" ) { nState = STATE_LANGUAGES; } @@ -184,10 +179,6 @@ extern char *GetOutputFile( int argc, char* argv[]) // command line is not valid return NULL; } -int isQuiet(){ - if( bQuiet ) return 1; - else return 0; -} /*****************************************************************************/ int InitCfgExport( char *pOutput , char* pFilename ) /*****************************************************************************/ diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index 589c962c112c..d6c7a9533309 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -62,7 +62,6 @@ BOOL bErrorLog; BOOL bBreakWhenHelpText; BOOL bUnmerge; BOOL bUTF8; -bool bQuiet; ByteString sPrj; ByteString sPrjRoot; ByteString sActFileName; @@ -98,7 +97,6 @@ extern char *GetOutputFile( int argc, char* argv[]) Export::sForcedLanguages = ""; sTempFile = ""; pTempFile = NULL; - bQuiet = false; USHORT nState = STATE_NON; BOOL bInput = FALSE; @@ -115,9 +113,6 @@ extern char *GetOutputFile( int argc, char* argv[]) else if (sSwitch == "-p" || sSwitch == "-P" ) { nState = STATE_PRJ; // next token specifies the cur. project } - else if (sSwitch == "-qq" || sSwitch == "-QQ" ) { - bQuiet = true; - } else if (sSwitch == "-r" || sSwitch == "-R" ) { nState = STATE_ROOT; // next token specifies path to project root @@ -196,12 +191,6 @@ extern char *GetOutputFile( int argc, char* argv[]) return NULL; } /*****************************************************************************/ -int isQuiet(){ -/*****************************************************************************/ - if( bQuiet ) return 1; - else return 0; -} -/*****************************************************************************/ int InitExport( char *pOutput , char* pFilename ) /*****************************************************************************/ { diff --git a/l10ntools/source/helpex.cxx b/l10ntools/source/helpex.cxx index 49a59266a85d..15239db5d9bd 100644 --- a/l10ntools/source/helpex.cxx +++ b/l10ntools/source/helpex.cxx @@ -61,7 +61,6 @@ ByteString sOutputFile; ByteString sOutputFileX; ByteString sOutputFileY; ByteString sSDFFile; -bool bQuiet; /*****************************************************************************/ BOOL ParseCommandLine( int argc, char* argv[]) @@ -73,7 +72,6 @@ BOOL ParseCommandLine( int argc, char* argv[]) bUTF8 = TRUE; sPrj = ""; sPrjRoot = ""; - bQuiet = false; Export::sLanguages = ""; Export::sForcedLanguages = ""; @@ -111,9 +109,6 @@ BOOL ParseCommandLine( int argc, char* argv[]) nState = STATE_ERRORLOG; bErrorLog = FALSE; } - else if ( ByteString( argv[ i ] ).ToUpperAscii() == "-QQ" ) { - bQuiet = true; - } else if ( ByteString( argv[ i ]).ToUpperAscii() == "-UTF8" ) { nState = STATE_UTF8; bUTF8 = TRUE; @@ -188,13 +183,12 @@ BOOL ParseCommandLine( int argc, char* argv[]) void Help() /*****************************************************************************/ { - fprintf( stdout, "Syntax: HELPEX[-p Prj][-r PrjRoot]-i FileIn ( -o FileOut | -x path -y relfile )[-m DataBase][-e][-b][-u][-L l1,l2,...][-QQ] -LF l1,l2 \n" ); + fprintf( stdout, "Syntax: HELPEX[-p Prj][-r PrjRoot]-i FileIn ( -o FileOut | -x path -y relfile )[-m DataBase][-e][-b][-u][-L l1,l2,...] -LF l1,l2 \n" ); fprintf( stdout, " Prj: Project\n" ); fprintf( stdout, " PrjRoot: Path to project root (..\\.. etc.)\n" ); fprintf( stdout, " FileIn: Source file (*.lng)\n" ); fprintf( stdout, " FileOut: Destination file (*.*)\n" ); fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" ); - fprintf( stdout, " -QQ: quiet output\n" ); fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (en-US,fr,de...)\n" ); fprintf( stdout, " A fallback language can be defined like this: l1=f1.\n" ); fprintf( stdout, " f1, f2,... are also elements of (en-US,fr,de...)\n" ); diff --git a/l10ntools/source/lngex.cxx b/l10ntools/source/lngex.cxx index 27136dc8797f..4ec069a810f5 100644 --- a/l10ntools/source/lngex.cxx +++ b/l10ntools/source/lngex.cxx @@ -53,7 +53,6 @@ BOOL bMergeMode; BOOL bErrorLog; BOOL bUTF8; BOOL bULF; // ULF = Unicode Language File -bool bQuiet; ByteString sPrj; ByteString sPrjRoot; ByteString sOutputFile; @@ -68,7 +67,6 @@ BOOL ParseCommandLine( int argc, char* argv[]) bErrorLog = TRUE; bUTF8 = TRUE; bULF = FALSE; - bQuiet = false; sPrj = ""; sPrjRoot = ""; Export::sLanguages = ""; @@ -92,9 +90,6 @@ BOOL ParseCommandLine( int argc, char* argv[]) else if ( sSwitch == "-R" ) { nState = STATE_ROOT; // next token specifies path to project root } - else if ( sSwitch == "-QQ" ) { - bQuiet = true; - } else if ( sSwitch == "-M" ) { nState = STATE_MERGESRC; // next token specifies the merge database } @@ -176,9 +171,6 @@ void Help() fprintf( stdout, " FileIn: Source file (*.lng)\n" ); fprintf( stdout, " FileOut: Destination file (*.*)\n" ); fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" ); - fprintf( stdout, " -QQ: quite output\n" ); - //fprintf( stdout, " -NOUTF8: disable UTF8 as language independent encoding\n" ); - //fprintf( stdout, " -ULF: enables Unicode Language File format, leads to UTF8 encoded version of lng files" ); fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" ); fprintf( stdout, " A fallback language can be defined like this: l1=f1.\n" ); fprintf( stdout, " f1, f2,... are also elements of (de,en-US...)\n" ); @@ -202,7 +194,7 @@ int _cdecl main( int argc, char *argv[] ) fflush( stdout ); if ( sOutputFile.Len()) { - LngParser aParser( sInputFile, bUTF8, bULF , bQuiet ); + LngParser aParser( sInputFile, bUTF8, bULF ); if ( bMergeMode ) aParser.Merge( sMergeSrc, sOutputFile , sPrj ); else diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index 5f40a4346f53..f0093bbccea7 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -38,15 +38,14 @@ using namespace std; // class LngParser // /*****************************************************************************/ -LngParser::LngParser( const ByteString &rLngFile, BOOL bUTF8, BOOL bULFFormat , bool bQuiet_in ) +LngParser::LngParser( const ByteString &rLngFile, BOOL bUTF8, BOOL bULFFormat ) /*****************************************************************************/ : nError( LNG_OK ), pLines( NULL ), sSource( rLngFile ), bDBIsUTF8( bUTF8 ), - bULF( bULFFormat ), - bQuiet( bQuiet_in ) + bULF( bULFFormat ) { pLines = new LngLineList( 100, 100 ); DirEntry aEntry( String( sSource, RTL_TEXTENCODING_ASCII_US )); diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index 853dcc97dc3e..bbc27dc229e7 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -134,7 +134,6 @@ private: ByteString sLanguageRestriction; ByteString sOutputFile; - bool bQuiet2; int nFileCnt; @@ -167,7 +166,7 @@ private: ); public: - SourceTreeLocalizer( const ByteString &rRoot, const ByteString &rVersion , bool bLocal , bool bQuiet2_in , bool skip_links ); + SourceTreeLocalizer( const ByteString &rRoot, const ByteString &rVersion , bool bLocal , bool skip_links ); ~SourceTreeLocalizer(); ByteString getSourceLanguages( ByteString sLanguageRestriction , ByteString sCommand ); @@ -183,11 +182,10 @@ public: /*****************************************************************************/ SourceTreeLocalizer::SourceTreeLocalizer( - const ByteString &rRoot, const ByteString &rVersion, bool bLocal_in , bool bQuiet2_in , bool skip_links ) + const ByteString &rRoot, const ByteString &rVersion, bool bLocal_in , bool skip_links ) /*****************************************************************************/ : SourceTreeIterator( rRoot, rVersion , bLocal_in ), nMode( LOCALIZE_NONE ), - bQuiet2( bQuiet2_in ), nFileCnt( 0 ) { bSkipLinks = skip_links ; @@ -323,9 +321,6 @@ void SourceTreeLocalizer::WorkOnFile( sCommand += getSourceLanguages( sLanguageRestriction , sCommand ); } - if( bQuiet2 ){ - //sCommand +=" -QQ "; - } //printf("DBG: %s\n",sCommand.GetBuffer()); if (system(sCommand.GetBuffer()) == -1) fprintf(stderr, "%s failed\n", sCommand.GetBuffer()); @@ -485,7 +480,6 @@ void SourceTreeLocalizer::OnExecuteDirectory( const rtl::OUString &aDirectory ) { ByteString rDirectory( rtl::OUStringToOString( aDirectory , RTL_TEXTENCODING_UTF8 , aDirectory.getLength() ) ) ; if ( nMode == LOCALIZE_NONE ){ - if( !bQuiet2 ) fprintf( stdout, "%s\n", rDirectory.GetBuffer()); } else WorkOnDirectory( rDirectory ); @@ -541,7 +535,6 @@ BOOL SourceTreeLocalizer::MergeSingleFile( ByteString sFile( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US ); ByteString sBCur( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US ); - if( !bQuiet2 ) fprintf( stdout, "##### %s #####\n", sBCur.GetBuffer()); ULONG nIndex = 0; ByteString sExtension( aEntry.GetExtension(), RTL_TEXTENCODING_ASCII_US ); @@ -589,9 +582,6 @@ BOOL SourceTreeLocalizer::MergeSingleFile( sCommand += " -l "; sCommand += sLanguageRestriction; } - if( bQuiet2 ){ - sCommand +=" -QQ "; - } DirEntry aPath( aEntry.GetPath()); DirEntry aOldCWD; @@ -601,7 +591,6 @@ BOOL SourceTreeLocalizer::MergeSingleFile( fprintf(stderr, "%s failed\n", sCommand.GetBuffer()); nFileCnt++; printf("."); - //if( bQuiet2 ){ printf("."); } SvFileStream aInStream( aOut.GetFull(), STREAM_READ ); if ( !aInStream.IsOpen()) { fprintf( stderr, @@ -792,12 +781,11 @@ void Help() fprintf( stdout, "As part of the L10N framework, localize extracts and merges translations\n" "out of and into the whole source tree.\n\n" - "Syntax: localize -e -l en-US -f FileName [-QQ]\n" + "Syntax: localize -e -l en-US -f FileName \n" "Parameter:\n" "\t-e: Extract mode\n" "\tFileName: Output file when extract mode, input file when merge mode\n" "\tl1...ln: supported languages (\"all\" for all languages).\n" - "\tQQ: quiet output)" ); fprintf( stdout, @@ -840,15 +828,12 @@ int _cdecl main( int argc, char *argv[] ) BOOL bExport = FALSE; BOOL bMerge = FALSE; - bool bQuiet = false; - bool bQuiet2 = false; bool bSkipLinks = false; ByteString sLanguages; ByteString sFileName; ByteString sOutput; - bQuiet2 = true; bExport = TRUE; for( int i = 1; i < argc; i++ ) { @@ -861,17 +846,12 @@ int _cdecl main( int argc, char *argv[] ) return Error(); bExport = TRUE; } - else if( sSwitch.Equals( "-Q" )) { - bQuiet = true; - } else if ( sSwitch.Equals( "-I" ) ) nState = STATE_ISOCODE; else if ( sSwitch.Equals( "-L" ) ) nState = STATE_LANGUAGES; else if ( sSwitch.Equals( "-F" ) ) nState = STATE_FILENAME; - else if ( sSwitch.Equals( "-QQ" )) - bQuiet2 = true; else if ( ByteString( argv[ i ]).ToUpperAscii().Equals( "-O" ) ) nState = STATE_OUTPUT; else { @@ -954,10 +934,10 @@ int _cdecl main( int argc, char *argv[] ) else curRepository = string( Export::GetEnv("SOURCE_ROOT_DIR") ) + "/" + *iter; cout << "Localizing repository " << curRepository << "\n"; - SourceTreeLocalizer aIter( ByteString( curRepository.c_str() ) , sVersion , (sOutput.Len() > 0) , bQuiet2 , bSkipLinks ); + SourceTreeLocalizer aIter( ByteString( curRepository.c_str() ) , sVersion , (sOutput.Len() > 0) , bSkipLinks ); aIter.SetLanguageRestriction( sLanguages ); if ( bExport ){ - if( bQuiet2 ){ /*printf("");*/fflush( stdout );} + fflush( stdout ); if( *iter == "ooo" ) aIter.Extract( sFileName ); else @@ -967,7 +947,7 @@ int _cdecl main( int argc, char *argv[] ) sFileNameWithExt += ByteString( (*iter).c_str() ); aIter.Extract( sFileNameWithExt ); } - if( bQuiet2 ){ printf("\n%d files found!\n",aIter.GetFileCnt());} + printf("\n%d files found!\n",aIter.GetFileCnt()); } } if( hasPwd ) @@ -975,12 +955,12 @@ int _cdecl main( int argc, char *argv[] ) string pwd; Export::getCurrentDir( pwd ); cout << "Localizing repository " << pwd << "\n"; - SourceTreeLocalizer aIter( ByteString( pwd.c_str() ) , sVersion , (sOutput.Len() > 0) , bQuiet2 , bSkipLinks ); + SourceTreeLocalizer aIter( ByteString( pwd.c_str() ) , sVersion , (sOutput.Len() > 0) , bSkipLinks ); aIter.SetLanguageRestriction( sLanguages ); if ( bExport ){ - if( bQuiet2 ){ /*printf("");*/fflush( stdout );} + fflush( stdout ); aIter.Extract( sFileName ); - if( bQuiet2 ){ printf("\n%d files found!\n",aIter.GetFileCnt());} + printf("\n%d files found!\n",aIter.GetFileCnt()); } } diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx index dc3d2fe6a283..fa7fdb4b4376 100644 --- a/l10ntools/source/xrmmerge.cxx +++ b/l10ntools/source/xrmmerge.cxx @@ -61,7 +61,6 @@ BOOL bEnableExport; BOOL bMergeMode; BOOL bErrorLog; BOOL bUTF8; -bool bQuiet; ByteString sPrj; ByteString sPrjRoot; ByteString sInputFileName; @@ -87,7 +86,6 @@ extern char *GetOutputFile( int argc, char* argv[]) sInputFileName = ""; sActFileName = ""; Export::sLanguages = ""; - bQuiet = false; USHORT nState = STATE_NON; BOOL bInput = FALSE; @@ -108,9 +106,6 @@ extern char *GetOutputFile( int argc, char* argv[]) else if ( ByteString( argv[ i ] ).ToUpperAscii() == "-M" ) { nState = STATE_MERGESRC; // next token specifies the merge database } - else if ( ByteString( argv[ i ] ).ToUpperAscii() == "-QQ" ) { - bQuiet = true; - } else if ( ByteString( argv[ i ] ).ToUpperAscii() == "-E" ) { nState = STATE_ERRORLOG; bErrorLog = FALSE; @@ -199,10 +194,6 @@ int InitXrmExport( char *pOutput , char* pFilename) return 1; } -int isQuiet(){ - if( bQuiet ) return 1; - else return 0; -} /*****************************************************************************/ int EndXrmExport() /*****************************************************************************/ -- cgit v1.2.3