Author: jani Date: Tue Mar 12 22:59:49 2013 New Revision: 1455744 URL: http://svn.apache.org/r1455744 Log: convert works.
Modified: openoffice/branches/l10n/main/l10ntools/source/gConPolex.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 Modified: openoffice/branches/l10n/main/l10ntools/source/gConPolex.l URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPolex.l?rev=1455744&r1=1455743&r2=1455744&view=diff ============================================================================== --- openoffice/branches/l10n/main/l10ntools/source/gConPolex.l (original) +++ openoffice/branches/l10n/main/l10ntools/source/gConPolex.l Tue Mar 12 22:59:49 2013 @@ -89,6 +89,10 @@ SPACE [ \t]* LOCptr->setKey(yytext); } +"#~".*\r*\n { + // special comment, just skip +} + {SPACE}[mM][sS][gG][iI][dD]{SPACE} { LOCptr->setMsgId(yytext); Modified: openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx?rev=1455744&r1=1455743&r2=1455744&view=diff ============================================================================== --- openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx (original) +++ openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx Tue Mar 12 22:59:49 2013 @@ -302,7 +302,7 @@ void handler::runConvert() // get converter and extract files convert_gen convertObj(mcMemory, sFilePath, *siSource); - convertObj.execute(true, false); + convertObj.execute(true, 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=1455744&r1=1455743&r2=1455744&view=diff ============================================================================== --- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx (original) +++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx Tue Mar 12 22:59:49 2013 @@ -335,6 +335,24 @@ 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) +{ + if (sOrgText == "-" || + sSourceFile == "basic.src" || + sSourceFile == "basmsg.src" || + sSourceFile == "svtmsg.src" || + sSourceFile == "testtool.src" || + sSourceFile == "ttmsg.src" ) + return true; + + return false; +} + + + +/********************** 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, @@ -342,55 +360,58 @@ void l10nMem_impl::convEntryKey(int const std::string& sText, bool bIsFuzzy) { - int i, iSize; - std::string sNewKey = sKey; - + std::vector<int> ivEntryList; + int i, iSize = mcDb.mcFileList.size(); - // adjust miCurFileInx as needed - // same filename as last ? - if (sSourceFile != mcDb.mcFileList[mcDb.miCurFileInx].msPureName) - { - iSize = mcDb.mcFileList.size(); + // filter out dummy messages, silently + if (convFilterWarning(sSourceFile, sKey, sOrgText)) + return; - // match filename - for (i = 1; i < iSize && sSourceFile != mcDb.mcFileList[i].msPureName; ++i) ; - if (i == iSize) + // Find all matching file names + for (i = 1; i < iSize; ++i) + if (sSourceFile == mcDb.mcFileList[i].msPureName) { - showError("filename(" + sSourceFile + ") not found!", iLineNo); - return; + int j = mcDb.mcFileList[i].miStart; + int iEnd = mcDb.mcFileList[i].miEnd; + + for (; j <= iEnd; ++j) + ivEntryList.push_back(j); } - mcDb.miCurFileInx = i; - } - // Calculate possible entries - l10nMem_file_entry& curF = mcDb.mcFileList[mcDb.miCurFileInx]; - i = curF.miStart; - iSize = curF.miEnd; + // Did we find one or more files ? + iSize = ivEntryList.size(); + if (!iSize) + { + showWarning("filename(" + sSourceFile + ") key(" + sKey +") lang(" + + mcDb.mcLangList[mcDb.miCurLangInx] + ") not found!", iLineNo); + return; + } - // Loop through possible en_US entries - for (; i <= iSize; ++i) + // Loop through all potential en_US entries + for (i = 0; i < iSize; ++i) { - l10nMem_enus_entry& curE = mcDb.mcENUSlist[i]; + l10nMem_enus_entry& curE = mcDb.mcENUSlist[ivEntryList[i]]; // The entry cannot be converted twice if (curE.meState != l10nMem::ENTRY_NORMAL) continue; - // The text must match + // The msgId must match if (sOrgText != curE.msText) continue; - // The keys must match - if (sNewKey != curE.msKey) - continue; - // update language text l10nMem_lang_entry& curL = curE.mcLangList[mcDb.miCurLangInx]; - curL.msText = sText; - curL.mbFuzzy = bIsFuzzy; - curE.meState = l10nMem::ENTRY_CHANGED; + + if (sText != curL.msText) + { + curL.msText = sText; + curL.mbFuzzy = bIsFuzzy; + curE.meState = l10nMem::ENTRY_CHANGED; + } return; } - showError("key(" + sKey + ") with msgId(" + sOrgText + ") cannot be matched", iLineNo); + showWarning("key(" + sKey + ") lang(" + mcDb.mcLangList[mcDb.miCurLangInx] + + ") with msgId(" + sOrgText + ") cannot be matched", iLineNo); } Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx?rev=1455744&r1=1455743&r2=1455744&view=diff ============================================================================== --- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx (original) +++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx Tue Mar 12 22:59:49 2013 @@ -172,6 +172,9 @@ class l10nMem_impl void formatAndShowText(const std::string& sType, int iLineNo, const std::string& sText); bool needWrite (const std::string sFileName, bool bForce); + bool convFilterWarning(const std::string& sSourceFile, + const std::string& sKey, + const std::string& sOrgText); void convEntryKey (int iLineNo, const std::string& sSourceFile, const std::string& sKey,