You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ja...@apache.org on 2013/03/10 13:05:10 UTC
svn commit: r1454842 - /openoffice/branches/l10n/main/l10ntools/source/
Author: jani
Date: Sun Mar 10 12:05:10 2013
New Revision: 1454842
URL: http://svn.apache.org/r1454842
Log:
lex reader for po files ready, together with cmdLine cleanup
Modified:
openoffice/branches/l10n/main/l10ntools/source/gCon.cxx
openoffice/branches/l10n/main/l10ntools/source/gConDB.cxx
openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx
openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx
openoffice/branches/l10n/main/l10ntools/source/gConPolex.l
openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l
openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l
openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l
openoffice/branches/l10n/main/l10ntools/source/gConXculex.l
openoffice/branches/l10n/main/l10ntools/source/gConXhplex.l
openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l
openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx
openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx
openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx
openoffice/branches/l10n/main/l10ntools/source/gLang.hxx
Modified: openoffice/branches/l10n/main/l10ntools/source/gCon.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gCon.cxx?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gCon.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gCon.cxx Sun Mar 10 12:05:10 2013
@@ -59,7 +59,7 @@ convert_gen::convert_gen(l10nMem& cMemor
// did the user give a .xxx with the source file ?
int nInx = sSourceFile.rfind(".");
if (nInx == (int)std::string::npos)
- throw cMemory.showError("source file: "+sSourceFile+" missing extension");
+ throw l10nMem::showError("source file: "+sSourceFile+" missing extension");
// find correct conversion class and create correct object
std::string sExtension = sSourceFile.substr(nInx+1);
@@ -73,7 +73,7 @@ convert_gen::convert_gen(l10nMem& cMemor
else if (sExtension == "xhp") convert_gen_impl::mcImpl = new convert_xhp(cMemory);
else if (sExtension == "xrm") convert_gen_impl::mcImpl = new convert_xrm(cMemory);
else if (sExtension == "properties") convert_gen_impl::mcImpl = new convert_prop(cMemory);
- else throw cMemory.showError("unknown extension on source file: "+sSourceFile);
+ else throw l10nMem::showError("unknown extension on source file: "+sSourceFile);
// and set environment
convert_gen_impl::mcImpl->msSourceFile = sSourceFile;
@@ -190,9 +190,12 @@ bool convert_gen_impl::prepareFile(bool
if (!inputFile.is_open())
{
if (bAllowNoFile)
+ {
+ l10nMem::showWarning("Cannot open file (" + msSourcePath + ")");
return false;
+ }
else
- throw mcMemory.showError("Cannot open file (" + msSourcePath + ")");
+ throw l10nMem::showError("Cannot open file (" + msSourcePath + ")");
}
// get length of file:
@@ -204,7 +207,7 @@ bool convert_gen_impl::prepareFile(bool
// get size, prepare std::string and read whole file
inputFile.read((char *)msSourceBuffer.c_str(), msSourceBuffer.size());
if ((unsigned int)inputFile.gcount() != msSourceBuffer.size())
- throw mcMemory.showError("cannot read whole file");
+ throw l10nMem::showError("cannot read whole file");
inputFile.close();
return true;
}
@@ -247,7 +250,7 @@ void convert_gen_impl::writeSourceFile(c
if (!line.size())
return;
- throw mcMemory.showError("writeSourceFile not implemented");
+ throw l10nMem::showError("writeSourceFile not implemented");
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConDB.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConDB.cxx?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConDB.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConDB.cxx Sun Mar 10 12:05:10 2013
@@ -58,8 +58,8 @@ void convert_db::execute()
for (; (i = msFields[1].find('\\')) != std::string::npos;)
msFields[1][i] = '/';
- // handle en-US or lang
- mcMemory.loadENUSkey(miLineNo, msFields[1], newKey, msFields[10]);
+ // handle en_US or lang
+ mcMemory.loadEntryKey(miLineNo, msFields[1], newKey, msFields[10], msFields[10], false);
}
}
@@ -88,7 +88,7 @@ bool convert_db::collectLine()
{
if (i >= NUMFIELD)
{
- mcMemory.showError((char*)"TOO many fields", miLineNo);
+ l10nMem::showError((char*)"TOO many fields", miLineNo);
}
msFields[i++] = msSourceBuffer.substr(iStart, miSourceReadIndex - iStart);
iStart = miSourceReadIndex +1;
Modified: openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx Sun Mar 10 12:05:10 2013
@@ -21,6 +21,8 @@
#ifndef GCONPO_HXX
#define GCONPO_HXX
#include "gCon.hxx"
+#include <iostream>
+#include <fstream>
@@ -36,13 +38,26 @@
class convert_po : public convert_gen_impl
{
public:
+ bool mbExpectId;
+ bool mbExpectStr;
+
+
convert_po(l10nMem& crMemory);
~convert_po();
- void startCollectData(char *syyText);
- void stopCollectData(char *syyText);
+ void startLook (char *syyText);
+ void setValue (char *syyText);
+ void setFuzzy (char *syyText);
+ void setKey (char *syyText);
+ void setMsgId (char *syyText);
+ void setMsgStr (char *syyText);
private:
+ std::string msValue;
+ std::string msKey;
+ bool mbFuzzy;
+ std::filebuf outBuffer;
+
void execute();
void startSave(const std::string& sTargetDir,
Modified: openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx Sun Mar 10 12:05:10 2013
@@ -34,8 +34,20 @@
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
-convert_po::convert_po(l10nMem& crMemory) : convert_gen_impl(crMemory) {}
-convert_po::~convert_po() {}
+convert_po::convert_po(l10nMem& crMemory)
+ : convert_gen_impl(crMemory),
+ mbExpectId(false),
+ mbExpectStr(false),
+ mbFuzzy(false)
+{
+}
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+convert_po::~convert_po()
+{
+}
@@ -47,105 +59,149 @@ namespace PoWrap
#include "gConPo_yy.c"
}
-#if 0
- white-space
- # translator-comments
- #. extracted-comments
- #: reference...
- #, flag...
- #| msgid previous-untranslated-string
- msgid untranslated-string
- msgstr translated-string
-
- fuzzy
-
- #: lib/error.c:116
- msgid "Unknown system error"
- msgstr "Error desconegut del sistema"
-#endif
+
+
/********************** I M P L E M E N T A T I O N **********************/
-void convert_po::execute()
+void convert_po::startLook(char *syyText)
{
- PoWrap::yylex();
+ //JIX startLook
+ msKey.clear();
+ msValue.clear();
+ mbExpectId =
+ mbExpectStr = false;
}
-
-
+
+
/********************** I M P L E M E N T A T I O N **********************/
-void convert_po::startSave(const std::string& sTargetDir,
- const std::string& sLanguage,
- const std::string& sFile)
+void convert_po::setValue(char *syyText)
{
- std::string x;
+ int inx;
+
- x = sTargetDir;
- x = sLanguage;
- x = sFile;
+ // find terminating "
+ msValue = syyText;
+ for (inx = msValue.size(); msValue[--inx] != '\"';)
+ msValue.erase(inx);
}
/********************** I M P L E M E N T A T I O N **********************/
-void convert_po::save(const std::string& sKey,
- const std::string& sENUStext,
- const std::string& sText,
- bool bFuzzy)
+void convert_po::setFuzzy(char *syyText)
{
- std::string x;
+ std::string sText(syyText);
- x = sKey;
- x = sENUStext;
- x = sText;
- bFuzzy = bFuzzy;
+ mbFuzzy = true;
}
/********************** I M P L E M E N T A T I O N **********************/
-void convert_po::endSave()
+void convert_po::setKey(char *syyText)
{
+ int i;
+
+
+ // skip "#:" and any blanks
+ for (syyText += 2; *syyText == ' ' || *syyText == '\t';) ;
+ msKey = syyText;
+
+ // remove trailing blanks
+ for (i = msKey.size() -1; msKey[i] == ' ' || msKey[i] == '\t'; --i) ;
+ msKey.erase(i+1);
}
/********************** I M P L E M E N T A T I O N **********************/
-void convert_po::startCollectData(char *syyText)
+void convert_po::setMsgId(char *syyText)
{
- std::string sCollectedText = copySource(syyText);
+ std::string sText(syyText);
-// mbCollectingData = true;
+ mbExpectId = true;
}
/********************** I M P L E M E N T A T I O N **********************/
-void convert_po::stopCollectData(char *syyText)
+void convert_po::setMsgStr(char *syyText)
{
- std::string sCollectedText = copySource(syyText);
- std::string useKey;
+ std::string sText(syyText);
+ mbExpectStr = true;
+}
- if (mbMergeMode)
- {
-#if 0
- // get all languages (includes en-US)
- std::vector<l10nMem_entry *>& cExtraLangauges = mcMemory.getLanguagesForKey(useKey);
- std::string sNewLine;
- int nL = cExtraLangauges.size();
- writeSourceFile(msCollector + sCollectedText);
- for (int i = 0; i < nL; ++i)
- {
- sNewLine = "<value xml:lang=\"" + cExtraLangauges[i]->msLanguage + "\">" +
- cExtraLangauges[i]->msText + "</value>";
- writeSourceFile(sNewLine);
- }
-#endif
- }
- else
- mcMemory.setSourceKey(miLineNo, msSourceFile, useKey, sCollectedText);
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::execute()
+{
+ PoWrap::yylex();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::startSave(const std::string& sTargetDir,
+ const std::string& sLanguage,
+ const std::string& sFile)
+{
+ std::string sFilePath = sTargetDir + sLanguage + "/" + sFile;
+ outBuffer.open(sFilePath.c_str(), std::ios::out);
+
+ if (!outBuffer.is_open())
+ throw l10nMem::showError("Cannot open " + sFilePath + " for writing");
+
+ l10nMem::showDebug("writing file (" + sFilePath + ")");
+
+ std::ostream outFile(&outBuffer);
+
+ // Set license header
+ outFile << "#*************************************************************" << std::endl
+ << "#*" << std::endl
+ << "#* Licensed to the Apache Software Foundation (ASF) under one" << std::endl
+ << "#* or more contributor license agreements. See the NOTICE file" << std::endl
+ << "#* distributed with this work for additional information" << std::endl
+ << "#* regarding copyright ownership. The ASF licenses this file" << std::endl
+ << "#* to you under the Apache License, Version 2.0 (the" << std::endl
+ << "#* \"License\"); you may not use this file except in compliance" << std::endl
+ << "#* with the License. You may obtain a copy of the License at" << std::endl
+ << "#*" << std::endl
+ << "#* http://www.apache.org/licenses/LICENSE-2.0" << std::endl
+ << "#*" << std::endl
+ << "#* Unless required by applicable law or agreed to in writing," << std::endl
+ << "#* software distributed under the License is distributed on an" << std::endl
+ << "#* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY" << std::endl
+ << "#* KIND, either express or implied. See the License for the" << std::endl
+ << "#* specific language governing permissions and limitations" << std::endl
+ << "#* under the License." << std::endl
+ << "#*" << std::endl
+ << "#************************************************************" << std::endl
+ << std::endl;
+}
+
+
-// mbCollectingData = false;
- msCollector.clear();
-}
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::save(const std::string& sKey,
+ const std::string& sENUStext,
+ const std::string& sText,
+ bool bFuzzy)
+{
+ std::ostream outFile(&outBuffer);
+
+ outFile << std::endl << "#: " + sKey << std::endl;
+ if (bFuzzy)
+ outFile << "#, fuzzy" << std::endl;
+ outFile << "msgid \"" << sENUStext << "\"" << std::endl
+ << "msgstr \"" << sText << "\"" << std::endl;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::endSave()
+{
+ outBuffer.close();
+}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConPolex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPolex.l?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPolex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPolex.l Sun Mar 10 12:05:10 2013
@@ -27,6 +27,20 @@
* file is converted to gConPo_yy.cxx with "flex"
*****************************************************************************/
+/*
+ white-space
+ # translator-comments
+ #. extracted-comments
+ #: reference...
+ #, fuzzy
+ #| msgid previous-untranslated-string
+ msgid untranslated-string
+ msgstr translated-string
+
+ #: lib/error.c:116
+ msgid "Unknown system error"
+ msgstr "Error desconegut del sistema"
+*/
/*************** O V E R W R I T I N G F U N C T I O N S ***************/
@@ -55,21 +69,56 @@
%e 1200
%n 500
-
-
+/*********************** H E L P E R M A C R O S ***********************/
+SPACE [ \t]*
/******************* R U L E S D E F I N I T I O N S *******************/
%%
-
-"<value xml:lang=\""[^\"]*\"[^>]*">" {
- LOCptr->startCollectData(yytext);
+
+"\"".* {
+ LOCptr->setValue(&yytext[1]);
+}
+
+
+"#,"{SPACE}.*[fF][uU][zZ][zZ][yY] {
+ LOCptr->setFuzzy(yytext);
+}
+
+
+"#:".* {
+ LOCptr->setKey(yytext);
+}
+
+
+{SPACE}[mM][sS][gG][iI][dD]{SPACE} {
+ LOCptr->setMsgId(yytext);
}
+
-"</value>" {
- LOCptr->stopCollectData(yytext);
+{SPACE}[mM][sS][gG][sS][tT][rR]{SPACE} {
+ LOCptr->setMsgStr(yytext);
}
+
+<<EOF>> {
+ LOCptr->startLook(yytext);
+}
+
+
+\n\r*\n {
+ LOCptr->startLook(yytext);
+}
+
+
.|\n {
- IMPLptr->copySource(yytext);
}
%%
+
+
+
+void dummyJustForCompiler()
+{
+ char *txt = NULL;
+ yy_flex_strlen(txt);
+ yyunput(0, txt);
+}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l Sun Mar 10 12:05:10 2013
@@ -305,3 +305,12 @@ KEYID [a-zA-Z0-9_-]+
}
%%
+
+
+
+void dummyJustForCompiler()
+{
+ char *txt = NULL;
+ yy_flex_strlen(txt);
+ yyunput(0, txt);
+}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l Sun Mar 10 12:05:10 2013
@@ -112,3 +112,12 @@ KEYID [a-zA-Z0-9_-]+
IMPLptr->copySource(yytext);
}
%%
+
+
+
+void dummyJustForCompiler()
+{
+ char *txt = NULL;
+ yy_flex_strlen(txt);
+ yyunput(0, txt);
+}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l Sun Mar 10 12:05:10 2013
@@ -80,3 +80,12 @@
IMPLptr->copySource(yytext);
}
%%
+
+
+
+void dummyJustForCompiler()
+{
+ char *txt = NULL;
+ yy_flex_strlen(txt);
+ yyunput(0, txt);
+}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXculex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXculex.l?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXculex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXculex.l Sun Mar 10 12:05:10 2013
@@ -128,5 +128,13 @@ FIN [^/>]*">"
-
%%
+
+
+
+void dummyJustForCompiler()
+{
+ char *txt = NULL;
+ yy_flex_strlen(txt);
+ yyunput(0, txt);
+}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXhplex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXhplex.l?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXhplex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXhplex.l Sun Mar 10 12:05:10 2013
@@ -160,3 +160,12 @@ IDENT [\.a-zA-Z0-9_-]+
%%
+
+
+
+void dummyJustForCompiler()
+{
+ char *txt = NULL;
+ yy_flex_strlen(txt);
+ yyunput(0, txt);
+}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l Sun Mar 10 12:05:10 2013
@@ -102,3 +102,10 @@ SP [ \t]*
%%
+
+void dummyJustForCompiler()
+{
+ char *txt = NULL;
+ yy_flex_strlen(txt);
+ yyunput(0, txt);
+}
Modified: openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx Sun Mar 10 12:05:10 2013
@@ -82,19 +82,6 @@ void handler::checkCommandLine(int argc,
nLen = sLangText.size() -1;
if (nLen > 0 && sLangText[nLen] == '\"')
sLangText.erase(nLen);
- if (sLangText.size())
- {
- // and convert language to a vector
- int current;
- int next = -1;
- do
- {
- current = next + 1;
- next = sLangText.find_first_of( ",", current );
- mvLanguages.push_back(sLangText.substr(current,next-current));
- }
- while (next != (int)std::string::npos);
- }
// decode parameters and translate to variables
for (argNow = 5; argNow < argc;)
@@ -135,15 +122,45 @@ void handler::checkCommandLine(int argc,
}
}
- // check parameters according to function
- if (!mvSourceFiles.size())
- throw "-f <files> is mandatory";
+ // Check parameters mandatory for all commands
+ if (!msModuleName.size())
+ throw "<module name> is mandatory";
+ if (!msPoDir.size())
+ throw "<po dir> is mandatory";
+ if (!sLangText.size())
+ throw "<languages> is mandatory";
- // partly valid
- if (meWorkMode != DO_MERGE && msTargetDir.size())
- throw "-t is mandatory using \"extract\"";
- if (meWorkMode == DO_MERGE && !msTargetDir.size())
- throw "-t is only valid using \"extract\"";
+ // check parameters according to function
+ if (mvSourceFiles.size())
+ {
+ if (meWorkMode == DO_CONVERT || meWorkMode == DO_GENERATE)
+ throw "-f <files> is only valid using \"extract\" and \"merge\"";
+ }
+ else
+ {
+ if (meWorkMode == DO_EXTRACT || meWorkMode == DO_MERGE)
+ throw "-f <files> is mandatory";
+ }
+ if (msTargetDir.size())
+ {
+ if (meWorkMode != DO_MERGE)
+ throw "-t <target dir> is only valid using \"merge\"";
+ }
+ else
+ {
+ if (meWorkMode == DO_MERGE)
+ throw "-t <target dir> is mandatory";
+ }
+ if (msSourceDir.size())
+ {
+ if (meWorkMode == DO_GENERATE)
+ throw "-s <source dir> is only valid using \"extract\", \"merge\" and \"convert\"";
+ }
+ else
+ {
+ if (meWorkMode != DO_GENERATE)
+ throw "-s <source dir> is mandatory";
+ }
// Key Identification generation
if (bKid)
@@ -183,8 +200,19 @@ void handler::checkCommandLine(int argc,
if (nLen && msPoOutDir.at(nLen-1) != '/')
msPoOutDir.append("/");
+ // and convert language to a vector
+ int current;
+ int next = -1;
+ do
+ {
+ current = next + 1;
+ next = sLangText.find_first_of( ",", current );
+ mvLanguages.push_back(sLangText.substr(current,next-current));
+ }
+ while (next != (int)std::string::npos);
+
// tell system
- mcMemory.showVerbose("gLang starting to " + sWorkText + " from module " + msModuleName);
+ l10nMem::showVerbose("gLang starting to " + sWorkText + " from module " + msModuleName);
}
@@ -222,22 +250,21 @@ void handler::run()
/********************** I M P L E M E N T A T I O N **********************/
void handler::runExtractMerge(bool bMerge, bool bKid)
{
- bKid = bKid;
- //JIX HANDLE KID
-
// loop through all source files, and extract messages from each file
for (std::vector<std::string>::iterator siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource)
{
// tell system
- mcMemory.showDebug("gLang extracting text from file " + *siSource);
+ l10nMem::showDebug("gLang extracting text from file " + msSourceDir + *siSource);
- // get converter and extract files
+ // get converter and extract file
convert_gen convertObj(mcMemory, msSourceDir, *siSource);
- convertObj.execute(bMerge);
+ convertObj.execute(bMerge, false);
+
+ //JIX runExtractMerge, handle merge
}
// and generate language file
- mcMemory.save(msPoOutDir);
+ mcMemory.save(msPoOutDir, bKid);
}
@@ -245,7 +272,28 @@ void handler::runExtractMerge(bool bMerg
/********************** I M P L E M E N T A T I O N **********************/
void handler::runConvert()
{
- throw mcMemory.showError(std::string("handler::runConvert not implemented"));
+ // loop through all languages
+ for (std::vector<std::string>::iterator siLang = mvLanguages.begin(); siLang != mvLanguages.end(); ++siLang)
+ {
+ // get converter and extract files
+ mcMemory.setLanguage(*siLang, false, true);
+
+ // loop through all source files, and extract messages from each file
+ for (std::vector<std::string>::iterator siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource)
+ {
+ std::string sFilePath = msSourceDir + *siLang + "/";
+
+ // tell system
+ l10nMem::showDebug("gLang convert text from file " + sFilePath + *siSource);
+
+ // get converter and extract files
+ convert_gen convertObj(mcMemory, sFilePath, *siSource);
+ convertObj.execute(true, false);
+ }
+ }
+
+ // and generate language file
+ mcMemory.save(msPoOutDir, false);
}
@@ -253,7 +301,7 @@ void handler::runConvert()
/********************** I M P L E M E N T A T I O N **********************/
void handler::runGenerate()
{
- throw mcMemory.showError(std::string("handler::runGenerate not implemented"));
+ mcMemory.dumpMem(msPoOutDir);
}
@@ -283,7 +331,7 @@ void handler::showManual()
"genLang (c)2013 by Apache Software Foundation\n"
"=============================================\n"
"As part of the L10N framework for Apache Open Office (AOO),\n"
- "genLang extracts en-US texts sources of the following types:\n"
+ "genLang extracts en_US texts sources of the following types:\n"
" .xrm, .xhp, .xcu, .xcs, .ulf, .tree, .src, .prop and .po\n"
"and merges with .po files in different languages.\n"
"genLang merges .po files with AOO sources to add languages.\n"
@@ -299,9 +347,8 @@ void handler::showManual()
" from <source dir>/<files>, result is merged and\n"
" written to <po outdir>/*lang/<module>.po if -o present\n"
" or <po dir>/*lang/<module>.po is overwritten\n"
- " - File will only be written if they are changes\n"
" - Keys in .po files, not in sources files (deleted keys)\n"
- " are moved to '-p <dir>'/<module>.deleted.po\n"
+ " are shown as warnings\n"
" - Keys in .po files, with changed text in the source\n"
" are marked \"fuzzy\"\n"
" - Keys in source files not in .po files (new keys)\n"
@@ -316,21 +363,23 @@ void handler::showManual()
" The result is stored in <target dir>/<files>\n"
"\n"
" genLang convert <module> <po dir> <languages> [-v] [-d]\\\n"
- " [-o <po outdir>] -f <files>\n"
- " reads sdf generated .po <files> and merges with\n"
+ " [-o <po outdir>] -s <source dir>\n"
+ " reads sdf generated .po <files> from\n"
+ " <source dir>/*lang/<module>.po\n"
+ " and merges with\n"
" <po dir>/*lang/<module>.po\n"
" Result is written to <po outdir>/*lang/<module>.po if\n"
" present or <po dir>/*lang/<module>.po is overwritten\n"
- " - File will only be written if they are changes\n"
- " - Keys in <files>, not in <module>.po\n"
- " are moved to <po dir>/<module>.deleted.po\n"
- " - Keys in <files>, with changed translation\n"
+ " - Keys in <source dir>, not in <module>.po\n"
+ " are shown as warnings\n"
+ " - Keys in <source dir>, with changed translation\n"
" are marked \"fuzzy\"\n"
"\n"
" genLang generate <module> <po dir> <languages> [-v] [-d]\\\n"
- " -o <po outdir>\n"
+ " [-o <po outdir>]\n"
" reads .po <files> and generates a \"bin\" file for fast loading\n"
- " Result is written to <po outdir>/<module>.dbpo\n"
+ " Result is written to <po outdir>/<module>.dbpo if\n"
+ " present or <po dir>/<module>.dbpo\n"
"\n"
" genLang help\n"
" this text\n"
@@ -372,16 +421,17 @@ void handler::showManual()
void handler::loadL10MEM()
{
std::string sMod = msModuleName + ".po";
- std::string sLoad = msPoDir + "en-US";
+ std::string sLoad = msPoDir + "en_US/";
- // load texts from en-US po file (master)
+ // load texts from en_US po file (master)
{
// tell system
- mcMemory.showDebug("gLang loading master text from file " + sLoad);
+ l10nMem::showDebug("gLang loading master text from file " + sLoad);
// and load file
- convert_gen(mcMemory, sLoad, sMod).execute(true);
+ mcMemory.setLanguage("", true, false);
+ convert_gen (mcMemory, sLoad, sMod).execute(false, true);
}
// loop through all languages and load text
@@ -390,9 +440,10 @@ void handler::loadL10MEM()
sLoad = msPoDir + *siLang;
// tell system
- mcMemory.showDebug("gLang loading text from language file " + sLoad);
+ l10nMem::showDebug("gLang loading text from language file " + sLoad);
// get converter and extract files
+ mcMemory.setLanguage(*siLang, true, false);
convert_gen(mcMemory, sLoad, sMod).execute(false, true);
}
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx Sun Mar 10 12:05:10 2013
@@ -83,38 +83,24 @@ void l10nMem::showDebug(const std::strin
{ l10nMem_impl::mcImpl->showDebug(sText, iLineNo); }
void l10nMem::showVerbose(const std::string& sText, int iLineNo)
{ l10nMem_impl::mcImpl->showVerbose(sText, iLineNo); }
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
bool l10nMem::isError()
-{
- return l10nMem_impl::mcImpl->mbInError;
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem::setModuleName(const std::string& sModuleName)
- { l10nMem_impl::mcImpl->setModuleName(sModuleName); }
-void l10nMem::loadENUSkey(int iL, const std::string& sS, const std::string& sK, const std::string& sT)
- { l10nMem_impl::mcImpl->mcDb.loadENUSkey(iL, sS, sK, sT); }
-void l10nMem::setLanguage(const std::string& sL, bool bC)
- { l10nMem_impl::mcImpl->mcDb.setLanguage(sL, bC); }
-void l10nMem::loadLangKey(int iL, const std::string& sS, const std::string& sK, const std::string& sO, const std::string& sT, bool bI)
- { l10nMem_impl::mcImpl->mcDb.loadLangKey(iL, sS, sK, sO, sT, bI); }
-void l10nMem::convLangKey(int iL, const std::string& sS, const std::string& sK, const std::string& sO, const std::string& sT, bool bI)
- { l10nMem_impl::mcImpl->convLangKey(iL, sS, sK, sO, sT, bI); }
+ { return l10nMem_impl::mcImpl->mbInError; }
+void l10nMem::setModuleName(const std::string& sM)
+ { l10nMem_impl::mcImpl->setModuleName(sM); }
+void l10nMem::setLanguage(const std::string& sL, bool bC, bool bK)
+ { l10nMem_impl::mcImpl->mcDb.setLanguage(sL, bC, bK); }
+void l10nMem::loadEntryKey(int iL, const std::string& sS, const std::string& sK, const std::string& sO, const std::string& sT, bool bI)
+ { l10nMem_impl::mcImpl->loadEntryKey(iL, sS, sK, sO, sT, bI); }
bool l10nMem::checkKey(const std::string& sKey, const std::string& sText)
{ return l10nMem_impl::mcImpl->mcDb.locateKey(0, sKey, sText, false); }
void l10nMem::setSourceKey(int iL, const std::string& sF, const std::string& sK, const std::string& sT)
{ l10nMem_impl::mcImpl->setSourceKey(iL, sF, sK, sT); }
void l10nMem::reorganize()
{ l10nMem_impl::mcImpl->mcDb.reorganize(); }
-void l10nMem::save(const std::string& sTargetDir)
- { l10nMem_impl::mcImpl->save(*this, sTargetDir); }
-void l10nMem::dumpMem(const std::string& sTargetDir)
- { l10nMem_impl::mcImpl->dumpMem(sTargetDir); }
+void l10nMem::save(const std::string& sT, bool bK)
+ { l10nMem_impl::mcImpl->save(*this, sT, bK); }
+void l10nMem::dumpMem(const std::string& sT)
+ { l10nMem_impl::mcImpl->dumpMem(sT); }
@@ -180,6 +166,24 @@ void l10nMem_impl::setModuleName(const s
/********************** I M P L E M E N T A T I O N **********************/
+void l10nMem_impl::loadEntryKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sOrgText,
+ const std::string& sText,
+ bool bIsFuzzy)
+{
+ if (!mcDb.miCurLangInx)
+ mcDb.loadENUSkey(iLineNo, sSourceFile, sKey, sText);
+ else if (mcDb.mbConvertMode)
+ convEntryKey(iLineNo, sSourceFile, sKey, sOrgText, sText, bIsFuzzy);
+ else
+ mcDb.loadLangKey(iLineNo, sSourceFile, sKey, sOrgText, sText, bIsFuzzy);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
void l10nMem_impl::setSourceKey(int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
@@ -201,42 +205,28 @@ void l10nMem_impl::setSourceKey(int
/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::convLangKey(int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sOrgText,
- const std::string& sText,
- bool bIsFuzzy)
+void l10nMem_impl::save(l10nMem& cMem, const std::string& sTargetDir, bool bKid)
{
- std::string x;
- iLineNo = iLineNo;
- x = sSourceFile;
- x = sKey;
- x = sOrgText;
- x = sText;
- bIsFuzzy = bIsFuzzy;
- //JIX (convLangKey)
-}
+ //JIX save HANDLE KID
+ if (mbInError)
+ throw l10nMem::showError("Cannot save due to previous errors");
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::save(l10nMem& cMem, const std::string& sTargetDir)
-{
int iE, iEsize = mcDb.mcENUSlist.size();
int iL, iLsize = mcDb.mcLangList.size();
std::string fileName = msModuleName + ".po";
- // Save en-US
+ // Save en_US
{
convert_gen savePo(cMem, sTargetDir, fileName);
savePo.startSave(sTargetDir, "en_US", fileName);
for (iE = 1; iE < iEsize; ++iE)
{
- l10nMem_enus_entry& cE = mcDb.mcENUSlist[iE];
+ l10nMem_enus_entry& cE = mcDb.mcENUSlist[iE];
+ std::string newKey = mcDb.mcFileList[cE.miFileInx].msFileName + ":" + cE.msKey;
- savePo.save(cE.msKey, cE.msText, cE.msText, false);
+
+ savePo.save(newKey, cE.msText, cE.msText, false);
}
savePo.endSave();
}
@@ -249,10 +239,13 @@ void l10nMem_impl::save(l10nMem& cMem, c
savePo.startSave(sTargetDir, mcDb.mcLangList[iL], fileName);
for (iE = 1; iE < iEsize; ++iE)
{
- l10nMem_enus_entry& cE = mcDb.mcENUSlist[iE];
- l10nMem_lang_entry& cL = cE.mcLangList[iL];
- bool bF = cL.mbFuzzy || (cE.meState == l10nMem::ENTRY_CHANGED);
- savePo.save(cE.msKey, cE.msText, cL.msText, false);
+ l10nMem_enus_entry& cE = mcDb.mcENUSlist[iE];
+ l10nMem_lang_entry& cL = cE.mcLangList[iL];
+ bool bF = cL.mbFuzzy || (cE.meState == l10nMem::ENTRY_CHANGED);
+ std::string newKey = mcDb.mcFileList[cE.miFileInx].msFileName + ":" + cE.msKey;
+
+
+ savePo.save(newKey, cE.msText, cL.msText, false);
}
savePo.endSave();
}
@@ -265,6 +258,9 @@ void l10nMem_impl::dumpMem(const std::st
{
std::string x;
+ if (mbInError)
+ throw l10nMem::showError("Cannot generate fast load file due to previous errors");
+
x = srTargetFile;
// JIX (dumpMem)
}
@@ -282,4 +278,24 @@ void l10nMem_impl::formatAndShowText(con
if (iLineNo)
std::cerr << "(" << iLineNo << ")";
std::cerr << ": " << sText << std::endl;
-}
\ No newline at end of file
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void l10nMem_impl::convEntryKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sOrgText,
+ const std::string& sText,
+ bool bIsFuzzy)
+{
+ std::string x;
+ iLineNo = iLineNo;
+ x = sSourceFile;
+ x = sKey;
+ x = sOrgText;
+ x = sText;
+ bIsFuzzy = bIsFuzzy;
+ //JIX (convLangKey)
+}
Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx Sun Mar 10 12:05:10 2013
@@ -58,7 +58,7 @@ class l10nMem_enus_entry
~l10nMem_enus_entry();
std::string msKey; // key in po file and source file
- std::string msText; // en-US text from source file
+ std::string msText; // en_US text from source file
l10nMem::ENTRY_STATE meState; // status information
int miFileInx; // index of file name
int miLineNo; // line number
@@ -94,6 +94,7 @@ class l10nMem_db
int miCurLastENUSinx;
bool mbNeedWrite;
bool mbReorganizeNeeded;
+ bool mbConvertMode;
std::vector<l10nMem_enus_entry> mcENUSlist;
std::vector<l10nMem_file_entry> mcFileList;
std::vector<std::string> mcLangList;
@@ -104,7 +105,8 @@ class l10nMem_db
const std::string& sKey,
const std::string& sText);
void setLanguage (const std::string& sLanguage,
- bool bCreate);
+ bool bCreate,
+ bool bConvert);
bool findFileName (const std::string& sSourceFile, int iStart, bool bCreate);
void loadLangKey (int iLineNo,
const std::string& sSourceFile,
@@ -141,22 +143,20 @@ class l10nMem_impl
void showVerbose (const std::string& sText, int iLineNo);
void setModuleName (const std::string& sModuleName);
-
-
- void setSourceKey (int iLineNo,
- const std::string& sFilename,
- const std::string& sKey,
- const std::string& sText);
-
-
- void convLangKey (int iLineNo,
+ void loadEntryKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
const std::string& sOrgText,
const std::string& sText,
bool bIsFuzzy);
+ void setSourceKey (int iLineNo,
+ const std::string& sFilename,
+ const std::string& sKey,
+ const std::string& sText);
- void save (l10nMem& cMem, const std::string& sTargetDir);
+ void save (l10nMem& cMem,
+ const std::string& sTargetDir,
+ bool bKid);
void dumpMem (const std::string& sTargetDir);
private:
@@ -168,6 +168,12 @@ class l10nMem_impl
bool mbInError;
void formatAndShowText(const std::string& sType, int iLineNo, const std::string& sText);
+ void convEntryKey (int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sOrgText,
+ const std::string& sText,
+ bool bIsFuzzy);
friend class l10nMem;
};
Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx Sun Mar 10 12:05:10 2013
@@ -100,7 +100,8 @@ l10nMem_db::l10nMem_db()
miCurENUSinx(0),
miCurLastENUSinx(0),
mbNeedWrite(false),
- mbReorganizeNeeded(false)
+ mbReorganizeNeeded(false),
+ mbConvertMode(false)
{
mcFileList.push_back(l10nMem_file_entry("", 0));
mcLangList.push_back("");
@@ -137,14 +138,21 @@ void l10nMem_db::loadENUSkey(int
/********************** I M P L E M E N T A T I O N **********************/
void l10nMem_db::setLanguage(const std::string& sLanguage,
- bool bCreate)
+ bool bCreate,
+ bool bConvert)
{
int iSize = mcLangList.size();
+ // regular load or convert of old po files
+ mbConvertMode = bConvert;
- // en-US is loaded as master and cannot be loaded again
- if (sLanguage == "en-US")
- throw l10nMem::showError("en-US is loaded automatically");
+ // With no languages selected only en_US is generated
+ if (!sLanguage.size())
+ miCurLangInx = 0;
+
+ // en_US is loaded as master and cannot be loaded again
+ if (sLanguage == "en_US")
+ throw l10nMem::showError("en_US is loaded automatically");
// check if language is already loaded
for (miCurLangInx = 0; miCurLangInx < iSize && mcLangList[miCurLangInx] != sLanguage; ++miCurLangInx) ;
@@ -262,6 +270,7 @@ void l10nMem_db::addKey(int
const std::string& sText,
l10nMem::ENTRY_STATE eStat)
{
+ // JIX. addKey, handle fuzzy bit in lang (if changed).
miCurENUSinx = mcENUSlist.size();
mcENUSlist.push_back(l10nMem_enus_entry(sKey, sText, iLineNo, miCurFileInx, eStat));
miCurLastENUSinx = mcFileList[miCurFileInx].miEnd = miCurENUSinx;
Modified: openoffice/branches/l10n/main/l10ntools/source/gLang.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gLang.hxx?rev=1454842&r1=1454841&r2=1454842&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gLang.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gLang.hxx Sun Mar 10 12:05:10 2013
@@ -67,21 +67,10 @@ class l10nMem
bool isError ();
void setModuleName (const std::string& sModuleName);
- void loadENUSkey (int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sText);
void setLanguage (const std::string& sLanguage,
- bool bCreate);
- void loadLangKey (int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sOrgText,
- const std::string& sText,
- bool bIsFuzzy);
-
-
- void convLangKey (int iLineNo,
+ bool bCreate,
+ bool bConvert);
+ void loadEntryKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
const std::string& sOrgText,
@@ -96,7 +85,8 @@ class l10nMem
const std::string& sText);
void reorganize ();
- void save (const std::string& sTargetDir);
+ void save (const std::string& sTargetDir,
+ bool bKid);
void dumpMem (const std::string& sTargetDir);
};
@@ -111,7 +101,7 @@ class convert_gen
~convert_gen();
// do extract/merge
- bool execute(const bool bMerge, const bool bAllowNoFile = false);
+ bool execute(const bool bMerge, const bool bAllowNoFile);
// ONLY po should implement these functions
void startSave(const std::string& sTargetDir,