summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--l10ntools/Executable_genlang.mk1
-rw-r--r--l10ntools/inc/gL10nMem.hxx79
-rw-r--r--l10ntools/inc/gLang.hxx195
-rw-r--r--l10ntools/source/gConv.cxx5
-rw-r--r--l10ntools/source/gConvProp.cxx2
-rw-r--r--l10ntools/source/gL10nMem.cxx963
-rw-r--r--l10ntools/source/gL10nMemDB.cxx10
-rw-r--r--l10ntools/source/gLang.cxx23
8 files changed, 518 insertions, 760 deletions
diff --git a/l10ntools/Executable_genlang.mk b/l10ntools/Executable_genlang.mk
index b6656c225533..13789e016d44 100644
--- a/l10ntools/Executable_genlang.mk
+++ b/l10ntools/Executable_genlang.mk
@@ -29,7 +29,6 @@ $(eval $(call gb_Executable_add_exception_objects,genlang,\
l10ntools/source/gLang \
l10ntools/source/gL10nMem \
l10ntools/source/gL10nMemDB \
- l10ntools/source/gHandler \
l10ntools/source/gConvProp \
l10ntools/source/gConv \
l10ntools/source/gConvDB \
diff --git a/l10ntools/inc/gL10nMem.hxx b/l10ntools/inc/gL10nMem.hxx
index 1da50af28bcc..e7dcd705bab9 100644
--- a/l10ntools/inc/gL10nMem.hxx
+++ b/l10ntools/inc/gL10nMem.hxx
@@ -23,16 +23,6 @@
-/*****************************************************************************
- ************************ G L 1 0 N M E M . H X X ************************
- *****************************************************************************
- * This is the class definition header of the l10n localizer program,
- * all global classes and their interrelations is defined here
- *****************************************************************************/
-
-
-
-/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_lang_entry
{
public:
@@ -45,7 +35,6 @@ class l10nMem_lang_entry
-/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_enus_entry
{
public:
@@ -67,7 +56,6 @@ class l10nMem_enus_entry
-/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_file_entry
{
public:
@@ -82,7 +70,6 @@ class l10nMem_file_entry
-/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_lang_list_entry
{
public:
@@ -95,7 +82,6 @@ class l10nMem_lang_list_entry
-/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_db
{
public:
@@ -149,69 +135,4 @@ class l10nMem_db
static void keyToUpper(std::string& sKey);
};
-
-
-
-
-/******************** C L A S S D E F I N I T I O N ********************/
-class l10nMem_impl
-{
- public:
- l10nMem_impl();
- ~l10nMem_impl();
-
- int showError (const std::string& sText, int iLineNo);
- int showWarning (const std::string& sText, int iLineNo);
- void showDebug (const std::string& sText, int iLineNo);
- void showVerbose (const std::string& sText, int iLineNo);
-
- void setModuleName (const std::string& sModuleName);
- const std::string& getModuleName (void);
- void loadEntryKey (int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- 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& sMsgId,
- bool bMustExist);
-
- 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();
-
- void convertToInetString(std::string& sText);
- void convertFromInetString(std::string& sText);
-
- private:
- static bool mbVerbose;
- static bool mbDebug;
- static l10nMem_impl *mcImpl;
- l10nMem_db mcDb;
- std::string msModuleName;
- bool mbInError;
-
- 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& sMsgId);
- void convEntryKey (int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sMsgId,
- const std::string& sMsgStr,
- bool bIsFuzzy);
-
- friend class l10nMem;
-};
#endif
diff --git a/l10ntools/inc/gLang.hxx b/l10ntools/inc/gLang.hxx
index ed3553881095..381d4d9df669 100644
--- a/l10ntools/inc/gLang.hxx
+++ b/l10ntools/inc/gLang.hxx
@@ -16,7 +16,6 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-
#ifndef GLANG_HXX
#define GLANG_HXX
#include <string>
@@ -24,107 +23,113 @@
-/*****************************************************************************
- *************************** G L A N G . H X X ***************************
- *****************************************************************************
- * This is the class definition header of the l10n localizer program,
- * all global classes and their interrelations is defined here
- *****************************************************************************/
-
-
-
-/******************* G L O B A L D E F I N I T I O N *******************/
-
-
-
-
-
-
-/******************** C L A S S D E F I N I T I O N ********************/
-class l10nMem_impl;
+class l10nMem_db;
class l10nMem
{
- public:
- l10nMem();
- ~l10nMem();
-
- typedef enum
- {
- ENTRY_DELETED,
- ENTRY_ADDED,
- ENTRY_CHANGED,
- ENTRY_NORMAL
- } ENTRY_STATE;
-
- static void setShowVerbose ();
- static void setShowDebug ();
-
- static int showError (const std::string& sText, int iLineNo = 0);
- static int showWarning (const std::string& sText, int iLineNo = 0);
- static void showDebug (const std::string& sText, int iLineNo = 0);
- static void showVerbose (const std::string& sText, int iLineNo = 0);
- bool isError ();
-
- void setModuleName (const std::string& sModuleName);
- const std::string& getModuleName (void);
- void setLanguage (const std::string& sLanguage,
- bool bCreate);
- void setConvert (bool bConvert,
- bool bStrict);
- 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,
- bool bMustExist);
-
- 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 ();
- bool getMergeLang (std::string& sLang,
- std::string& sText);
- void showNOconvert ();
-
- void convertToInetString(std::string& sText);
- void convertFromInetString(std::string& sText);
+ public:
+ l10nMem();
+ ~l10nMem();
+
+ static int showError(const std::string& sText, int iLineNo = 0);
+ static void showWarning(const std::string& sText, int iLineNo = 0);
+ static void showDebug(const std::string& sText, int iLineNo = 0);
+ static void showVerbose(const std::string& sText, int iLineNo = 0);
+ static bool isError();
+
+ void setModuleName (const std::string& sModuleName);
+ const std::string& getModuleName (void);
+ void setLanguage (const std::string& sLanguage,
+ bool bCreate);
+ void setConvert (bool bConvert,
+ bool bStrict);
+ 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,
+ bool bMustExist);
+
+ void saveTemplates (const std::string& sTargetDir,
+ bool bKid,
+ bool bForce);
+ void saveLanguages(l10nMem& cMem,
+ const std::string& sTargetDir,
+ bool bForce);
+ void dumpMem (const std::string& sTargetDir);
+
+ int prepareMerge ();
+ bool getMergeLang (std::string& sLang,
+ std::string& sText);
+ void showNOconvert ();
+
+ void convertToInetString(std::string& sText);
+ void convertFromInetString(std::string& sText);
+
+ private:
+ l10nMem_db *mcDb;
+ bool mbVerbose;
+ bool mbDebug;
+ bool mbInError;
+ typedef enum
+ {
+ ENTRY_DELETED,
+ ENTRY_ADDED,
+ ENTRY_CHANGED,
+ ENTRY_NORMAL
+ } ENTRY_STATE;
+ std::string msModuleName;
+
+ 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& sMsgId);
+ void convEntryKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
+ bool bIsFuzzy);
+ void saveTemplates(l10nMem& cMem,
+ const std::string& sTargetDir,
+ bool bKid,
+ bool bForce);
+
+ friend class handler;
+ friend class l10nMem_enus_entry;
+ friend class l10nMem_db;
};
-/******************** C L A S S D E F I N I T I O N ********************/
class convert_gen
{
- public:
- convert_gen(l10nMem& cMemory,
- const std::string& sSourceDir,
- const std::string& sTargetDir,
- const std::string& sSourceFile);
- ~convert_gen();
-
- // do extract/merge
- bool execute(const bool bMerge, const bool bKid);
-
- // ONLY po should implement these functions
- void startSave(const std::string& sLanguage,
- const std::string& sFile);
- void save(const std::string& sFileName,
- const std::string& sKey,
- const std::string& sENUStext,
- const std::string& sText,
- bool bFuzzy);
- void endSave();
- static bool checkAccess(std::string& sFile);
- static bool createDir(std::string& sDir, std::string& sFile);
+ public:
+ convert_gen(l10nMem& cMemory,
+ const std::string& sSourceDir,
+ const std::string& sTargetDir,
+ const std::string& sSourceFile);
+ ~convert_gen();
+
+ // do extract/merge
+ bool execute(const bool bMerge, const bool bKid);
+
+ // ONLY po should implement these functions
+ void startSave(const std::string& sLanguage,
+ const std::string& sFile);
+ void save(const std::string& sFileName,
+ const std::string& sKey,
+ const std::string& sENUStext,
+ const std::string& sText,
+ bool bFuzzy);
+ void endSave();
+ static bool checkAccess(std::string& sFile);
+ static bool createDir(std::string& sDir, std::string& sFile);
};
#endif
diff --git a/l10ntools/source/gConv.cxx b/l10ntools/source/gConv.cxx
index ff16706d9076..164b245addcf 100644
--- a/l10ntools/source/gConv.cxx
+++ b/l10ntools/source/gConv.cxx
@@ -302,12 +302,13 @@ void convert_gen_impl::lexRead(char *sBuf, int *nResult, int nMax_size)
// space enough for the whole line ?
if (*nResult <= nMax_size)
{
- msSourceBuffer.copy(sBuf, *nResult, miSourceReadIndex);
+// msSourceBuffer.copy(sBuf, *nResult, miSourceReadIndex);
+ l10nMem::showDebug(sBuf);
miSourceReadIndex = -1;
}
else
{
- msSourceBuffer.copy(sBuf, nMax_size, miSourceReadIndex);
+// msSourceBuffer.copy(sBuf, nMax_size, miSourceReadIndex);
*nResult = nMax_size;
miSourceReadIndex += nMax_size;
}
diff --git a/l10ntools/source/gConvProp.cxx b/l10ntools/source/gConvProp.cxx
index 159325d02d34..a5067614b4ff 100644
--- a/l10ntools/source/gConvProp.cxx
+++ b/l10ntools/source/gConvProp.cxx
@@ -32,7 +32,7 @@
/********************** I M P L E M E N T A T I O N **********************/
convert_prop::convert_prop(l10nMem& crMemory) : convert_gen_impl(crMemory)
{
- throw l10nMem::showError(std::string("convert_prop not implemented"));
+// throw l10nMem::showError(std::string("convert_prop not implemented"));
}
diff --git a/l10ntools/source/gL10nMem.cxx b/l10ntools/source/gL10nMem.cxx
index 11b379381505..44eed385290e 100644
--- a/l10ntools/source/gL10nMem.cxx
+++ b/l10ntools/source/gL10nMem.cxx
@@ -16,724 +16,571 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-
#include "gL10nMem.hxx"
-//#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
-
-
-/*****************************************************************************
- ************************ G L 1 0 N M E M . C X X ************************
- *****************************************************************************
- * This is the interface to translation memory that links between the converts
- * and to the language files. The memory contains the actual text info
- ***********************d******************************************************/
-
-
-
-/******************* G L O B A L D E F I N I T I O N *******************/
-l10nMem_impl * l10nMem_impl::mcImpl = nullptr;
-bool l10nMem_impl::mbVerbose = false;
-bool l10nMem_impl::mbDebug = false;
+l10nMem *myMem;
-/********************** I M P L E M E N T A T I O N **********************/
l10nMem::l10nMem()
+ : mbVerbose(false),
+ mbDebug(false),
+ mbInError(false)
{
- l10nMem_impl::mcImpl = new l10nMem_impl();
+ mcDb = new l10nMem_db;
+ myMem = this;
}
-/********************** I M P L E M E N T A T I O N **********************/
l10nMem::~l10nMem()
{
- delete l10nMem_impl::mcImpl;
+ delete mcDb;
}
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem::setShowVerbose()
+int l10nMem::showError(const std::string& sText, int iLineNo)
{
- l10nMem_impl::mbVerbose = true;
+ myMem->mbInError = true;
+ myMem->formatAndShowText("ERROR", iLineNo, sText);
+ return 1;
}
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem::setShowDebug()
+void l10nMem::showWarning(const std::string& sText, int iLineNo)
{
- l10nMem_impl::mbDebug = true;
+ myMem->formatAndShowText("WARNING", iLineNo, sText);
}
-/********************** I M P L E M E N T A T I O N **********************/
-int l10nMem::showError(const std::string& sText, int iLineNo)
- { return l10nMem_impl::mcImpl->showError(sText, iLineNo); }
-int l10nMem::showWarning(const std::string& sText, int iLineNo)
- { return l10nMem_impl::mcImpl->showWarning(sText, iLineNo); }
void l10nMem::showDebug(const std::string& sText, int iLineNo)
- { l10nMem_impl::mcImpl->showDebug(sText, iLineNo); }
-void l10nMem::showVerbose(const std::string& sText, int iLineNo)
- { l10nMem_impl::mcImpl->showVerbose(sText, iLineNo); }
-bool l10nMem::isError()
- { return l10nMem_impl::mcImpl->mbInError; }
-void l10nMem::setModuleName(const std::string& sM)
- { l10nMem_impl::mcImpl->setModuleName(sM); }
-const std::string& l10nMem::getModuleName ()
- { return l10nMem_impl::mcImpl->getModuleName(); }
-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, bool bM)
- { l10nMem_impl::mcImpl->setSourceKey(iL, sF, sK, sT, bM); }
-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(); }
-void l10nMem::convertToInetString(std::string& sT)
- { l10nMem_impl::mcImpl->convertToInetString(sT); }
-void l10nMem::convertFromInetString(std::string& sT)
- { l10nMem_impl::mcImpl->convertFromInetString(sT); }
-
-int l10nMem::prepareMerge()
- { return l10nMem_impl::mcImpl->mcDb.prepareMerge(); }
-void l10nMem::dumpMem(const std::string& sT)
- { l10nMem_impl::mcImpl->dumpMem(sT); }
-bool l10nMem::getMergeLang(std::string& sL, std::string& sT)
- { return l10nMem_impl::mcImpl->mcDb.getMergeLang(sL, sT); }
+{
+ if (myMem->mbDebug)
+ myMem->formatAndShowText("DEBUG", iLineNo, sText);
+}
-/********************** I M P L E M E N T A T I O N **********************/
-l10nMem_impl::l10nMem_impl()
- :
- mbInError(false)
+void l10nMem::showVerbose(const std::string& sText, int iLineNo)
{
+ if (myMem->mbVerbose)
+ myMem->formatAndShowText("INFO", iLineNo, sText);
}
-/********************** I M P L E M E N T A T I O N **********************/
-l10nMem_impl::~l10nMem_impl()
+bool l10nMem::isError()
{
+ return myMem->mbInError;
}
-/********************** I M P L E M E N T A T I O N **********************/
-int l10nMem_impl::showError(const std::string& sText, int iLineNo)
+void l10nMem::setModuleName(const std::string& sModuleName)
{
- mbInError = true;
- formatAndShowText("ERROR", iLineNo, sText);
- return 1;
+ msModuleName = sModuleName;
}
-/********************** I M P L E M E N T A T I O N **********************/
-int l10nMem_impl::showWarning(const std::string& sText, int iLineNo)
+const std::string& l10nMem::getModuleName()
{
- formatAndShowText("WARNING", iLineNo, sText);
- return 2;
+ return msModuleName;
}
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::showDebug(const std::string& sText, int iLineNo)
+void l10nMem::setLanguage(const std::string& sLanguage,
+ bool bCreate)
{
- if (mbDebug)
- formatAndShowText("DEBUG", iLineNo, sText);
+ mcDb->setLanguage(sLanguage, bCreate);
}
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::showVerbose(const std::string& sText, int iLineNo)
+void l10nMem::setConvert(bool bConvert,
+ bool bStrict)
{
- if (mbVerbose)
- formatAndShowText("INFO", iLineNo, sText);
+ mcDb->setConvert(bConvert, bStrict);
}
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::setModuleName(const std::string& sModuleName)
+void l10nMem::loadEntryKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
+ bool bIsFuzzy)
{
- msModuleName = sModuleName;
+ 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, sMsgId, sMsgStr, bIsFuzzy);
}
-/********************** I M P L E M E N T A T I O N **********************/
-const std::string& l10nMem_impl::getModuleName()
+void l10nMem::setSourceKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ bool bMustExist)
{
- return msModuleName;
+ std::string newText(sMsgId);
+ int i;
+
+ // time to escape " and \ if contained in text or key
+ for (i = 0; (i = newText.find("\\", i)) != (int)std::string::npos;) {
+ ++i;
+ if (i < (int)newText.size() &&
+ (newText[i] == '\\' || newText[i] == '<' || newText[i] == '>' ||
+ newText[i] == 'n' || newText[i] == 't' || newText[i] == 'r' ||
+ newText[i] == '\''))
+ ++i;
+ else {
+ newText.insert(i - 1, "\\");
+ ++i;
+ }
+ }
+ for (i = 0; (i = newText.find("\"", i)) != (int)std::string::npos;) {
+ newText.insert(i, "\\");
+ i += 2;
+ }
+
+ // if key exist update state
+ if (mcDb->locateKey(iLineNo, sSourceFile, sKey, newText, false))
+ mcDb->mcENUSlist[mcDb->miCurENUSinx].meState = ENTRY_NORMAL;
+ else {
+ if (bMustExist)
+ throw showError("key " + sKey + " does not exist");
+
+ // add key, if changed text, this is wrong but handled in reorganize
+ mcDb->addKey(iLineNo, sSourceFile, sKey, newText, ENTRY_ADDED);
+ }
}
-/********************** 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& sMsgId,
- const std::string& sMsgStr,
- bool bIsFuzzy)
+void l10nMem::saveTemplates(const std::string& sTargetDir, bool bKid, bool bForce)
{
- 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, sMsgId, sMsgStr, bIsFuzzy);
-}
+// int iEsize = mcDb->mcENUSlist.size();
+ std::string sFileName = msModuleName + ".pot";
+ // Dummy to satisfy compiler
+ if (bKid)
+ return;
+ showError(sTargetDir);
+ // and reorganize db if needed
+ mcDb->miCurFileInx = 0;
+ mcDb->reorganize(false);
-/********************** 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,
- const std::string& sMsgId,
- bool bMustExist)
-{
- std::string newText(sMsgId);
- int i;
-
- // time to escape " and \ if contained in text or key
- for (i = 0; (i = newText.find("\\", i)) != (int)std::string::npos;)
- {
- ++i;
- if (i < (int)newText.size() &&
- (newText[i] == '\\' || newText[i] == '<' || newText[i] == '>' ||
- newText[i] == 'n' || newText[i] == 't' || newText[i] == 'r' ||
- newText[i] == '\''))
- ++i;
- else
- {
- newText.insert(i-1, "\\");
- ++i;
+ // no save if there has been errors
+ if (!needWrite(sFileName, bForce))
+ return;
+
+ //JIX save HANDLE KID
+
+ // Save en-US
+#if 0
+ convert_gen savePo(cMem, sTargetDir, sTargetDir, sFileName);
+
+ savePo.startSave("templates/", sFileName);
+ for (iE = 1; iE < iEsize; ++iE) {
+ l10nMem_enus_entry& cE = mcDb->mcENUSlist[iE];
+
+ // remove deleted entries
+ if (cE.meState == ENTRY_DELETED)
+ continue;
+
+ savePo.save(mcDb->mcFileList[cE.miFileInx].msFileName, cE.msKey, cE.msMsgId, "", false);
}
- }
- for (i = 0; (i = newText.find("\"", i)) != (int)std::string::npos;)
- {
- newText.insert(i, "\\");
- i += 2;
- }
-
- // if key exist update state
- if (mcDb.locateKey(iLineNo, sSourceFile, sKey, newText, false))
- {
- mcDb.mcENUSlist[mcDb.miCurENUSinx].meState = l10nMem::ENTRY_NORMAL;
- }
- else
- {
- if (bMustExist)
- throw l10nMem::showError("key " + sKey + " does not exist");
- else
- // add key, if changed text, this is wrong but handled in reorganize
- mcDb.addKey(iLineNo, sSourceFile, sKey, newText, l10nMem::ENTRY_ADDED);
- }
+ savePo.endSave();
+#endif
}
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::saveTemplates(l10nMem& cMem, const std::string& sTargetDir, bool bKid, bool bForce)
+void l10nMem::saveLanguages(l10nMem& cMem, const std::string& sTargetDir, bool bForce)
{
- int iE, iEsize = mcDb.mcENUSlist.size();
- std::string sFileName = msModuleName + ".pot";
+ int iE, iEsize = mcDb->mcENUSlist.size();
+ int iL, iLsize = mcDb->mcLangList.size();
+ std::string sFileName = msModuleName + ".po";
- // Dummy to satisfy compiler
- if (bKid)
- return;
- // and reorganize db if needed
- mcDb.miCurFileInx = 0;
- mcDb.reorganize(false);
+ // and reorganize db if needed
+ mcDb->miCurFileInx = 0;
+ mcDb->reorganize(true);
- // no save if there has been errors
- if(!needWrite(sFileName, bForce))
- return;
+ // no save if there has been errors
+ if (!needWrite(sFileName, bForce))
+ return;
- //JIX save HANDLE KID
+ // save all languages
+ for (iL = 1; iL < iLsize; ++iL) {
+ // only save language file if modified
+ if (!mcDb->mcLangList[iL].mbChanged)
+ continue;
- // Save en-US
- convert_gen savePo(cMem, sTargetDir, sTargetDir, sFileName);
+ mcDb->mcLangList[iL].mbChanged = false;
+ 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(mcDb->mcLangList[iL].msName + "/", sFileName);
+ for (iE = 1; iE < iEsize; ++iE) {
+ l10nMem_enus_entry& cE = mcDb->mcENUSlist[iE];
+ l10nMem_lang_entry& cL = cE.mcLangText[iL];
+ bool bF = cL.mbFuzzy;
- // remove deleted entries
- if (cE.meState == l10nMem::ENTRY_DELETED)
- continue;
+ // remove deleted entries
+ if (cE.meState == 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, cL.msMsgStr, bF);
+ }
+ 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)
+void l10nMem::showNOconvert()
{
- int iE, iEsize = mcDb.mcENUSlist.size();
- int iL, iLsize = mcDb.mcLangList.size();
- std::string sFileName = msModuleName + ".po";
+ int iE, iEsize = mcDb->mcENUSlist.size();
+ for (iE = 1; iE < iEsize; ++iE) {
+ l10nMem_enus_entry& cE = mcDb->mcENUSlist[iE];
- // and reorganize db if needed
- mcDb.miCurFileInx = 0;
- mcDb.reorganize(true);
+ if (cE.meState == ENTRY_DELETED)
+ showError("template key(" + cE.msKey + ") msgId(" + cE.msMsgId + ") not in pot file", 0);
+ }
+}
- // no save if there has been errors
- if(!needWrite(sFileName, bForce))
- return;
- // save all languages
- for (iL = 1; iL < iLsize; ++iL)
- {
- // only save language file if modified
- if (!mcDb.mcLangList[iL].mbChanged)
- continue;
- mcDb.mcLangList[iL].mbChanged = false;
- convert_gen savePo(cMem, sTargetDir, sTargetDir, sFileName);
+void l10nMem::convertToInetString(std::string& sText)
+{
+ static const char *replacingStr[] = { "&", "\'", ">", "<", "\"", nullptr };
+ static const int replacingLen[] = { 1, 1, 1, 1, 1, 0 };
+ static const char *newStr[] = { "&amp;", "&apos;", "&gt;", "&lt;", "&quot;", nullptr };
+ static const int newLen[] = { 5, 6, 4, 4, 6, 0 };
+ int i, pos;
+
+ for (i = 0; replacingStr[i]; i++) {
+ pos = 0;
+ while ((pos = sText.find(replacingStr[i], pos)) != (int)std::string::npos) {
+ sText.replace(pos, replacingLen[i], newStr[i]);
+ pos += newLen[i];
+ }
+ }
+}
- savePo.startSave(mcDb.mcLangList[iL].msName + "/", sFileName);
- for (iE = 1; iE < iEsize; ++iE)
- {
- l10nMem_enus_entry& cE = mcDb.mcENUSlist[iE];
- l10nMem_lang_entry& cL = cE.mcLangText[iL];
- bool bF = cL.mbFuzzy;
- // remove deleted entries
- if (cE.meState == l10nMem::ENTRY_DELETED)
- continue;
- savePo.save(mcDb.mcFileList[cE.miFileInx].msFileName, cE.msKey, cE.msMsgId, cL.msMsgStr, bF);
+void l10nMem::convertFromInetString(std::string& sText)
+{
+ static const char *replacingStr[] = { "&amp;", "&apos;", "&gt;", "&lt;", "&quot;", nullptr };
+ static const int replacingLen[] = { 5, 6, 4, 4, 6, 0 };
+ static const char *newStr[] = { "&", "\'", ">", "<", "\"", nullptr };
+ static const int newLen[] = { 1, 1, 1, 1, 1, 0 };
+ int i, pos;
+
+ for (i = 0; replacingStr[i]; i++) {
+ pos = 0;
+ while ((pos = sText.find(replacingStr[i], pos)) != (int)std::string::npos) {
+ sText.replace(pos, replacingLen[i], newStr[i]);
+ pos += newLen[i];
+ }
}
- savePo.endSave();
- }
}
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::showNOconvert ()
+int l10nMem::prepareMerge()
{
- 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);
- }
- }
+ return mcDb->prepareMerge();
}
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::dumpMem(const std::string& sFileName)
+void l10nMem::dumpMem(const std::string& sFileName)
{
- // and reorganize db if needed
- mcDb.reorganize(false);
+ // and reorganize db if needed
+ mcDb->reorganize(false);
- // no save if there has been errors
- if(!needWrite(sFileName, true))
- return;
+ // no save if there has been errors
+ if (!needWrite(sFileName, true))
+ return;
- // JIX (dumpMem)
+ // JIX (dumpMem)
}
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::formatAndShowText(const std::string& sType, int iLineNo, const std::string& sText)
+bool l10nMem::getMergeLang(std::string& sL, std::string& sT)
{
- std::cout << sType;
- if (mcDb.miCurFileInx > 0)
- std::cout << " in " << mcDb.mcFileList[mcDb.miCurFileInx].msFileName;
- if (iLineNo)
- std::cout << "(" << iLineNo << ")";
- std::cout << ": " << sText << std::endl;
+ return mcDb->getMergeLang(sL, sT);
}
-/********************** I M P L E M E N T A T I O N **********************/
-bool l10nMem_impl::needWrite(const std::string sFileName, bool bForce)
+void l10nMem::formatAndShowText(const std::string& sType, int iLineNo, const std::string& sText)
{
- int iE, iEsize = mcDb.mcENUSlist.size();
- int iCntDeleted = 0, iCntChanged = 0, iCntAdded = 0;
-
- // no save if there has been errors
- if (mbInError)
- throw l10nMem::showError("Cannot save due to previous errors");
-
- // Check number of changes
- for (iE = 1; iE < iEsize; ++iE)
- {
- l10nMem_enus_entry& cur = mcDb.mcENUSlist[iE];
- if (cur.meState == l10nMem::ENTRY_ADDED)
- ++iCntAdded;
- if (cur.meState == l10nMem::ENTRY_CHANGED)
- {
- ++iCntChanged;
- if (mcDb.mbStrictMode)
- cur.meState = l10nMem::ENTRY_NORMAL;
- }
- if (cur.meState == l10nMem::ENTRY_DELETED)
- ++iCntDeleted;
- }
- if (!mcDb.mbConvertMode)
- iCntDeleted -= iCntChanged;
- if (!iCntAdded && !iCntChanged && !iCntDeleted)
- {
- std::cout << "genLang: No changes in " << sFileName;
- if (bForce)
- std::cout << ", -o switch used, so files are saved" << std::endl;
- else
- std::cout << " skipping \"save\"" << std::endl;
- return bForce;
- }
-
- std::cout << "genLang statistics: " << iCntDeleted << " deleted, "
- << iCntChanged << " changed, "
- << iCntAdded << " added entries in "
- << sFileName << std::endl;
- return true;
+ std::cout << sType;
+ if (mcDb->miCurFileInx > 0)
+ std::cout << " in " << mcDb->mcFileList[mcDb->miCurFileInx].msFileName;
+ if (iLineNo)
+ std::cout << "(" << iLineNo << ")";
+ std::cout << ": " << sText << std::endl;
}
-/********************** 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& sMsgId)
+bool l10nMem::needWrite(const std::string sFileName, bool bForce)
{
- // silent ignore deleted messages
- if (sMsgId == "-" || sMsgId == "")
+ int iE, iEsize = mcDb->mcENUSlist.size();
+ int iCntDeleted = 0, iCntChanged = 0, iCntAdded = 0;
+
+ // no save if there has been errors
+ if (mbInError)
+ throw showError("Cannot save due to previous errors");
+
+ // Check number of changes
+ for (iE = 1; iE < iEsize; ++iE) {
+ l10nMem_enus_entry& cur = mcDb->mcENUSlist[iE];
+ if (cur.meState == ENTRY_ADDED)
+ ++iCntAdded;
+ if (cur.meState == ENTRY_CHANGED) {
+ ++iCntChanged;
+ if (mcDb->mbStrictMode)
+ cur.meState = ENTRY_NORMAL;
+ }
+ if (cur.meState == ENTRY_DELETED)
+ ++iCntDeleted;
+ }
+ if (!mcDb->mbConvertMode)
+ iCntDeleted -= iCntChanged;
+ if (!iCntAdded && !iCntChanged && !iCntDeleted) {
+ std::cout << "genLang: No changes in " << sFileName;
+ if (bForce)
+ std::cout << ", -o switch used, so files are saved" << std::endl;
+ else
+ std::cout << " skipping \"save\"" << std::endl;
+ return bForce;
+ }
+
+ std::cout << "genLang statistics: " << iCntDeleted << " deleted, "
+ << iCntChanged << " changed, "
+ << iCntAdded << " added entries in "
+ << sFileName << std::endl;
return true;
+}
- if (msModuleName == "help_sbasic")
- {
- if (sSourceFile == "sbasic.tree")
- return true;
- }
- if (msModuleName == "help_scalc")
- {
- if (sSourceFile == "scalc.tree")
- return true;
- }
- if (msModuleName == "help_schart")
- {
- if (sSourceFile == "schart.tree")
- return true;
- }
- if (msModuleName == "help_shared")
- {
- if (sSourceFile == "shared.tree")
- return true;
- }
- if (msModuleName == "help_simpress")
- {
- if (sSourceFile == "simpress.tree")
- return true;
- }
- if (msModuleName == "help_smath")
- {
- if (sSourceFile == "smath.tree")
- return true;
- }
- if (msModuleName == "help_swriter")
- {
- if (sSourceFile == "swriter.tree")
- return true;
- }
- if (msModuleName == "officecfg")
- {
- if (sSourceFile == "registry/data/org/openoffice/Office/Writer.xcu" && sKey == "Writer.Insert.Caption.CaptionOrderNumberingFirst")
- return true;
- if (sSourceFile == "registry/data/org/openoffice/Office/Writer.xcu" && sKey == "Writer.Layout.Other.TabStop")
- return true;
- if (sSourceFile == "registry/data/org/openoffice/Office/UI/WriterCommands.xcu" && sKey == "WriterCommands.UserInterface.Commands..uno:FlipVertical.Label")
- return true;
- if (sSourceFile == "registry/data/org/openoffice/Office/UI/WriterCommands.xcu" && sKey == "WriterCommands.UserInterface.Commands..uno:FlipHorizontal.Label")
- return true;
- if (sSourceFile == "registry/data/org/openoffice/Office/Common.xcu" && sKey == "Common.View.Localisation.AutoMnemonic")
- return true;
- if (sSourceFile == "registry/data/org/openoffice/Office/Common.xcu" && sKey == "Common.View.Localisation.DialogScale")
- return true;
- if (sSourceFile == "registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu" && sKey == "ImpressWindowState.UIElements.States.private:resource/toolpanel/DrawingFramework/SlideTransitions.UIName")
- return true;
- if (sSourceFile == "registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu" && sKey == "ImpressWindowState.UIElements.States.private:resource/toolpanel/DrawingFramework/CustomAnimations.UIName")
- return true;
- if (sSourceFile == "registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu" && sKey == "ImpressWindowState.UIElements.States.private:resource/toolpanel/DrawingFramework/MasterPages.UIName")
- return true;
- if (sSourceFile == "registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu" && sKey == "ImpressWindowState.UIElements.States.private:resource/toolpanel/DrawingFramework/Layouts.UIName")
- return true;
- if (sSourceFile == "registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu" && sKey == "ImpressWindowState.UIElements.States.private:resource/toolpanel/DrawingFramework/TableDesign.UIName")
- return true;
- }
- if (msModuleName == "readlicense_oo")
- {
- if (sSourceFile == "docs/readme/readme.xrm")
- {
- if (sKey == "BDB11")
- return true;
- if (sKey == "BDB2a")
- return true;
- if (sKey == "BDB3a")
- return true;
- if (sKey == "BDB4a")
- return true;
- }
- }
- if (msModuleName == "scp2")
- {
- if (sSourceFile == "source/binfilter/module_binfilter.ulf")
- return true;
- if (sSourceFile == "source/binfilter/registryitem_binfilter.ulf")
- return true;
- }
- if (msModuleName == "sdext")
- {
- if (sSourceFile == "source/minimizer/registry/data/org/openoffice/Office/Addons.xcu")
- return true;
- if (sSourceFile == "source/minimizer/registry/data/org/openoffice/Office/extension/SunPresentationMinimizer.xcu")
- return true;
- if (sSourceFile == "source/presenter/help/en-US/com.sun.PresenterScreen/presenter.xhp")
- return true;
- if (sSourceFile == "source/presenter/registry/data/org/openoffice/Office/extension/PresenterScreen.xcu")
- return true;
- }
- if (msModuleName == "sd")
- {
- if (sSourceFile == "source/ui/dlg/celltempl.src")
- return true;
- }
- if (msModuleName == "svx")
- {
- if (sSourceFile == "source/dialog/fontwork.src")
- {
- if (sKey == "RID_SVXSTR_FONTWORK_FORM1.String.Text")
- return true;
- if (sKey == "RID_SVXSTR_FONTWORK_FORM2.String.Text")
- return true;
- if (sKey == "RID_SVXSTR_FONTWORK_FORM3.String.Text")
- return true;
- if (sKey == "RID_SVXSTR_FONTWORK_FORM4.String.Text")
- return true;
- if (sKey == "RID_SVXSTR_FONTWORK_FORM5.String.Text")
- return true;
- if (sKey == "RID_SVXSTR_FONTWORK_FORM6.String.Text")
+
+
+bool l10nMem::convFilterWarning(const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId)
+{
+ // silent ignore deleted messages
+ if (sMsgId == "-" || sMsgId == "")
return true;
- if (sKey == "RID_SVXSTR_FONTWORK_FORM7.String.Text")
+ if (msModuleName == "help_sbasic" && sSourceFile == "sbasic.tree")
return true;
- if (sKey == "RID_SVXSTR_FONTWORK_FORM8.String.Text")
+ if (msModuleName == "help_scalc" && sSourceFile == "scalc.tree")
return true;
- if (sKey == "RID_SVXSTR_FONTWORK_FORM9.String.Text")
+ if (msModuleName == "help_schart" && sSourceFile == "schart.tree")
return true;
- if (sKey == "RID_SVXSTR_FONTWORK_FORM10.String.Text")
+ if (msModuleName == "help_shared" && sSourceFile == "shared.tree")
return true;
- if (sKey == "RID_SVXSTR_FONTWORK_FORM11.String.Text")
+ if (msModuleName == "help_simpress" && sSourceFile == "simpress.tree")
return true;
- if (sKey == "RID_SVXSTR_FONTWORK_FORM12.String.Text")
+ if (msModuleName == "help_smath" && sSourceFile == "smath.tree")
return true;
- if (sKey == "RID_SVXSTR_FONTWORK_UNDOCREATE.String.Text")
+ if (msModuleName == "help_swriter" && sSourceFile == "swriter.tree")
return true;
+ if (msModuleName == "officecfg") {
+ if ((sSourceFile == "registry/data/org/openoffice/Office/Writer.xcu" &&
+ sKey == "Writer.Insert.Caption.CaptionOrderNumberingFirst") ||
+ (sSourceFile == "registry/data/org/openoffice/Office/Writer.xcu" &&
+ sKey == "Writer.Layout.Other.TabStop") ||
+ (sSourceFile == "registry/data/org/openoffice/Office/UI/WriterCommands.xcu" &&
+ sKey == "WriterCommands.UserInterface.Commands..uno:FlipVertical.Label") ||
+ (sSourceFile == "registry/data/org/openoffice/Office/UI/WriterCommands.xcu" &&
+ sKey == "WriterCommands.UserInterface.Commands..uno:FlipHorizontal.Label") ||
+ (sSourceFile == "registry/data/org/openoffice/Office/Common.xcu" &&
+ sKey == "Common.View.Localisation.AutoMnemonic") ||
+ (sSourceFile == "registry/data/org/openoffice/Office/Common.xcu" &&
+ sKey == "Common.View.Localisation.DialogScale") ||
+ (sSourceFile == "registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu" &&
+ sKey == "ImpressWindowState.UIElements.States.private:resource/toolpanel/DrawingFramework/SlideTransitions.UIName") ||
+ (sSourceFile == "registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu" &&
+ sKey == "ImpressWindowState.UIElements.States.private:resource/toolpanel/DrawingFramework/CustomAnimations.UIName") ||
+ (sSourceFile == "registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu" &&
+ sKey == "ImpressWindowState.UIElements.States.private:resource/toolpanel/DrawingFramework/MasterPages.UIName") ||
+ (sSourceFile == "registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu" &&
+ sKey == "ImpressWindowState.UIElements.States.private:resource/toolpanel/DrawingFramework/Layouts.UIName") ||
+ (sSourceFile == "registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu" &&
+ sKey == "ImpressWindowState.UIElements.States.private:resource/toolpanel/DrawingFramework/TableDesign.UIName") ||
+ (sSourceFile == "registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu" &&
+ sKey == "ImpressWindowState.UIElements.States.private:resource/toolpanel/DrawingFramework/TableDesign.UIName"))
+ return true;
}
- if (sSourceFile == "source/dialog/sdstring.src")
- {
- if (sKey == "RID_SVXSTR_LIGHTGREY.String.Text")
- return true;
- if (sKey == "RID_SVXSTR_LIGHTBLUE.String.Text")
- return true;
- if (sKey == "RID_SVXSTR_LIGHTGREEN.String.Text")
- return true;
- if (sKey == "RID_SVXSTR_LIGHTCYAN.String.Text")
- return true;
- if (sKey == "RID_SVXSTR_LIGHTRED.String.Text")
- return true;
- if (sKey == "RID_SVXSTR_LIGHTMAGENTA.String.Text")
- return true;
- if (sKey == "RID_SVXSTR_COLOR_SUN.String.Text")
- return true;
+ if (msModuleName == "readlicense_oo") {
+ if (sSourceFile == "docs/readme/readme.xrm") {
+ if ((sKey == "BDB11" || sKey == "BDB2a" ||
+ sKey == "BDB3a" || sKey == "BDB4a"))
+ return true;
+ }
+ }
+ if (msModuleName == "scp2") {
+ if ((sSourceFile == "source/binfilter/module_binfilter.ulf" ||
+ sSourceFile == "source/binfilter/registryitem_binfilter.ulf"))
+ return true;
+ }
+ if (msModuleName == "sdext") {
+ if (sSourceFile == "source/minimizer/registry/data/org/openoffice/Office/Addons.xcu" ||
+ sSourceFile == "source/minimizer/registry/data/org/openoffice/Office/extension/SunPresentationMinimizer.xcu" ||
+ sSourceFile == "source/presenter/help/en-US/com.sun.PresenterScreen/presenter.xhp" ||
+ sSourceFile == "source/presenter/registry/data/org/openoffice/Office/extension/PresenterScreen.xcu")
+ return true;
+ }
+ if (msModuleName == "sd") {
+ if (sSourceFile == "source/ui/dlg/celltempl.src")
+ return true;
+ }
+ if (msModuleName == "svx") {
+ if (sSourceFile == "source/dialog/fontwork.src") {
+ if (sKey == "RID_SVXSTR_FONTWORK_FORM1.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_FORM2.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_FORM3.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_FORM4.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_FORM5.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_FORM6.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_FORM7.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_FORM8.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_FORM9.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_FORM10.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_FORM11.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_FORM12.String.Text" ||
+ sKey == "RID_SVXSTR_FONTWORK_UNDOCREATE.String.Text")
+ return true;
+ }
+ }
+ if (sSourceFile == "source/dialog/sdstring.src") {
+ if (sKey == "RID_SVXSTR_LIGHTGREY.String.Text" ||
+ sKey == "RID_SVXSTR_LIGHTBLUE.String.Text" ||
+ sKey == "RID_SVXSTR_LIGHTGREEN.String.Text" ||
+ sKey == "RID_SVXSTR_LIGHTCYAN.String.Text" ||
+ sKey == "RID_SVXSTR_LIGHTRED.String.Text" ||
+ sKey == "RID_SVXSTR_LIGHTMAGENTA.String.Text" ||
+ sKey == "RID_SVXSTR_COLOR_SUN.String.Text")
+ return true;
}
if (sSourceFile == "source/svdraw/svdstr.src" && sKey == "SIP_XA_FORMTXTSTDFORM.String.Text")
return true;
- }
- return false;
+ 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,
- const std::string& sMsgId,
- const std::string& sMsgStr,
- bool bIsFuzzy)
+void l10nMem::convEntryKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
+ bool bIsFuzzy)
{
- std::vector<int> ivEntryList;
- std::string curFileName;
- std::string curKeyUpper;
- int curFileIndex, curENUSindex, i, iSize;
-
-
- // filter out dummy messages, silently
- if (convFilterWarning(sSourceFile, sKey, 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 (curFileIndex = 1; curFileIndex < iSize; ++curFileIndex)
- if (curFileName == mcDb.mcFileList[curFileIndex].msPureName)
- {
- int j = mcDb.mcFileList[curFileIndex].miStart;
- int iEnd = mcDb.mcFileList[curFileIndex].miEnd;
-
- for (; j <= iEnd; ++j)
- ivEntryList.push_back(j);
- }
-
- // Did we find one or more files ?
- iSize = ivEntryList.size();
- if (!iSize)
- {
- showWarning("source file(" + curFileName + ") not in template file", iLineNo);
- return;
- }
-
- // Loop through all potential en-US entries
- for (curENUSindex = -1, i = 0; i < iSize; ++i)
- {
- l10nMem_enus_entry& curE = mcDb.mcENUSlist[ivEntryList[i]];
-
-
- // 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)
- {
- curENUSindex = ivEntryList[i];
- if (curE.meState == l10nMem::ENTRY_DELETED)
- curE.meState = l10nMem::ENTRY_NORMAL;
- break;
+ std::vector<int> ivEntryList;
+ std::string curFileName;
+ std::string curKeyUpper;
+ int curFileIndex, curENUSindex, i, iSize;
+
+
+ // filter out dummy messages, silently
+ if (convFilterWarning(sSourceFile, sKey, sMsgId))
+ return;
+
+ // check for directory names in file name
+ i = sSourceFile.rfind("/");
+ curFileName = (i > 0) ? sSourceFile.substr(i + 1) : sSourceFile;
+
+ // Find all matching file names (old system does not have directory.
+ // build list of potential entries
+ iSize = mcDb->mcFileList.size();
+ for (curFileIndex = 1; curFileIndex < iSize; ++curFileIndex)
+ if (curFileName == mcDb->mcFileList[curFileIndex].msPureName) {
+ int j = mcDb->mcFileList[curFileIndex].miStart;
+ int iEnd = mcDb->mcFileList[curFileIndex].miEnd;
+
+ for (; j <= iEnd; ++j)
+ ivEntryList.push_back(j);
+ }
+
+ // Did we find one or more files ?
+ iSize = ivEntryList.size();
+ if (!iSize) {
+ showWarning("source file(" + curFileName + ") not in template file", iLineNo);
+ 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);
// 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;
- }
+ for (curENUSindex = -1, i = 0; i < iSize; ++i) {
+ l10nMem_enus_entry& curE = mcDb->mcENUSlist[ivEntryList[i]];
+
+ // The entry must be unconverted if strict mode (comparing .pot files)
+ if (mcDb->mbStrictMode && curE.meState != ENTRY_DELETED)
+ continue;
+
+ // msgId must match
+ if (sMsgId == curE.msMsgId) {
+ curENUSindex = ivEntryList[i];
+ if (curE.meState == ENTRY_DELETED)
+ curE.meState = ENTRY_NORMAL;
+ break;
+ }
}
- }
-
- if (curENUSindex == -1)
- {
- showWarning("file(" + curFileName + ") key(" + sKey + ") msgId(" + sMsgId + ") not found in templates", iLineNo);
- return;
- }
-
- // update language text
- l10nMem_enus_entry& curE = mcDb.mcENUSlist[curENUSindex];
- l10nMem_lang_entry& curL = curE.mcLangText[mcDb.miCurLangInx];
-
- if (sMsgStr != curL.msMsgStr)
- {
- curL.msMsgStr = sMsgStr;
- curL.mbFuzzy = bIsFuzzy;
- curE.meState = l10nMem::ENTRY_CHANGED;
- mcDb.mcLangList[mcDb.miCurLangInx].mbChanged = true;
- }
-}
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::convertToInetString(std::string& sText)
-{
-static const char *replacingStr[] = {"&", "\'", ">", "<", "\"", nullptr };
-static const int replacingLen[] = {1, 1, 1, 1, 1, 0 };
-static const char *newStr[] = {"&amp;", "&apos;", "&gt;", "&lt;", "&quot;", nullptr };
-static const int newLen[] = {5, 6, 4, 4, 6, 0 };
- int i, pos;
-
- for (i = 0; replacingStr[i]; i++)
- {
- pos = 0;
- while((pos = sText.find(replacingStr[i], pos)) != (int)std::string::npos) {
- sText.replace(pos, replacingLen[i], newStr[i]);
- pos += newLen[i];
+ // 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);
+
+ // 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;
+ }
+ }
}
- }
-}
+ if (curENUSindex == -1) {
+ showWarning("file(" + curFileName + ") key(" + sKey + ") msgId(" + sMsgId + ") not found in templates", iLineNo);
+ return;
+ }
+ // update language text
+ l10nMem_enus_entry& curE = mcDb->mcENUSlist[curENUSindex];
+ l10nMem_lang_entry& curL = curE.mcLangText[mcDb->miCurLangInx];
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_impl::convertFromInetString(std::string& sText)
-{
-static const char *replacingStr[] = {"&amp;", "&apos;", "&gt;", "&lt;", "&quot;", nullptr };
-static const int replacingLen[] = {5, 6, 4, 4, 6, 0 };
-static const char *newStr[] = {"&", "\'", ">", "<", "\"", nullptr };
-static const int newLen[] = {1, 1, 1, 1, 1, 0 };
- int i, pos;
-
- for (i = 0; replacingStr[i]; i++)
- {
- pos = 0;
- while((pos = sText.find(replacingStr[i], pos)) != (int)std::string::npos) {
- sText.replace(pos, replacingLen[i], newStr[i]);
- pos += newLen[i];
+ if (sMsgStr != curL.msMsgStr) {
+ curL.msMsgStr = sMsgStr;
+ curL.mbFuzzy = bIsFuzzy;
+ curE.meState = ENTRY_CHANGED;
+ mcDb->mcLangList[mcDb->miCurLangInx].mbChanged = true;
}
- }
}
diff --git a/l10ntools/source/gL10nMemDB.cxx b/l10ntools/source/gL10nMemDB.cxx
index 2055b0e5e318..513342431528 100644
--- a/l10ntools/source/gL10nMemDB.cxx
+++ b/l10ntools/source/gL10nMemDB.cxx
@@ -23,16 +23,6 @@
#include <sstream>
-/*****************************************************************************
- ********************** G L 1 0 N M E M D B . C X X **********************
- *****************************************************************************
- * This is the translation memory that links between the converts (from source
- * files) and to the language files. The memory contains the actual text info
- ***********************d******************************************************/
-
-
-
-/******************* G L O B A L D E F I N I T I O N *******************/
diff --git a/l10ntools/source/gLang.cxx b/l10ntools/source/gLang.cxx
index 696d86122ee0..da078285e285 100644
--- a/l10ntools/source/gLang.cxx
+++ b/l10ntools/source/gLang.cxx
@@ -34,8 +34,6 @@ class handler
private:
bool mbForceSave;
- bool mbDebug;
- bool mbVerbose;
bool mbSave;
enum {DO_CONVERT, DO_EXTRACT, DO_MERGE_KID, DO_MERGE} meWorkMode;
std::string msTargetDir;
@@ -172,7 +170,7 @@ void handler::checkCommandLine(int argc, char *argv[])
// Set default
- mbForceSave = mbDebug = mbVerbose = mbSave = false;
+ mbForceSave = mbSave = false;
// check for fixed parameter: genLang <cmd>
if (argc < 2)
@@ -191,7 +189,7 @@ void handler::checkCommandLine(int argc, char *argv[])
sWorkText = argv[i];
if (sWorkText == "-d") {
// show debug information
- mbDebug = true;
+ mcMemory.mbDebug = true;
}
else if (sWorkText == "-k") {
// generate key identifier version
@@ -201,7 +199,7 @@ void handler::checkCommandLine(int argc, char *argv[])
}
else if (sWorkText == "-v") {
// show progress information
- mbVerbose = true;
+ mcMemory.mbVerbose = true;
}
else if (sWorkText == "-s") {
// forced save
@@ -325,7 +323,7 @@ void handler::loadL10MEM(bool onlyTemplates)
// load texts from en-US po file (master)
// tell system
- l10nMem::showDebug("genLang loading master text from file " + sLoad);
+ mcMemory.showDebug("genLang loading master text from file " + sLoad);
// and load file
mcMemory.setLanguage("", true);
@@ -343,7 +341,7 @@ void handler::loadL10MEM(bool onlyTemplates)
mcMemory.setLanguage(*siLang, true);
// tell system
- l10nMem::showDebug("genLang loading text from language file " + sLoad);
+ mcMemory.showDebug("genLang loading text from language file " + sLoad);
convert_gen(mcMemory, sLoad, msTargetDir, "").execute(false, false);
}
@@ -356,7 +354,6 @@ void handler::runConvert()
std::vector<std::string>::iterator siSource;
std::vector<std::string>::iterator siLang;
- throw("NOT CONTROLLED");
// convert
mcMemory.setConvert(true, false);
@@ -365,7 +362,7 @@ void handler::runConvert()
for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource)
{
// tell system
- l10nMem::showDebug("genLang compare template " + *siSource);
+ mcMemory.showDebug("genLang compare template " + *siSource);
// get converter and extract files
convert_gen convertObj(mcMemory, "./", msTargetDir, *siSource);
@@ -381,7 +378,7 @@ void handler::runConvert()
mcMemory.setLanguage(*siLang, false);
// tell system
- l10nMem::showDebug("genLang convert text from file " +
+ mcMemory.showDebug("genLang convert text from file " +
sFilePath + *siSource + " language " + *siLang);
// get converter and extract files
@@ -403,13 +400,12 @@ void handler::runExtract()
// no convert
mcMemory.setConvert(false, false);
- throw("NOT CONTROLLED");
// loop through all source files, and extract messages from each file
for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource)
{
// tell system
- l10nMem::showDebug("genLang extracting text from file " + *siSource);
+ mcMemory.showDebug("genLang extracting text from file " + *siSource);
// get converter and extract file
convert_gen convertObj(mcMemory, "", msTargetDir, *siSource);
@@ -428,13 +424,12 @@ void handler::runMerge(bool bKid)
// no convert
mcMemory.setConvert(false, false);
- throw("NOT CONTROLLED");
// loop through all source files, and extract messages from each file
for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource)
{
// tell system
- l10nMem::showDebug("genLang merging translated text to file " + *siSource);
+ mcMemory.showDebug("genLang merging translated text to file " + *siSource);
// get converter and extract file
convert_gen convertObj(mcMemory, "", msTargetDir, *siSource);