Author: jani
Date: Mon Dec 17 14:40:39 2012
New Revision: 1422951
URL: http://svn.apache.org/viewvc?rev=1422951&view=rev
Log:
update to add po files, and read xcs correct
Modified:
openoffice/branches/l10n/main/l10ntools/source/gCon.cxx
openoffice/branches/l10n/main/l10ntools/source/gConPo.cxx
openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx
openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx
openoffice/branches/l10n/main/l10ntools/source/gConXcs.cxx
openoffice/branches/l10n/main/l10ntools/source/gConXcs.hxx
openoffice/branches/l10n/main/l10ntools/source/gConXcsWrap.cxx
openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l
openoffice/branches/l10n/main/l10ntools/source/gConXcu.cxx
openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx
openoffice/branches/l10n/main/l10ntools/source/gConXhp.cxx
openoffice/branches/l10n/main/l10ntools/source/gConXhpWrap.cxx
openoffice/branches/l10n/main/l10ntools/source/gConXrm.cxx
openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx
openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx
openoffice/branches/l10n/main/l10ntools/source/gL10nMem.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=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gCon.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gCon.cxx Mon Dec 17 14:40:39
2012
@@ -149,6 +149,9 @@ void convert_gen::lineRead(bool *bEof, s
/********************** I M P L E M E N T A T I O N **********************/
void convert_gen::writeSourceFile(const string& line)
{
+ if (!line.size())
+ return;
+
cout << line;
// JIX
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConPo.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPo.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPo.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPo.cxx Mon Dec 17
14:40:39 2012
@@ -64,7 +64,9 @@ po_stack_entry::~po_stack_entry()
/********************** I M P L E M E N T A T I O N **********************/
convert_po_impl::convert_po_impl(const string& srSourceFile, l10nMem& crMemory)
- : convert_gen (srSourceFile, crMemory)
+ : convert_gen (srSourceFile, crMemory),
+
mbCollectingData(false)
+
{
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx Mon Dec 17
14:40:39 2012
@@ -49,7 +49,9 @@ void convert_src::insert() {mcpImpl->in
/********************** I M P L E M E N T A T I O N **********************/
convert_src_impl::convert_src_impl(const string& srSourceFile, l10nMem&
crMemory)
- : convert_gen (srSourceFile,
crMemory)
+ : convert_gen(srSourceFile, crMemory),
+
mbCollectingData(false)
+
{
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx Mon Dec 17
14:40:39 2012
@@ -78,7 +78,7 @@ class convert_src_impl : public convert_
void runLex();
void extract();
void insert();
-
+ bool mbCollectingData;
friend class convert_src;
};
#endif
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcs.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcs.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcs.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcs.cxx Mon Dec 17
14:40:39 2012
@@ -48,7 +48,8 @@ void convert_xcs::insert() {mcpImpl->in
/********************** I M P L E M E N T A T I O N **********************/
convert_xcs_impl::convert_xcs_impl(const string& srSourceFile, l10nMem&
crMemory)
- : convert_gen (srSourceFile, crMemory)
+ : convert_gen (srSourceFile, crMemory),
+
mbCollectingData(false)
{
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcs.hxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcs.hxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcs.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcs.hxx Mon Dec 17
14:40:39 2012
@@ -39,15 +39,17 @@ class convert_xcs_impl : public convert_
convert_xcs_impl(const string& srSourceFile, l10nMem& crMemory);
~convert_xcs_impl();
- void startCollectData(string& sCollectedText);
+ void setKey(string &sCollectedText);
+ void unsetKey(string &sCollectedText);
+ void startCollectData(string& sCollectedText);
void stopCollectData(string& sCollectedText);
void collectData(string& sCollectedText);
private:
- bool mbMergeMode;
-
- bool mbCollectingData;
+ bool mbMergeMode;
+ bool mbCollectingData;
string msCollector;
+ string msKey;
void extract();
void insert();
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcsWrap.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcsWrap.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcsWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcsWrap.cxx Mon Dec 17
14:40:39 2012
@@ -39,7 +39,45 @@ using namespace std;
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcs_impl::runLex()
{
- genxcs_lex();
+ // currently no .xcs files generate en-US translation, so stop trying
+ // genxcs_lex();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcs_impl::setKey(string& sCollectedText)
+{
+ int nL;
+ string sHead;
+
+ if (mbMergeMode)
+ writeSourceFile(msCollector+sCollectedText);
+ msCollector.clear();
+
+ // is it to be translated
+ if (sCollectedText.find("oor:localized=") == string::npos)
+ return;
+
+ // locate key (is any)
+ nL = sCollectedText.find("oor:name=\"");
+ if (nL == string::npos)
+ return;
+ sHead = sCollectedText.substr(nL+10);
+ nL = sHead.find("\"");
+ msKey = sHead.substr(0,nL);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcs_impl::unsetKey(string& sCollectedText)
+{
+ if (mbMergeMode)
+ writeSourceFile(msCollector+sCollectedText);
+ msCollector.clear();
+
+ msKey.clear();
}
@@ -47,11 +85,12 @@ void convert_xcs_impl::runLex()
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcs_impl::startCollectData(string& sCollectedText)
{
- if (mbMergeMode && msCollector.size())
+ if (mbMergeMode)
writeSourceFile(msCollector);
+ msCollector.clear();
- mbCollectingData = true;
- msCollector = sCollectedText;
+ if (!msKey.size())
+ return;
}
@@ -112,9 +151,10 @@ void convert_xcs_impl::stopCollectData(s
void convert_xcs_impl::collectData(string& sCollectedText)
{
msCollector += sCollectedText;
- if (mbMergeMode && sCollectedText == "\n")
+ if (sCollectedText == "\n")
{
- writeSourceFile(msCollector);
+ if (mbMergeMode)
+ writeSourceFile(msCollector);
msCollector.clear();
}
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l Mon Dec 17
14:40:39 2012
@@ -59,38 +59,17 @@
/******************* R U L E S D E F I N I T I O N S *******************/
%%
-"<oor:component-data "[^>]*> {
+"<prop"[^>]*> {
string text(yytext);
-// convert_xcs::mcpImpl->pushKeyPart(TAG_COMPONENT, text);
-}
-
-
-"</oor:component-data>" {
- string text(yytext);
-// convert_xcs::mcpImpl->popKeyPart(TAG_COMPONENT, text);
-}
-
-"<prop oor:name=\""[^\"]*\" {
- string text(yytext);
-// convert_xcu::mcpImpl->pushKeyPart(TAG_PROP, text);
+ convert_xcs::mcpImpl->setKey(text);
}
"</prop>" {
string text(yytext);
-// convert_xcs::mcpImpl->popKeyPart(TAG_PROP, text);
-}
-
-"<node oor:name=\""[^\"]*\" {
- string text(yytext);
-// convert_xcs::mcpImpl->pushKeyPart(TAG_NODE, text);
-}
-
-"</node>" {
- string text(yytext);
-// convert_xcs::mcpImpl->popKeyPart(TAG_NODE, text);
+ convert_xcs::mcpImpl->unsetKey(text);
}
-"<value xml:lang=\""[^\"]*\"[^>]*">" {
+"<value"[^>]*> {
string text(yytext);
convert_xcs::mcpImpl->startCollectData(text);
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcu.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcu.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcu.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcu.cxx Mon Dec 17
14:40:39 2012
@@ -64,7 +64,9 @@ xcu_stack_entry::~xcu_stack_entry()
/********************** I M P L E M E N T A T I O N **********************/
convert_xcu_impl::convert_xcu_impl(const string& srSourceFile, l10nMem&
crMemory)
- : convert_gen (srSourceFile, crMemory)
+ : convert_gen (srSourceFile, crMemory),
+
mbCollectingData(false)
+
{
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx Mon Dec 17
14:40:39 2012
@@ -47,10 +47,28 @@ void convert_xcu_impl::runLex()
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcu_impl::pushKeyPart(TAG_TYPE bIsNode, string& sTag)
{
+ string sKey, sHead;
+ int nL;
+
+
// remember text for merge
msCollector += sTag;
- xcu_stack_entry newTag(bIsNode, sTag);
+ // find key in tag
+ nL = sTag.find("oor:name=\"");
+ if (nL != string::npos)
+ sHead = sTag.substr(nL+10);
+ else
+ return;
+
+ // find end of key
+ nL = sHead.find("\"");
+ if (nL != string::npos)
+ sKey = sHead.substr(0, nL);
+ else
+ return;
+
+ xcu_stack_entry newTag(bIsNode, sKey);
mcStack.push(newTag);
}
@@ -64,12 +82,10 @@ void convert_xcu_impl::popKeyPart(TAG_TY
msCollector += sTag;
// check for correct node/prop relations
- if (bIsNode != mcStack.top().mbIsNode)
- throw "node/prob mismatch in file " + msSourceFile;
-
- mcStack.pop();
+ if (mcStack.size())
+ mcStack.pop();
- if (mbMergeMode && msCollector.size())
+ if (mbMergeMode)
writeSourceFile(msCollector);
msCollector.clear();
}
@@ -79,7 +95,7 @@ void convert_xcu_impl::popKeyPart(TAG_TY
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcu_impl::startCollectData(string& sCollectedText)
{
- if (mbMergeMode && msCollector.size())
+ if (mbMergeMode)
writeSourceFile(msCollector);
mbCollectingData = true;
@@ -93,34 +109,38 @@ void convert_xcu_impl::stopCollectData(s
{
string useKey;
+ // time to do something ?
+ if (!mbCollectingData)
+ return;
+ mbCollectingData = false;
// locate key and extract it
while (mcStack.size())
{
xcu_stack_entry nowEntry = mcStack.top();
- mcStack.pop();
- useKey = useKey + nowEntry.msName;
+ mcStack.pop();
+ useKey = nowEntry.msName + "." + useKey;
}
if (mbMergeMode)
{
+ writeSourceFile(msCollector + sCollectedText);
+
// get all languages (includes en-US)
vector<l10nMem_entry *>& cExtraLangauges =
mcMemory.getLanguagesForKey(useKey);
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>";
+ cExtraLangauges[i]->msText + "</value>";
writeSourceFile(sNewLine);
}
}
else
- mcMemory.setEnUsKey(useKey, sCollectedText);
+ mcMemory.setEnUsKey(useKey, msCollector);
- mbCollectingData = false;
msCollector.clear();
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXhp.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXhp.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXhp.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXhp.cxx Mon Dec 17
14:40:39 2012
@@ -48,7 +48,8 @@ void convert_xhp::insert() {mcpImpl->in
/********************** I M P L E M E N T A T I O N **********************/
convert_xhp_impl::convert_xhp_impl(const string& srSourceFile, l10nMem&
crMemory)
- : convert_gen (srSourceFile, crMemory)
+ : convert_gen (srSourceFile, crMemory),
+
mbCollectingData(false)
{
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXhpWrap.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXhpWrap.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXhpWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXhpWrap.cxx Mon Dec 17
14:40:39 2012
@@ -41,7 +41,7 @@ void convert_xhp_impl::runLex()
{
genXhp_lex();
- if (mbMergeMode && msCollector.size())
+ if (mbMergeMode)
writeSourceFile(msCollector);
}
@@ -50,7 +50,7 @@ void convert_xhp_impl::runLex()
/********************** I M P L E M E N T A T I O N **********************/
void convert_xhp_impl::startCollectData(string& sCollectedText)
{
- if (mbMergeMode && msCollector.size())
+ if (mbMergeMode)
writeSourceFile(msCollector);
mbCollectingData = true;
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXrm.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXrm.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXrm.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXrm.cxx Mon Dec 17
14:40:39 2012
@@ -48,7 +48,8 @@ void convert_xrm::insert() {mcpImpl->in
/********************** I M P L E M E N T A T I O N **********************/
convert_xrm_impl::convert_xrm_impl(const string& srSourceFile, l10nMem&
crMemory)
- : convert_gen (srSourceFile, crMemory)
+ : convert_gen (srSourceFile, crMemory),
+
mbCollectingData(false)
{
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx Mon Dec 17
14:40:39 2012
@@ -42,7 +42,7 @@ void convert_xrm_impl::runLex()
genXrm_lex();
// write last part of file.
- if (mbMergeMode && msCollector.size())
+ if (mbMergeMode)
writeSourceFile(msCollector);
}
@@ -51,7 +51,7 @@ void convert_xrm_impl::runLex()
/********************** I M P L E M E N T A T I O N **********************/
void convert_xrm_impl::startCollectData(string& sCollectedText)
{
- if (mbMergeMode && msCollector.size())
+ if (mbMergeMode)
writeSourceFile(msCollector);
mbCollectingData = true;
Modified: openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx Mon Dec 17
14:40:39 2012
@@ -223,7 +223,10 @@ void handler::runExtract()
// loop through all source files, and extract messages from each file
for (vector<string>::iterator siSource = msSourceFiles.begin(); siSource !=
msSourceFiles.end(); ++siSource)
{
- // prepare translation memory
+ // JIX JUST FOR TEST
+ mcMemory.clear();
+
+ // prepare translation memory
mcMemory.setFileName(*siSource);
// get converter and extract files
Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx Mon Dec 17
14:40:39 2012
@@ -85,6 +85,17 @@ void l10nMem::save(const string& srTarge
/********************** I M P L E M E N T A T I O N **********************/
+void l10nMem::clear()
+{
+ cout << "--------------- clear of l10n -----------------" << endl;
+
+ mcMemory.clear();
+ // JIX
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
void l10nMem::setFileName(const string& srSourceFile)
{
msCurrentSourceFileName = srSourceFile;
Modified: openoffice/branches/l10n/main/l10ntools/source/gLang.hxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gLang.hxx?rev=1422951&r1=1422950&r2=1422951&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gLang.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gLang.hxx Mon Dec 17
14:40:39 2012
@@ -7,7 +7,7 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
@@ -64,6 +64,7 @@ class l10nMem
~l10nMem();
void save(const string& srTargetFile);
+ void clear();
void setFileName(const string& srSourceFile);
void setModuleName(const string& srModuleName);
void setEnUsKey(const string& srKey, const string& srText);