Author: jani
Date: Sat Aug 31 23:43:50 2013
New Revision: 1519235
URL: http://svn.apache.org/r1519235
Log:
update for cmd: convert, splitted save into templates and languages.
Modified:
openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx
openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.cxx
openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.hxx
openoffice/branches/l10n40/main/l10ntools/source/gLang.hxx
Modified: openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx?rev=1519235&r1=1519234&r2=1519235&view=diff
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx (original)
+++ openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx Sat Aug 31
23:43:50 2013
@@ -282,7 +282,7 @@ void handler::runExtract()
}
// and generate language file
- mcMemory.save(msPoOutDir, false, mbForceSave);
+ mcMemory.saveTemplates(msPoOutDir, false, mbForceSave);
}
@@ -303,9 +303,6 @@ void handler::runMerge(bool bKid)
convert_gen convertObj(mcMemory, msSourceDir, msTargetDir, *siSource);
convertObj.execute(true);
}
-
- // and generate language file
- mcMemory.save(msPoOutDir, bKid, mbForceSave);
}
@@ -346,15 +343,12 @@ void handler::runConvert(bool bPot)
// get converter and extract files
convert_gen convertObj(mcMemory, sFilePath, msTargetDir, *siSource);
convertObj.execute(true);
-
- if (bPot)
- mcMemory.showNOconvert();
}
}
// and generate language file
if (!bPot)
- mcMemory.save(msPoOutDir, false, mbForceSave);
+ mcMemory.saveLanguages(msPoOutDir, mbForceSave);
}
@@ -477,14 +471,12 @@ void handler::loadL10MEM(bool onlyTempla
mcMemory.setConvert(false, false);
// load texts from en-US po file (master)
- {
- // tell system
- l10nMem::showDebug("genLang loading master text from file " + sLoad +
sMod);
+ // tell system
+ l10nMem::showDebug("genLang loading master text from file " + sLoad + sMod);
- // and load file
- mcMemory.setLanguage("", true);
- convert_gen (mcMemory, sLoad, msTargetDir, sMod).execute(false);
- }
+ // and load file
+ mcMemory.setLanguage("", true);
+ convert_gen (mcMemory, sLoad, msTargetDir, sMod).execute(false);
if (onlyTemplates)
return;
Modified: openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.cxx?rev=1519235&r1=1519234&r2=1519235&view=diff
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.cxx (original)
+++ openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.cxx Sat Aug 31
23:43:50 2013
@@ -95,8 +95,10 @@ void l10nMem::loadEntryKey(int iL, const
{ l10nMem_impl::mcImpl->loadEntryKey(iL, sS, sK, sO, sT, bI); }
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::save(const std::string& sT, bool bK, bool bF)
- { l10nMem_impl::mcImpl->save(*this, sT, bK, bF); }
+void l10nMem::saveTemplates(const std::string& sT, bool bK, bool bF)
+ { l10nMem_impl::mcImpl->saveTemplates(*this, sT, bK, bF); }
+void l10nMem::saveLanguages(const std::string& sT, bool bF)
+ { l10nMem_impl::mcImpl->saveLanguages(*this, sT, bF); }
void l10nMem::showNOconvert ()
{ l10nMem_impl::mcImpl->showNOconvert(); }
@@ -234,10 +236,9 @@ void l10nMem_impl::setSourceKey(int
/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::save(l10nMem& cMem, const std::string& sTargetDir, bool
bKid, bool bForce)
+void l10nMem_impl::saveTemplates(l10nMem& cMem, const std::string& sTargetDir,
bool bKid, bool bForce)
{
int iE, iEsize = mcDb.mcENUSlist.size();
- int iL, iLsize = mcDb.mcLangList.size();
int iCntDeleted = 0, iCntChanged = 0, iCntAdded = 0;
std::string sFileName = msModuleName + ".pot";
@@ -253,25 +254,42 @@ void l10nMem_impl::save(l10nMem& cMem, c
//JIX save HANDLE KID
// Save en-US
- {
- convert_gen savePo(cMem, sTargetDir, sTargetDir, sFileName);
+ convert_gen savePo(cMem, sTargetDir, sTargetDir, sFileName);
- savePo.startSave("templates/", sFileName);
- for (iE = 1; iE < iEsize; ++iE)
- {
- l10nMem_enus_entry& cE = mcDb.mcENUSlist[iE];
+ savePo.startSave("templates/", sFileName);
+ for (iE = 1; iE < iEsize; ++iE)
+ {
+ l10nMem_enus_entry& cE = mcDb.mcENUSlist[iE];
- // remove deleted entries
- if (cE.meState == l10nMem::ENTRY_DELETED)
- continue;
+ // remove deleted entries
+ if (cE.meState == l10nMem::ENTRY_DELETED)
+ continue;
- savePo.save(mcDb.mcFileList[cE.miFileInx].msFileName, cE.msKey,
cE.msMsgId, "", false);
- }
- savePo.endSave();
+ savePo.save(mcDb.mcFileList[cE.miFileInx].msFileName, cE.msKey,
cE.msMsgId, "", false);
}
+ savePo.endSave();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void l10nMem_impl::saveLanguages(l10nMem& cMem, const std::string& sTargetDir,
bool bForce)
+{
+ int iE, iEsize = mcDb.mcENUSlist.size();
+ int iL, iLsize = mcDb.mcLangList.size();
+ int iCntDeleted = 0, iCntChanged = 0, iCntAdded = 0;
+ std::string sFileName = msModuleName + ".po";
+
+
+ // and reorganize db if needed
+ mcDb.miCurFileInx = 0;
+ mcDb.reorganize();
+
+ // no save if there has been errors
+ if(!needWrite(sFileName, bForce))
+ return;
// save all languages
- sFileName = msModuleName + ".po";
for (iL = 1; iL < iLsize; ++iL)
{
convert_gen savePo(cMem, sTargetDir, sTargetDir, sFileName);
@@ -421,21 +439,30 @@ void l10nMem_impl::convEntryKey(int
bool bIsFuzzy)
{
std::vector<int> ivEntryList;
- int i, iSize;
+ std::string curFileName;
+ std::string curKeyUpper;
+ int curFileIndex, curENUSindex, i, iSize;
// silent ignore deleted messages
if (sMsgId == "-" || sMsgId == "")
return;
+ // check for directory names in file name
+ i = sSourceFile.rfind("/");
+ if (i > 0)
+ curFileName = sSourceFile.substr(i+1);
+ else
+ curFileName = sSourceFile;
+
// Find all matching file names (old system does not have directory.
// build list of potential entries
iSize = mcDb.mcFileList.size();
- for (i = 1; i < iSize; ++i)
- if (sSourceFile == mcDb.mcFileList[i].msPureName)
+ for (curFileIndex = 1; curFileIndex < iSize; ++curFileIndex)
+ if (curFileName == mcDb.mcFileList[curFileIndex].msPureName)
{
- int j = mcDb.mcFileList[i].miStart;
- int iEnd = mcDb.mcFileList[i].miEnd;
+ int j = mcDb.mcFileList[curFileIndex].miStart;
+ int iEnd = mcDb.mcFileList[curFileIndex].miEnd;
for (; j <= iEnd; ++j)
ivEntryList.push_back(j);
@@ -445,97 +472,74 @@ void l10nMem_impl::convEntryKey(int
iSize = ivEntryList.size();
if (!iSize)
{
- showWarning("source file(" + sSourceFile + ") not in template file",
iLineNo);
+ showWarning("source file(" + curFileName + ") not in template file",
iLineNo);
return;
}
// Loop through all potential en-US entries
- for (i = 0; i < iSize; ++i)
+ for (curENUSindex = -1, i = 0; i < iSize; ++i)
{
- int z = ivEntryList[i];
l10nMem_enus_entry& curE = mcDb.mcENUSlist[ivEntryList[i]];
- // The entry must be unconverted and msgId must match
- if (curE.meState == l10nMem::ENTRY_DELETED && sMsgId == curE.msMsgId)
+
+ // The entry must be unconverted if strict mode (comparing .pot files)
+ if (mcDb.mbStrictMode && curE.meState != l10nMem::ENTRY_DELETED)
+ continue;
+
+ // msgId must match
+ if (sMsgId == curE.msMsgId)
{
- curE.meState = l10nMem::ENTRY_NORMAL;
+ curENUSindex = ivEntryList[i];
+ if (mcDb.mbStrictMode)
+ curE.meState = l10nMem::ENTRY_NORMAL;
break;
}
}
- if (i == iSize)
- {
- showWarning("file(" + sSourceFile + ") key(" + sKey + ") msgId(" + sMsgId
+ ") not found in templates", iLineNo);
- }
-
- if (mcDb.mbStrictMode)
- return;
+ // do we need to do advanced find
+ if (curENUSindex == -1 || mcDb.mbStrictMode)
+ {
+ // make copy of key in upper case
+ curKeyUpper = sKey;
+ l10nMem_db::keyToUpper(curKeyUpper);
-{
- std::string sKeyUpper;
+ // Loop through all potential en-US entries
+ for (i = 0; i < iSize; ++i)
+ {
+ l10nMem_enus_entry& curE = mcDb.mcENUSlist[ivEntryList[i]];
+ // compare keys, but be aware of different length
+ if (curKeyUpper.find(curE.msKey) != std::string::npos)
+ {
+ curENUSindex = ivEntryList[i];
+ bIsFuzzy = true;
+ break;
+ }
+ }
+ }
- // filter out dummy messages, silently
- if (convFilterWarning(sSourceFile, sKey, sMsgId))
+ if (curENUSindex == -1)
+ {
+ showWarning("file(" + curFileName + ") key(" + sKey + ") msgId(" + sMsgId
+ ") not found in templates", iLineNo);
return;
+ }
- // make copy of key in upper case
- sKeyUpper = sKey;
- l10nMem_db::keyToUpper(sKeyUpper);
-
-
+ // update language text
+ l10nMem_enus_entry& curE = mcDb.mcENUSlist[curENUSindex];
+ l10nMem_lang_entry& curL = curE.mcLangText[mcDb.miCurLangInx];
- // Loop through all potential en-US entries
- int iCandidate;
- for (iCandidate = -1, i = 0; i < iSize; ++i)
+ if (sMsgStr != curL.msMsgStr)
{
- l10nMem_enus_entry& curE = mcDb.mcENUSlist[ivEntryList[i]];
-
- // The entry cannot be converted twice
- if (curE.meState != l10nMem::ENTRY_NORMAL)
- continue;
-
- // The msgId must match
- if (sMsgId == curE.msMsgId)
- break;
-
- // compare keys, but be aware of different length
- if (sKeyUpper.find(curE.msKey) != std::string::npos)
- {
- // is this the second (or more candidate ? then we cannot use key
- if (iCandidate > 0)
- iCandidate = -1;
- else
- iCandidate = i;
- }
+ curL.msMsgStr = sMsgStr;
+ curL.mbFuzzy = bIsFuzzy;
+ curE.meState = l10nMem::ENTRY_CHANGED;
}
- sKeyUpper.clear();
- if (i == iSize && iCandidate < 0)
- sKeyUpper = "cannot be matched";
- else
- {
- // Primarely use text match, alternatively use key candidate
- if (i == iSize)
- {
- i = iCandidate;
- sKeyUpper = "could only be matched through KEY";
- }
- // update language text
- l10nMem_enus_entry& curE = mcDb.mcENUSlist[ivEntryList[i]];
- l10nMem_lang_entry& curL = curE.mcLangText[mcDb.miCurLangInx];
- if (sMsgStr != curL.msMsgStr)
- {
- curL.msMsgStr = sMsgStr;
- curL.mbFuzzy = bIsFuzzy;
- curE.meState = l10nMem::ENTRY_CHANGED;
- }
- if (sKeyUpper.size())
- {
- showWarning("file(" + sSourceFile + ") key(" + sKey + ") lang(" +
mcDb.mcLangList[mcDb.miCurLangInx] +
- ") with msgId(" + sMsgId + ") " + sKeyUpper, iLineNo);
- }
- }
- }
+
+#if 0
+ // filter out dummy messages, silently
+ if (convFilterWarning(sSourceFile, sKey, sMsgId))
+ return;
+#endif
}
Modified: openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.hxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.hxx?rev=1519235&r1=1519234&r2=1519235&view=diff
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.hxx (original)
+++ openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.hxx Sat Aug 31
23:43:50 2013
@@ -165,10 +165,13 @@ class l10nMem_impl
const std::string& sKey,
const std::string& sMsgId);
- void save (l10nMem& cMem,
- const std::string& sTargetDir,
- bool bKid,
- bool bForce);
+ void saveTemplates (l10nMem& cMem,
+ const std::string& sTargetDir,
+ bool bKid,
+ bool bForce);
+ void saveLanguages (l10nMem& cMem,
+ const std::string& sTargetDir,
+ bool bForce);
void dumpMem (const std::string& sTargetDir);
void showNOconvert();
Modified: openoffice/branches/l10n40/main/l10ntools/source/gLang.hxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gLang.hxx?rev=1519235&r1=1519234&r2=1519235&view=diff
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gLang.hxx (original)
+++ openoffice/branches/l10n40/main/l10ntools/source/gLang.hxx Sat Aug 31
23:43:50 2013
@@ -83,9 +83,11 @@ class l10nMem
const std::string& sKey,
const std::string& sText);
- void save (const std::string& sTargetDir,
+ void saveTemplates (const std::string& sTargetDir,
bool bKid,
bool bForce);
+ void saveLanguages (const std::string& sTargetDir,
+ bool bForce);
void dumpMem (const std::string& sTargetDir);
int prepareMerge ();