Author: jani
Date: Mon Aug 26 20:03:22 2013
New Revision: 1517671
URL: http://svn.apache.org/r1517671
Log:
added check of templates (to compare with old system)
Modified:
openoffice/branches/l10n40/main/l10ntools/source/gConPoWrap.cxx
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/gL10nMemDB.cxx
openoffice/branches/l10n40/main/l10ntools/source/gLang.hxx
Modified: openoffice/branches/l10n40/main/l10ntools/source/gConPoWrap.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConPoWrap.cxx?rev=1517671&r1=1517670&r2=1517671&view=diff
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConPoWrap.cxx (original)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConPoWrap.cxx Mon Aug 26
20:03:22 2013
@@ -70,7 +70,7 @@ void convert_po::startLook()
int i;
- if (!msKey.size() || !msId.size() || !msStr.size())
+ if (!msKey.size() || !msId.size())
return;
// split key into filename and real key
Modified: openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx?rev=1517671&r1=1517670&r2=1517671&view=diff
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx (original)
+++ openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx Mon Aug 26
20:03:22 2013
@@ -267,6 +267,9 @@ void handler::run()
/********************** I M P L E M E N T A T I O N **********************/
void handler::runExtract()
{
+ // no convert
+ mcMemory.setConvert(false, false);
+
// loop through all source files, and extract messages from each file
for (std::vector<std::string>::iterator siSource = mvSourceFiles.begin();
siSource != mvSourceFiles.end(); ++siSource)
{
@@ -287,6 +290,9 @@ void handler::runExtract()
/********************** I M P L E M E N T A T I O N **********************/
void handler::runMerge(bool bKid)
{
+ // no convert
+ mcMemory.setConvert(false, false);
+
// loop through all source files, and extract messages from each file
for (std::vector<std::string>::iterator siSource = mvSourceFiles.begin();
siSource != mvSourceFiles.end(); ++siSource)
{
@@ -307,6 +313,9 @@ void handler::runMerge(bool bKid)
/********************** I M P L E M E N T A T I O N **********************/
void handler::runConvert(bool bPot)
{
+ // convert
+ mcMemory.setConvert(true, bPot);
+
// loop through all source files, and extract messages from each file
for (std::vector<std::string>::iterator siSource = mvSourceFiles.begin();
siSource != mvSourceFiles.end(); ++siSource)
{
@@ -315,6 +324,13 @@ void handler::runConvert(bool bPot)
{
// tell system
l10nMem::showDebug("genLang compare template " + msSourceDir +
*siSource);
+
+ // get converter and extract files
+ convert_gen convertObj(mcMemory, "./", msTargetDir, *siSource);
+ convertObj.execute(false);
+
+ if (bPot)
+ mcMemory.showNOconvert();
}
else
for (std::vector<std::string>::iterator siLang = mvLanguages.begin();
siLang != mvLanguages.end(); ++siLang)
@@ -322,7 +338,7 @@ void handler::runConvert(bool bPot)
std::string sFilePath = msSourceDir + *siLang + "/";
// get converter and extract files
- mcMemory.setLanguage(*siLang, false, true);
+ mcMemory.setLanguage(*siLang, false);
// tell system
l10nMem::showDebug("genLang convert text from file " + sFilePath +
*siSource + " language " + *siLang);
@@ -330,11 +346,15 @@ 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
- mcMemory.save(msPoOutDir, false, mbForceSave);
+ if (!bPot)
+ mcMemory.save(msPoOutDir, false, mbForceSave);
}
@@ -453,6 +473,8 @@ void handler::loadL10MEM(bool onlyTempla
std::string sMod = msModuleName + ".pot";
std::string sLoad = msPoDir + "templates/";
+ // no convert
+ mcMemory.setConvert(false, false);
// load texts from en-US po file (master)
{
@@ -460,7 +482,7 @@ void handler::loadL10MEM(bool onlyTempla
l10nMem::showDebug("genLang loading master text from file " + sLoad +
sMod);
// and load file
- mcMemory.setLanguage("", true, false);
+ mcMemory.setLanguage("", true);
convert_gen (mcMemory, sLoad, msTargetDir, sMod).execute(false);
}
@@ -474,7 +496,7 @@ void handler::loadL10MEM(bool onlyTempla
sLoad = msPoDir + *siLang + "/";
// get converter and extract files
- mcMemory.setLanguage(*siLang, true, false);
+ mcMemory.setLanguage(*siLang, true);
// tell system
l10nMem::showDebug("genLang loading text from language file " + sLoad +
sMod);
Modified: openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.cxx?rev=1517671&r1=1517670&r2=1517671&view=diff
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.cxx (original)
+++ openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.cxx Mon Aug 26
20:03:22 2013
@@ -87,14 +87,19 @@ bool l10nMem::isError()
{ 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::setLanguage(const std::string& sL, bool bC)
+ { l10nMem_impl::mcImpl->mcDb.setLanguage(sL, bC); }
+void l10nMem::setConvert(bool bC, bool bS)
+ { l10nMem_impl::mcImpl->mcDb.setConvert(bC, bS); }
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); }
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::showNOconvert ()
+ { l10nMem_impl::mcImpl->showNOconvert(); }
+
int l10nMem::prepareMerge()
{ return l10nMem_impl::mcImpl->mcDb.prepareMerge(); }
void l10nMem::dumpMem(const std::string& sT)
@@ -169,16 +174,16 @@ void l10nMem_impl::setModuleName(const s
void l10nMem_impl::loadEntryKey(int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sOrgText,
- const std::string& sText,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
bool bIsFuzzy)
{
- if (!mcDb.miCurLangInx)
- mcDb.loadENUSkey(iLineNo, sSourceFile, sKey, sText);
- else if (mcDb.mbConvertMode)
- convEntryKey(iLineNo, sSourceFile, sKey, sOrgText, sText, bIsFuzzy);
+ if (mcDb.mbConvertMode)
+ convEntryKey(iLineNo, sSourceFile, sKey, sMsgId, sMsgStr, bIsFuzzy);
+ else if (!mcDb.miCurLangInx)
+ mcDb.loadENUSkey(iLineNo, sSourceFile, sKey, sMsgId);
else
- mcDb.loadLangKey(iLineNo, sSourceFile, sKey, sOrgText, sText, bIsFuzzy);
+ mcDb.loadLangKey(iLineNo, sSourceFile, sKey, sMsgId, sMsgStr, bIsFuzzy);
}
@@ -187,9 +192,9 @@ void l10nMem_impl::loadEntryKey(int
void l10nMem_impl::setSourceKey(int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sText)
+ const std::string& sMsgId)
{
- std::string newText(sText);
+ std::string newText(sMsgId);
int i;
@@ -257,7 +262,7 @@ void l10nMem_impl::save(l10nMem& cMem, c
if (cE.meState == l10nMem::ENTRY_DELETED)
continue;
- savePo.save(mcDb.mcFileList[cE.miFileInx].msFileName, cE.msUpperKey,
cE.msText, "", false);
+ savePo.save(mcDb.mcFileList[cE.miFileInx].msFileName, cE.msKey,
cE.msMsgId, "", false);
}
savePo.endSave();
}
@@ -279,7 +284,7 @@ void l10nMem_impl::save(l10nMem& cMem, c
if (cE.meState == l10nMem::ENTRY_DELETED)
continue;
- savePo.save(mcDb.mcFileList[cE.miFileInx].msFileName, cE.msKey,
cE.msText, cL.msText, bF);
+ savePo.save(mcDb.mcFileList[cE.miFileInx].msFileName, cE.msKey,
cE.msMsgId, cL.msMsgStr, bF);
}
savePo.endSave();
}
@@ -288,6 +293,24 @@ void l10nMem_impl::save(l10nMem& cMem, c
/********************** I M P L E M E N T A T I O N **********************/
+void l10nMem_impl::showNOconvert ()
+{
+ int iE, iEsize = mcDb.mcENUSlist.size();
+
+ for (iE = 1; iE < iEsize; ++iE)
+ {
+ l10nMem_enus_entry& cE = mcDb.mcENUSlist[iE];
+
+ if (cE.meState == l10nMem::ENTRY_DELETED)
+ {
+ showError("template key(" + cE.msKey + ") msgId(" + cE.msMsgId + ") not
in pot file", 0);
+ }
+ }
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
void l10nMem_impl::dumpMem(const std::string& sFileName)
{
// and reorganize db if needed
@@ -366,9 +389,9 @@ bool l10nMem_impl::needWrite(const std::
/********************** I M P L E M E N T A T I O N **********************/
bool l10nMem_impl::convFilterWarning(const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sOrgText)
+ const std::string& sMsgId)
{
- if (sOrgText == "-")
+ if (sMsgId == "-")
return true;
if (msModuleName == "basic")
@@ -390,27 +413,17 @@ bool l10nMem_impl::convFilterWarning(con
void l10nMem_impl::convEntryKey(int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sOrgText,
- const std::string& sText,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
bool bIsFuzzy)
{
std::vector<int> ivEntryList;
- std::string sKeyUpper;
- int i, iSize, iCandidate;
+ int i, iSize;
- // filter out dummy messages, silently
- if (!sText.size() || convFilterWarning(sSourceFile, sKey, sOrgText))
- return;
-
- // make copy of key in upper case
- iSize = sKey.size();
- sKeyUpper = sKey;
- for (i = 0; i < iSize; ++i)
- sKeyUpper[i] = toupper(sKeyUpper[i]);
-
- // Find all matching file names
- iSize = mcDb.mcFileList.size();
+ // 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)
{
@@ -425,12 +438,47 @@ void l10nMem_impl::convEntryKey(int
iSize = ivEntryList.size();
if (!iSize)
{
- showWarning("file(" + sSourceFile + ") key(" + sKey + ") lang(" +
mcDb.mcLangList[mcDb.miCurLangInx] +
- ") with msgId(" + sOrgText + ") file not found", iLineNo);
+ showWarning("source file(" + sSourceFile + ") not in template file",
iLineNo);
return;
}
// Loop through all potential en-US entries
+ for (i = 0; i < iSize; ++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)
+ {
+ 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;
+
+
+{
+ std::string sKeyUpper;
+
+
+ // filter out dummy messages, silently
+ if (convFilterWarning(sSourceFile, sKey, sMsgId))
+ return;
+
+ // make copy of key in upper case
+ sKeyUpper = sKey;
+ l10nMem_db::keyToUpper(sKeyUpper);
+
+
+
+ // Loop through all potential en-US entries
+ int iCandidate;
for (iCandidate = -1, i = 0; i < iSize; ++i)
{
l10nMem_enus_entry& curE = mcDb.mcENUSlist[ivEntryList[i]];
@@ -440,11 +488,11 @@ void l10nMem_impl::convEntryKey(int
continue;
// The msgId must match
- if (sOrgText == curE.msText)
+ if (sMsgId == curE.msMsgId)
break;
// compare keys, but be aware of different length
- if (sKeyUpper.find(curE.msUpperKey) != std::string::npos)
+ if (sKeyUpper.find(curE.msKey) != std::string::npos)
{
// is this the second (or more candidate ? then we cannot use key
if (iCandidate > 0)
@@ -469,16 +517,17 @@ void l10nMem_impl::convEntryKey(int
l10nMem_enus_entry& curE = mcDb.mcENUSlist[ivEntryList[i]];
l10nMem_lang_entry& curL = curE.mcLangText[mcDb.miCurLangInx];
- if (sText != curL.msText)
+ if (sMsgStr != curL.msMsgStr)
{
- curL.msText = sText;
- curL.mbFuzzy = bIsFuzzy;
- curE.meState = l10nMem::ENTRY_CHANGED;
+ 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(" + sOrgText + ") " + sKeyUpper, iLineNo);
+ ") with msgId(" + sMsgId + ") " + sKeyUpper, iLineNo);
}
}
+ }
}
Modified: openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.hxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.hxx?rev=1517671&r1=1517670&r2=1517671&view=diff
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.hxx (original)
+++ openoffice/branches/l10n40/main/l10ntools/source/gL10nMem.hxx Mon Aug 26
20:03:22 2013
@@ -37,10 +37,10 @@
class l10nMem_lang_entry
{
public:
- l10nMem_lang_entry(const std::string& sText, bool bFuzzy);
+ l10nMem_lang_entry(const std::string& sMsgStr, bool bFuzzy);
~l10nMem_lang_entry();
- std::string msText; // translated text from po file
+ std::string msMsgStr; // translated text from po file
bool mbFuzzy; // fuzzy flag
};
@@ -51,7 +51,7 @@ class l10nMem_enus_entry
{
public:
l10nMem_enus_entry(const std::string& sKey,
- const std::string& sText,
+ const std::string& sMsgId,
int iLineNo,
int iFileInx,
int iLangSize,
@@ -59,8 +59,7 @@ class l10nMem_enus_entry
~l10nMem_enus_entry();
std::string msKey; // key in po file and source
file
- std::string msUpperKey; // key converted to uppercase
(for compare)
- std::string msText; // en-US text from source file
+ std::string msMsgId; // en-US text from source file
l10nMem::ENTRY_STATE meState; // status information
int miFileInx; // index of file name
int miLineNo; // line number
@@ -96,6 +95,7 @@ class l10nMem_db
int miCurENUSinx;
bool mbNeedWrite;
bool mbConvertMode;
+ bool mbStrictMode;
std::vector<l10nMem_enus_entry> mcENUSlist;
std::vector<l10nMem_file_entry> mcFileList;
std::vector<std::string> mcLangList;
@@ -104,35 +104,38 @@ class l10nMem_db
void loadENUSkey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sText);
+ const std::string& sMsgId);
void setLanguage (const std::string& sLanguage,
- bool bCreate,
- bool bConvert);
+ bool bCreate);
+ void setConvert (bool bConvert,
+ bool bStrict);
bool findFileName (const std::string& sSourceFile);
void loadLangKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sOrgText,
- const std::string& sText,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
bool bFuzzy);
bool locateKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sText,
+ const std::string& sMsgId,
bool bThrow);
void reorganize ();
void addKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sText,
+ const std::string& sMsgId,
l10nMem::ENTRY_STATE eStat);
int prepareMerge ();
bool getMergeLang (std::string& sLang,
std::string& sText);
bool getLangList (std::string& sLang);
+
+static void keyToUpper(std::string& sKey);
};
@@ -154,19 +157,20 @@ class l10nMem_impl
void loadEntryKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sOrgText,
- const std::string& sText,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
bool bIsFuzzy);
void setSourceKey (int iLineNo,
const std::string& sFilename,
const std::string& sKey,
- const std::string& sText);
+ const std::string& sMsgId);
void save (l10nMem& cMem,
const std::string& sTargetDir,
bool bKid,
bool bForce);
void dumpMem (const std::string& sTargetDir);
+ void showNOconvert();
private:
static bool mbVerbose;
@@ -180,12 +184,12 @@ class l10nMem_impl
bool needWrite (const std::string sFileName, bool bForce);
bool convFilterWarning(const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sOrgText);
+ const std::string& sMsgId);
void convEntryKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sOrgText,
- const std::string& sText,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
bool bIsFuzzy);
friend class l10nMem;
Modified: openoffice/branches/l10n40/main/l10ntools/source/gL10nMemDB.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gL10nMemDB.cxx?rev=1517671&r1=1517670&r2=1517671&view=diff
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gL10nMemDB.cxx (original)
+++ openoffice/branches/l10n40/main/l10ntools/source/gL10nMemDB.cxx Mon Aug 26
20:03:22 2013
@@ -38,9 +38,9 @@
/********************** I M P L E M E N T A T I O N **********************/
-l10nMem_lang_entry::l10nMem_lang_entry(const std::string& sText, bool bFuzzy)
+l10nMem_lang_entry::l10nMem_lang_entry(const std::string& sMsgStr, bool bFuzzy)
:
- msText(sText),
+ msMsgStr(sMsgStr),
mbFuzzy(bFuzzy)
{
}
@@ -56,36 +56,26 @@ l10nMem_lang_entry::~l10nMem_lang_entry(
/********************** I M P L E M E N T A T I O N **********************/
l10nMem_enus_entry::l10nMem_enus_entry(const std::string& sKey,
- const std::string& sText,
+ const std::string& sMsgId,
int iLineNo,
int iFileInx,
int iLangSize,
l10nMem::ENTRY_STATE eState)
:
- msKey(sKey),
- msText(sText),
+ msMsgId(sMsgId),
meState(eState),
miFileInx(iFileInx),
miLineNo(iLineNo)
{
- int i, iSize;
- char ch;
+ int i;
// add dummy language entries
for (i = 0; i < iLangSize; ++i)
mcLangText.push_back(l10nMem_lang_entry("", false));
// convert key to upper case
- iSize = sKey.size();
- msUpperKey = sKey;
- for (i = 0; i < iSize; ++i)
- {
- ch = msUpperKey[i];
- if (ch == ' ' || ch == '*' || ch == '+' || ch == '%')
- msUpperKey[i] = '_';
- else
- msUpperKey[i] = toupper(msUpperKey[i]);
- }
+ msKey = sKey;
+ l10nMem_db::keyToUpper(msKey);
}
@@ -128,7 +118,8 @@ l10nMem_db::l10nMem_db()
miCurLangInx(0),
miCurENUSinx(0),
mbNeedWrite(false),
- mbConvertMode(false)
+ mbConvertMode(false),
+ mbStrictMode(false)
{
mcFileList.push_back(l10nMem_file_entry("-genLang-", 0));
mcLangList.push_back("-genLang-");
@@ -148,29 +139,21 @@ l10nMem_db::~l10nMem_db()
void l10nMem_db::loadENUSkey(int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sText)
+ const std::string& sMsgId)
{
// add it to vector and update file pointer
- addKey(iLineNo, sSourceFile, sKey, sText, l10nMem::ENTRY_DELETED);
+ addKey(iLineNo, sSourceFile, sKey, sMsgId, l10nMem::ENTRY_DELETED);
}
/********************** 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 bConvert)
+ bool bCreate)
{
int i, iSize;
// regular load or convert of old po files
- if (bConvert)
- {
- iSize = mcENUSlist.size();
- for (i = 0; i < iSize; ++i)
- mcENUSlist[i].meState = l10nMem::ENTRY_NORMAL;
- }
- mbConvertMode = bConvert;
miCurFileInx = 0;
// With no languages selected only en-US is generated
@@ -210,6 +193,17 @@ void l10nMem_db::setLanguage(const std::
/********************** I M P L E M E N T A T I O N **********************/
+void l10nMem_db::setConvert(bool bConvert,
+ bool bStrict)
+{
+ // regular load or convert of old po files
+ mbConvertMode = bConvert;
+ mbStrictMode = bStrict;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
bool l10nMem_db::findFileName(const std::string& sSourceFile)
{
int iSize = mcFileList.size();
@@ -238,15 +232,15 @@ bool l10nMem_db::findFileName(const std:
void l10nMem_db::loadLangKey(int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sOrgText,
- const std::string& sText,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
bool bFuzzy)
{
- if (!locateKey(iLineNo, sSourceFile, sKey, sOrgText, true))
+ if (!locateKey(iLineNo, sSourceFile, sKey, sMsgId, true))
throw l10nMem::showError(".po file contains unknown filename: " +
sSourceFile + " or key: " + sKey);
l10nMem_lang_entry& xCur = mcENUSlist[miCurENUSinx].mcLangText[miCurLangInx];
- xCur.msText = sText;
+ xCur.msMsgStr = sMsgStr;
xCur.mbFuzzy = bFuzzy;
}
@@ -287,7 +281,7 @@ void l10nMem_db::reorganize()
continue;
if (curE.msKey == curAdd.msKey)
break;
- if (curE.msText == curAdd.msText)
+ if (curE.msMsgId == curAdd.msMsgId)
break;
}
if (iD == iDsize)
@@ -295,7 +289,7 @@ void l10nMem_db::reorganize()
// Update deleted entry (original), because lang is connected here
l10nMem_enus_entry& curDel = mcENUSlist[listDel[iD]];
- curDel.msText = curAdd.msText;
+ curDel.msMsgId = curAdd.msMsgId;
curDel.msKey = curAdd.msKey;
curDel.meState = l10nMem::ENTRY_CHANGED;
curAdd.meState = l10nMem::ENTRY_DELETED;
@@ -308,7 +302,7 @@ void l10nMem_db::reorganize()
bool l10nMem_db::locateKey(int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sText,
+ const std::string& sMsgId,
bool bThrow)
{
std::string sUpperKey(sKey);
@@ -323,7 +317,7 @@ bool l10nMem_db::locateKey(int
if (++miCurENUSinx < (int)mcENUSlist.size())
{
l10nMem_enus_entry& nowEntry = mcENUSlist[miCurENUSinx];
- if (nowEntry.msText == sText && nowEntry.msKey == sKey)
+ if (nowEntry.msMsgId == sMsgId && nowEntry.msKey == sKey)
return true;
}
@@ -344,12 +338,12 @@ bool l10nMem_db::locateKey(int
for (miCurENUSinx = cCur.miStart; miCurENUSinx <= cCur.miEnd; ++miCurENUSinx)
{
l10nMem_enus_entry& cEntry = mcENUSlist[miCurENUSinx];
- if (cEntry.msText == sText && cEntry.msKey == sUpperKey)
+ if (cEntry.msMsgId == sMsgId && cEntry.msKey == sUpperKey)
return true;
}
if (bThrow)
- throw l10nMem::showError("cannot find key(" + sKey +") with text(" + sText
+ ")", iLineNo);
+ throw l10nMem::showError("cannot find key(" + sKey +") with text(" +
sMsgId + ")", iLineNo);
return false;
}
@@ -359,7 +353,7 @@ bool l10nMem_db::locateKey(int
void l10nMem_db::addKey(int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
- const std::string& sText,
+ const std::string& sMsgId,
l10nMem::ENTRY_STATE eStat)
{
// check file
@@ -373,7 +367,7 @@ void l10nMem_db::addKey(int
mcFileList.push_back(l10nMem_file_entry(sSourceFile, miCurENUSinx));
// and add entry at the back (no problem since it is a new file)
- mcENUSlist.push_back(l10nMem_enus_entry(sKey, sText, iLineNo, miCurFileInx,
+ mcENUSlist.push_back(l10nMem_enus_entry(sKey, sMsgId, iLineNo,
miCurFileInx,
mcLangList.size(), eStat));
mcFileList[miCurFileInx].miEnd = miCurENUSinx;
}
@@ -387,7 +381,7 @@ void l10nMem_db::addKey(int
curF.miEnd++;
miCurENUSinx = curF.miEnd;
mcENUSlist.insert(it + curF.miEnd,
- l10nMem_enus_entry(sKey, sText, iLineNo, miCurFileInx,
+ l10nMem_enus_entry(sKey, sMsgId, iLineNo, miCurFileInx,
mcLangList.size(), eStat));
for (int i = miCurFileInx+1; i < iFsize; ++i)
{
@@ -413,7 +407,7 @@ int l10nMem_db::prepareMerge()
/********************** I M P L E M E N T A T I O N **********************/
bool l10nMem_db::getMergeLang(std::string& sLang,
- std::string& sText)
+ std::string& sMsgStr)
{
miCurLangInx++;
if (miCurLangInx >= (int)mcLangList.size())
@@ -423,12 +417,30 @@ bool l10nMem_db::getMergeLang(std::strin
if (!miCurLangInx)
{
sLang = "en-US";
- sText = mcENUSlist[miCurENUSinx].msText;
+ sMsgStr = mcENUSlist[miCurENUSinx].msMsgId;
}
else
{
sLang = mcLangList[miCurLangInx];
- sText = mcENUSlist[miCurENUSinx].mcLangText[miCurLangInx].msText;
+ sMsgStr = mcENUSlist[miCurENUSinx].mcLangText[miCurLangInx].msMsgStr;
}
return true;
}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void l10nMem_db::keyToUpper(std::string& sKey)
+{
+ int i, iSize;
+
+ iSize = sKey.size();
+ for (i = 0; i < iSize; ++i)
+ {
+ char ch = sKey[i];
+ if (ch == ' ' || ch == '*' || ch == '+' || ch == '%')
+ sKey[i] = '_';
+ else
+ sKey[i] = toupper(ch);
+ }
+}
Modified: openoffice/branches/l10n40/main/l10ntools/source/gLang.hxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gLang.hxx?rev=1517671&r1=1517670&r2=1517671&view=diff
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gLang.hxx (original)
+++ openoffice/branches/l10n40/main/l10ntools/source/gLang.hxx Mon Aug 26
20:03:22 2013
@@ -68,8 +68,9 @@ class l10nMem
void setModuleName (const std::string& sModuleName);
void setLanguage (const std::string& sLanguage,
- bool bCreate,
- bool bConvert);
+ bool bCreate);
+ void setConvert (bool bConvert,
+ bool bStrict);
void loadEntryKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
@@ -90,6 +91,7 @@ class l10nMem
int prepareMerge ();
bool getMergeLang (std::string& sLang,
std::string& sText);
+ void showNOconvert ();
};