[Libreoffice-commits] core.git: 2 commits - l10ntools/Executable_genlang.mk l10ntools/inc l10ntools/source
jan iversen
jani at documentfoundation.org
Mon Mar 14 22:41:31 UTC 2016
l10ntools/Executable_genlang.mk | 1
l10ntools/inc/gConv.hxx | 67 ++---
l10ntools/inc/gConvDB.hxx | 2
l10ntools/inc/gConvPo.hxx | 2
l10ntools/inc/gConvProp.hxx | 2
l10ntools/inc/gConvSrc.hxx | 2
l10ntools/inc/gConvTree.hxx | 2
l10ntools/inc/gConvUlf.hxx | 2
l10ntools/inc/gConvXcs.hxx | 2
l10ntools/inc/gConvXcu.hxx | 2
l10ntools/inc/gConvXhp.hxx | 2
l10ntools/inc/gConvXrm.hxx | 2
l10ntools/inc/gL10nMem.hxx | 209 ++++++++--------
l10ntools/inc/gLang.hxx | 135 ----------
l10ntools/source/gConv.cxx | 119 ++-------
l10ntools/source/gConvDB.cxx | 14 -
l10ntools/source/gConvPo.cxx | 5
l10ntools/source/gConvProp.cxx | 14 -
l10ntools/source/gConvSrc.cxx | 16 -
l10ntools/source/gConvTree.cxx | 15 -
l10ntools/source/gConvUlf.cxx | 17 -
l10ntools/source/gConvXcs.cxx | 17 -
l10ntools/source/gConvXcu.cxx | 19 -
l10ntools/source/gConvXhp.cxx | 17 -
l10ntools/source/gConvXrm.cxx | 13 -
l10ntools/source/gL10nMem.cxx | 503 +++++++++++++++++++++++++++++++++++-----
l10ntools/source/gL10nMemDB.cxx | 453 ------------------------------------
l10ntools/source/gLang.cxx | 39 +--
l10ntools/source/gLexPo.l | 8
l10ntools/source/gLexSrc.l | 8
l10ntools/source/gLexTree.l | 8
l10ntools/source/gLexUlf.l | 8
l10ntools/source/gLexXcs.l | 8
l10ntools/source/gLexXcu.l | 8
l10ntools/source/gLexXhp.l | 8
l10ntools/source/gLexXrm.l | 8
l10ntools/source/merge.cxx | 17 -
37 files changed, 743 insertions(+), 1031 deletions(-)
New commits:
commit 4043af877587622935be828049b7b18cc27ad1d8
Author: jan iversen <jani at documentfoundation.org>
Date: Mon Mar 14 23:35:34 2016 +0100
genLang update
Last singleton gone, structure is now
handler (local in gLang.cxx) holds
a variable of l10nMem
a temporary convert_gen variable (to analyze file)
l10nMem contains hash list of all PO information
convert_xxx is inherited from convert_gen and instanciated
with a static function convert_gen::createInstance
the lex functions (in c) uses a "this" pointer to find back
to the class. This needs to be done better.
l10nMem contains a link to convert_PO, to save files, this
needs to be split.
Change-Id: I3ad31aac27aac739845062f8da61c8c1c3bf9c31
diff --git a/l10ntools/inc/gConv.hxx b/l10ntools/inc/gConv.hxx
index 604e5ed..b9507ac 100644
--- a/l10ntools/inc/gConv.hxx
+++ b/l10ntools/inc/gConv.hxx
@@ -25,65 +25,40 @@
class convert_gen
{
public:
- convert_gen(l10nMem& cMemory,
+ static convert_gen *mcImpl;
+
+ convert_gen(l10nMem& cMemory);
+ virtual ~convert_gen();
+
+ // Create instance
+ static convert_gen& createInstance(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);
+ // all converters MUST implement this function
+ virtual void execute() = 0;
+
// ONLY po should implement these functions
- void startSave(const std::string& sLanguage,
+ virtual void startSave(const std::string& sLanguage,
const std::string& sFile);
- void save(const std::string& sFileName,
+ virtual void save(const std::string& sFileName,
const std::string& sKey,
const std::string& sENUStext,
const std::string& sText,
bool bFuzzy);
- void endSave();
+ virtual void endSave();
static bool checkAccess(std::string& sFile);
static bool createDir(std::string& sDir, std::string& sFile);
-};
-
-
-/*****************************************************************************
- **************************** G C O N . H X X ****************************
- *****************************************************************************
- * This is the class definition header for all converter classes,
- * all 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 convert_gen_impl
-{
- public:
- static convert_gen_impl *mcImpl;
+ // utility functions for converters
+ void lexRead(char *sBuf, int *nResult, int nMax_size);
+ std::string& copySource(char const *yyText, bool bDoClear = true);
- convert_gen_impl(l10nMem& crMemory);
- virtual ~convert_gen_impl();
-
- // all converters MUST implement this function
- virtual void execute() = 0;
-
- // ONLY po should implement these functions
- virtual void startSave(const std::string& sLanguage,
- const std::string& sFile);
- virtual void save(const std::string& sFileName,
- const std::string& sKey,
- const std::string& sENUStext,
- const std::string& sText,
- bool bFuzzy);
- virtual void endSave();
-
+protected:
// generic variables
bool mbMergeMode;
bool mbLoadMode;
@@ -93,22 +68,14 @@ class convert_gen_impl
l10nMem& mcMemory;
std::string msCollector;
int miLineNo;
-
-
- // utility functions for converters
- void lexRead (char *sBuf, int *nResult, int nMax_size);
- void writeSourceFile(const std::string& line);
- std::string& copySource (char const *yyText, bool bDoClear = true);
-
- protected:
std::string msSourceBuffer, msCopyText;
int miSourceReadIndex;
bool prepareFile();
- private:
+ // utility functions for converters
+ void writeSourceFile(const std::string& line);
+private:
std::ofstream mcOutputFile;
-
- friend class convert_gen;
};
#endif
diff --git a/l10ntools/inc/gConvDB.hxx b/l10ntools/inc/gConvDB.hxx
index 0cbb746..51c8377 100644
--- a/l10ntools/inc/gConvDB.hxx
+++ b/l10ntools/inc/gConvDB.hxx
@@ -32,7 +32,7 @@
/******************** C L A S S D E F I N I T I O N ********************/
-class convert_db : public convert_gen_impl
+class convert_db : public convert_gen
{
public:
convert_db(l10nMem& crMemory);
diff --git a/l10ntools/inc/gConvPo.hxx b/l10ntools/inc/gConvPo.hxx
index b467064..33fc4ef 100644
--- a/l10ntools/inc/gConvPo.hxx
+++ b/l10ntools/inc/gConvPo.hxx
@@ -32,7 +32,7 @@
/******************** C L A S S D E F I N I T I O N ********************/
-class convert_po : public convert_gen_impl
+class convert_po : public convert_gen
{
public:
bool mbExpectId;
diff --git a/l10ntools/inc/gConvProp.hxx b/l10ntools/inc/gConvProp.hxx
index 8b1c281..b2b9bd1 100644
--- a/l10ntools/inc/gConvProp.hxx
+++ b/l10ntools/inc/gConvProp.hxx
@@ -32,7 +32,7 @@
/******************** C L A S S D E F I N I T I O N ********************/
-class convert_prop : public convert_gen_impl
+class convert_prop : public convert_gen
{
public:
convert_prop(l10nMem& crMemory);
diff --git a/l10ntools/inc/gConvSrc.hxx b/l10ntools/inc/gConvSrc.hxx
index e9a2139..669430f 100644
--- a/l10ntools/inc/gConvSrc.hxx
+++ b/l10ntools/inc/gConvSrc.hxx
@@ -31,7 +31,7 @@
/******************** C L A S S D E F I N I T I O N ********************/
-class convert_src : public convert_gen_impl
+class convert_src : public convert_gen
{
public:
bool mbExpectValue;
diff --git a/l10ntools/inc/gConvTree.hxx b/l10ntools/inc/gConvTree.hxx
index dda10ca..a0ecb20 100644
--- a/l10ntools/inc/gConvTree.hxx
+++ b/l10ntools/inc/gConvTree.hxx
@@ -32,7 +32,7 @@
/******************** C L A S S D E F I N I T I O N ********************/
-class convert_tree : public convert_gen_impl
+class convert_tree : public convert_gen
{
public:
typedef enum
diff --git a/l10ntools/inc/gConvUlf.hxx b/l10ntools/inc/gConvUlf.hxx
index 2fdbea6..dc7c75f 100644
--- a/l10ntools/inc/gConvUlf.hxx
+++ b/l10ntools/inc/gConvUlf.hxx
@@ -32,7 +32,7 @@
/******************** C L A S S D E F I N I T I O N ********************/
-class convert_ulf : public convert_gen_impl
+class convert_ulf : public convert_gen
{
public:
convert_ulf(l10nMem& crMemory);
diff --git a/l10ntools/inc/gConvXcs.hxx b/l10ntools/inc/gConvXcs.hxx
index a72f7c0..40cb2ca 100644
--- a/l10ntools/inc/gConvXcs.hxx
+++ b/l10ntools/inc/gConvXcs.hxx
@@ -32,7 +32,7 @@
/******************** C L A S S D E F I N I T I O N ********************/
-class convert_xcs : public convert_gen_impl
+class convert_xcs : public convert_gen
{
public:
convert_xcs(l10nMem& crMemory);
diff --git a/l10ntools/inc/gConvXcu.hxx b/l10ntools/inc/gConvXcu.hxx
index e751e36..c19f9901 100644
--- a/l10ntools/inc/gConvXcu.hxx
+++ b/l10ntools/inc/gConvXcu.hxx
@@ -33,7 +33,7 @@
/******************** C L A S S D E F I N I T I O N ********************/
class xcu_stack_entry;
-class convert_xcu : public convert_gen_impl
+class convert_xcu : public convert_gen
{
public:
bool mbNoCollectingData;
diff --git a/l10ntools/inc/gConvXhp.hxx b/l10ntools/inc/gConvXhp.hxx
index 04de5aa..d59a00b 100644
--- a/l10ntools/inc/gConvXhp.hxx
+++ b/l10ntools/inc/gConvXhp.hxx
@@ -32,7 +32,7 @@
/******************** C L A S S D E F I N I T I O N ********************/
-class convert_xhp : public convert_gen_impl
+class convert_xhp : public convert_gen
{
public:
convert_xhp(l10nMem& crMemory);
diff --git a/l10ntools/inc/gConvXrm.hxx b/l10ntools/inc/gConvXrm.hxx
index b29b536..4928bac 100644
--- a/l10ntools/inc/gConvXrm.hxx
+++ b/l10ntools/inc/gConvXrm.hxx
@@ -32,7 +32,7 @@
/******************** C L A S S D E F I N I T I O N ********************/
-class convert_xrm : public convert_gen_impl
+class convert_xrm : public convert_gen
{
public:
bool mbNoCollectingData;
diff --git a/l10ntools/source/gConv.cxx b/l10ntools/source/gConv.cxx
index eb81024..d9bb973 100644
--- a/l10ntools/source/gConv.cxx
+++ b/l10ntools/source/gConv.cxx
@@ -45,31 +45,25 @@
#endif
+convert_gen * convert_gen::mcImpl = NULL;
-/*****************************************************************************
- **************************** G C O N . C X X ****************************
- *****************************************************************************
- * This is the generic conversion module, it handles all generic work of the
- * conversion, and offer utility functions to the specific conversion classes
- *****************************************************************************/
-
-
-
-/******************* G L O B A L D E F I N I T I O N *******************/
-convert_gen_impl * convert_gen_impl::mcImpl = nullptr;
+/********************** I M P L E M E N T A T I O N **********************/
+convert_gen::convert_gen(l10nMem& cMemory)
+ : mcMemory(cMemory)
+{
+ mcImpl = this;
+}
+convert_gen::~convert_gen()
+{
+}
-/********************** I M P L E M E N T A T I O N **********************/
-convert_gen::convert_gen(l10nMem& cMemory,
+convert_gen& convert_gen::createInstance(l10nMem& cMemory,
const std::string& sSourceDir,
const std::string& sTargetDir,
const std::string& sSourceFile)
{
- // do we have an old object
- if (convert_gen_impl::mcImpl)
- delete convert_gen_impl::mcImpl;
-
// did the user give a .xxx with the source file ?
int nInx = sSourceFile.rfind(".");
if (nInx == (int)std::string::npos)
@@ -77,30 +71,24 @@ convert_gen::convert_gen(l10nMem& cMemory,
// find correct conversion class and create correct object
std::string sExtension = sSourceFile.substr(nInx+1);
- if (sExtension == "hrc") convert_gen_impl::mcImpl = new convert_src(cMemory);
- else if (sExtension == "src") convert_gen_impl::mcImpl = new convert_src(cMemory);
- else if (sExtension == "po") convert_gen_impl::mcImpl = new convert_po(cMemory);
- else if (sExtension == "pot") convert_gen_impl::mcImpl = new convert_po(cMemory);
- else if (sExtension == "tree") convert_gen_impl::mcImpl = new convert_tree(cMemory);
- else if (sExtension == "ulf") convert_gen_impl::mcImpl = new convert_ulf(cMemory);
- else if (sExtension == "xcu") convert_gen_impl::mcImpl = new convert_xcu(cMemory);
- else if (sExtension == "xhp") convert_gen_impl::mcImpl = new convert_xhp(cMemory);
- else if (sExtension == "xrm") convert_gen_impl::mcImpl = new convert_xrm(cMemory);
- else if (sExtension == "properties") convert_gen_impl::mcImpl = new convert_prop(cMemory);
+ convert_gen *x;
+ if (sExtension == "hrc") x = new convert_src(cMemory);
+ else if (sExtension == "src") x = new convert_src(cMemory);
+ else if (sExtension == "po") x = new convert_po(cMemory);
+ else if (sExtension == "pot") x = new convert_po(cMemory);
+ else if (sExtension == "tree") x = new convert_tree(cMemory);
+ else if (sExtension == "ulf") x = new convert_ulf(cMemory);
+ else if (sExtension == "xcu") x = new convert_xcu(cMemory);
+ else if (sExtension == "xhp") x = new convert_xhp(cMemory);
+ else if (sExtension == "xrm") x = new convert_xrm(cMemory);
+ else if (sExtension == "properties") x = new convert_prop(cMemory);
else throw l10nMem::showError("unknown extension on source file: "+sSourceFile);
// and set environment
- convert_gen_impl::mcImpl->msSourceFile = sSourceFile;
- convert_gen_impl::mcImpl->msTargetPath = sTargetDir;
- convert_gen_impl::mcImpl->msSourcePath = sSourceDir + sSourceFile;
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-convert_gen::~convert_gen()
-{
- delete convert_gen_impl::mcImpl;
+ x->msSourceFile = sSourceFile;
+ x->msTargetPath = sTargetDir;
+ x->msSourcePath = sSourceDir + sSourceFile;
+ return *x;
}
@@ -108,17 +96,17 @@ convert_gen::~convert_gen()
/********************** I M P L E M E N T A T I O N **********************/
bool convert_gen::execute(const bool bMerge, const bool bKid)
{
- convert_gen_impl::mcImpl->mbMergeMode = bMerge;
+ mbMergeMode = bMerge;
if (bKid)
throw l10nMem::showError("not implemented");
// and load file
- if (!convert_gen_impl::mcImpl->prepareFile())
+ if (!prepareFile())
return false;
// and execute conversion
- convert_gen_impl::mcImpl->execute();
+ execute();
return true;
}
@@ -129,11 +117,6 @@ bool convert_gen::execute(const bool bMerge, const bool bKid)
void convert_gen::startSave(const std::string& sLanguage,
const std::string& sFile)
{
- convert_gen_impl::mcImpl->startSave(sLanguage, sFile);
-}
-void convert_gen_impl::startSave(const std::string& sLanguage,
- const std::string& sFile)
-{
std::string x;
x = sLanguage;
@@ -143,21 +126,12 @@ void convert_gen_impl::startSave(const std::string& sLanguage,
-/********************** I M P L E M E N T A T I O N **********************/
void convert_gen::save(const std::string& sFileName,
const std::string& sKey,
const std::string& sENUStext,
const std::string& sText,
bool bFuzzy)
{
- convert_gen_impl::mcImpl->save(sFileName, sKey, sENUStext, sText, bFuzzy);
-}
-void convert_gen_impl::save(const std::string& sFileName,
- const std::string& sKey,
- const std::string& sENUStext,
- const std::string& sText,
- bool bFuzzy)
-{
std::string x;
if (bFuzzy)
@@ -167,13 +141,8 @@ void convert_gen_impl::save(const std::string& sFileName,
-/********************** I M P L E M E N T A T I O N **********************/
void convert_gen::endSave()
{
- convert_gen_impl::mcImpl->endSave();
-}
-void convert_gen_impl::endSave()
-{
throw l10nMem::showError("endSave called with non .po file");
}
@@ -216,26 +185,7 @@ bool convert_gen::createDir(std::string& sDir, std::string& sFile)
/********************** I M P L E M E N T A T I O N **********************/
-convert_gen_impl::convert_gen_impl(l10nMem& crMemory)
- : mbMergeMode(false),
- mbLoadMode(false),
- mcMemory(crMemory),
- miLineNo(1)
-{
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-convert_gen_impl::~convert_gen_impl()
-{
- mcImpl = nullptr;
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-bool convert_gen_impl::prepareFile()
+bool convert_gen::prepareFile()
{
std::ifstream inputFile(msSourcePath.c_str(), std::ios::binary);
@@ -290,7 +240,7 @@ bool convert_gen_impl::prepareFile()
/********************** I M P L E M E N T A T I O N **********************/
-void convert_gen_impl::lexRead(char *sBuf, int *nResult, int nMax_size)
+void convert_gen::lexRead(char *sBuf, int *nResult, int nMax_size)
{
// did we hit eof
if (miSourceReadIndex == -1)
@@ -320,7 +270,7 @@ void convert_gen_impl::lexRead(char *sBuf, int *nResult, int nMax_size)
/********************** I M P L E M E N T A T I O N **********************/
-void convert_gen_impl::writeSourceFile(const std::string& line)
+void convert_gen::writeSourceFile(const std::string& line)
{
if (!line.size())
return;
@@ -332,7 +282,7 @@ void convert_gen_impl::writeSourceFile(const std::string& line)
/********************** I M P L E M E N T A T I O N **********************/
-std::string& convert_gen_impl::copySource(char const *yyText, bool bDoClear)
+std::string& convert_gen::copySource(char const *yyText, bool bDoClear)
{
int nL;
diff --git a/l10ntools/source/gConvDB.cxx b/l10ntools/source/gConvDB.cxx
index 36689c8..c0931eb 100644
--- a/l10ntools/source/gConvDB.cxx
+++ b/l10ntools/source/gConvDB.cxx
@@ -24,16 +24,7 @@
-/*****************************************************************************
- ************************** G C O N D B . C X X **************************
- *****************************************************************************
- * This includes the c code generated by flex
- *****************************************************************************/
-
-
-
-/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
-convert_db::convert_db(l10nMem& crMemory) : convert_gen_impl(crMemory) {}
+convert_db::convert_db(l10nMem& crMemory) : convert_gen(crMemory) {}
convert_db::~convert_db() {}
diff --git a/l10ntools/source/gConvPo.cxx b/l10ntools/source/gConvPo.cxx
index 82dcf44..e540d70 100644
--- a/l10ntools/source/gConvPo.cxx
+++ b/l10ntools/source/gConvPo.cxx
@@ -37,7 +37,7 @@
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_po::convert_po(l10nMem& crMemory)
- : convert_gen_impl(crMemory),
+ : convert_gen(crMemory),
mbExpectId(false),
mbExpectStr(false),
mbFuzzy(false)
diff --git a/l10ntools/source/gConvProp.cxx b/l10ntools/source/gConvProp.cxx
index b9e5755..e751737 100644
--- a/l10ntools/source/gConvProp.cxx
+++ b/l10ntools/source/gConvProp.cxx
@@ -24,16 +24,7 @@
-/*****************************************************************************
- ************************ G C O N P R O P . C X X ************************
- *****************************************************************************
- * This is the conversion for .properties files
- *****************************************************************************/
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-convert_prop::convert_prop(l10nMem& crMemory) : convert_gen_impl(crMemory)
+convert_prop::convert_prop(l10nMem& crMemory) : convert_gen(crMemory)
{
// throw l10nMem::showError(std::string("convert_prop not implemented"));
}
diff --git a/l10ntools/source/gConvSrc.cxx b/l10ntools/source/gConvSrc.cxx
index 08b4aa1..08fe485 100644
--- a/l10ntools/source/gConvSrc.cxx
+++ b/l10ntools/source/gConvSrc.cxx
@@ -28,17 +28,8 @@
#include <sstream>
-/*****************************************************************************
- ********************* G C O N S R C W R A P . C X X *********************
- *****************************************************************************
- * This includes the c code generated by flex
- *****************************************************************************/
-
-
-
-/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_src::convert_src(l10nMem& crMemory)
- : convert_gen_impl(crMemory),
+ : convert_gen(crMemory),
mbExpectValue(false),
mbEnUs(false),
mbExpectName(false),
diff --git a/l10ntools/source/gConvTree.cxx b/l10ntools/source/gConvTree.cxx
index 45ff1bd..cac25a4 100644
--- a/l10ntools/source/gConvTree.cxx
+++ b/l10ntools/source/gConvTree.cxx
@@ -23,18 +23,8 @@
#include "gConvTree.hxx"
-
-/*****************************************************************************
- ******************** G C O N T R E E W R A P . C X X ********************
- *****************************************************************************
- * This includes the c code generated by flex
- *****************************************************************************/
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
convert_tree::convert_tree(l10nMem& crMemory)
- : convert_gen_impl(crMemory),
+ : convert_gen(crMemory),
mcOutputFiles(nullptr),
meStateTag(STATE_TAG_NONE),
meStateVal(STATE_VAL_NONE),
diff --git a/l10ntools/source/gConvUlf.cxx b/l10ntools/source/gConvUlf.cxx
index 361065a..d8d5651 100644
--- a/l10ntools/source/gConvUlf.cxx
+++ b/l10ntools/source/gConvUlf.cxx
@@ -24,16 +24,7 @@
-/*****************************************************************************
- ********************* G C O N X C S W R A P . C X X *********************
- *****************************************************************************
- * This includes the c code generated by flex
- *****************************************************************************/
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-convert_ulf::convert_ulf(l10nMem& crMemory) : convert_gen_impl(crMemory) {}
+convert_ulf::convert_ulf(l10nMem& crMemory) : convert_gen(crMemory) {}
convert_ulf::~convert_ulf() {}
diff --git a/l10ntools/source/gConvXcs.cxx b/l10ntools/source/gConvXcs.cxx
index 31cbaee..45b41e2 100644
--- a/l10ntools/source/gConvXcs.cxx
+++ b/l10ntools/source/gConvXcs.cxx
@@ -24,17 +24,8 @@
-/*****************************************************************************
- ********************* G C O N X C S W R A P . C X X *********************
- *****************************************************************************
- * This includes the c code generated by flex
- *****************************************************************************/
-
-
-
-/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xcs::convert_xcs(l10nMem& crMemory)
- : convert_gen_impl(crMemory),
+ : convert_gen(crMemory),
mbCollectingData(false)
{
}
diff --git a/l10ntools/source/gConvXcu.cxx b/l10ntools/source/gConvXcu.cxx
index e8070bc..ff7e7f6 100644
--- a/l10ntools/source/gConvXcu.cxx
+++ b/l10ntools/source/gConvXcu.cxx
@@ -21,19 +21,8 @@
#include "gL10nMem.hxx"
#include "gConvXcu.hxx"
-
-
-/*****************************************************************************
- ********************* G C O N X C U W R A P . C X X *********************
- *****************************************************************************
- * This includes the c code generated by flex
- *****************************************************************************/
-
-
-
-/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xcu::convert_xcu(l10nMem& crMemory)
- : convert_gen_impl(crMemory),
+ : convert_gen(crMemory),
mbNoCollectingData(true),
miLevel(0),
mbNoTranslate(false)
diff --git a/l10ntools/source/gConvXhp.cxx b/l10ntools/source/gConvXhp.cxx
index b2c58ac..b10b038 100644
--- a/l10ntools/source/gConvXhp.cxx
+++ b/l10ntools/source/gConvXhp.cxx
@@ -21,20 +21,8 @@
#include "gL10nMem.hxx"
#include "gConvXhp.hxx"
-
-
-
-/*****************************************************************************
- ********************* G C O N X H P W R A P . C X X *********************
- *****************************************************************************
- * This includes the c code generated by flex
- *****************************************************************************/
-
-
-
-/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xhp::convert_xhp(l10nMem& crMemory)
- : convert_gen_impl(crMemory),
+ : convert_gen(crMemory),
meExpectValue(VALUE_NOT_USED),
msLangText(nullptr),
mcOutputFiles(nullptr),
diff --git a/l10ntools/source/gConvXrm.cxx b/l10ntools/source/gConvXrm.cxx
index 0c22744..0e71bf2 100644
--- a/l10ntools/source/gConvXrm.cxx
+++ b/l10ntools/source/gConvXrm.cxx
@@ -23,17 +23,9 @@
#include "gConvXrm.hxx"
-/*****************************************************************************
- ********************* G C O N X R M W R A P . C X X *********************
- *****************************************************************************
- * This includes the c code generated by flex
- *****************************************************************************/
-
-
-/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xrm::convert_xrm(l10nMem& crMemory)
- : convert_gen_impl(crMemory),
+ : convert_gen(crMemory),
mbNoCollectingData(true),
mbIsTag(false),
mbIsLang(false)
diff --git a/l10ntools/source/gLang.cxx b/l10ntools/source/gLang.cxx
index 757e9eb..d4bb18f 100644
--- a/l10ntools/source/gLang.cxx
+++ b/l10ntools/source/gLang.cxx
@@ -330,7 +330,7 @@ void handler::loadL10MEM(bool onlyTemplates)
// and load file
mcMemory.setLanguage("", true);
- convert_gen (mcMemory, sLoad, msTargetDir, "").execute(false, false);
+ convert_gen::createInstance(mcMemory, sLoad, msTargetDir, "").execute(false, false);
if (onlyTemplates)
return;
@@ -346,7 +346,7 @@ void handler::loadL10MEM(bool onlyTemplates)
// tell system
l10nMem::showDebug("genLang loading text from language file " + sLoad);
- convert_gen(mcMemory, sLoad, msTargetDir, "").execute(false, false);
+ convert_gen::createInstance(mcMemory, sLoad, msTargetDir, "").execute(false, false);
}
}
@@ -368,7 +368,7 @@ void handler::runConvert()
l10nMem::showDebug("genLang compare template " + *siSource);
// get converter and extract files
- convert_gen convertObj(mcMemory, "./", msTargetDir, *siSource);
+ convert_gen& convertObj = convert_gen::createInstance(mcMemory, "./", msTargetDir, *siSource);
convertObj.execute(false, false);
mcMemory.showNOconvert();
@@ -385,7 +385,7 @@ void handler::runConvert()
sFilePath + *siSource + " language " + *siLang);
// get converter and extract files
- //convert_gen convertObj(mcMemory, sFilePath, msTargetDir, *siSource);
+ convert_gen& convertObj = convert_gen::createInstance(mcMemory, sFilePath, msTargetDir, *siSource);
convertObj.execute(true, false);
}
}
@@ -411,7 +411,7 @@ void handler::runExtract()
l10nMem::showDebug("genLang extracting text from file " + *siSource);
// get converter and extract file
- convert_gen convertObj(mcMemory, "", msTargetDir, *siSource);
+ convert_gen& convertObj = convert_gen::createInstance(mcMemory, "", msTargetDir, *siSource);
convertObj.execute(false, false);
}
@@ -435,7 +435,7 @@ void handler::runMerge(bool bKid)
l10nMem::showDebug("genLang merging translated text to file " + *siSource);
// get converter and extract file
- convert_gen convertObj(mcMemory, "", msTargetDir, *siSource);
+ convert_gen& convertObj = convert_gen::createInstance(mcMemory, "", msTargetDir, *siSource);
convertObj.execute(true, bKid);
}
}
diff --git a/l10ntools/source/gLexPo.l b/l10ntools/source/gLexPo.l
index 3d6bfc3..ae4db4f 100644
--- a/l10ntools/source/gLexPo.l
+++ b/l10ntools/source/gLexPo.l
@@ -41,8 +41,8 @@
#include "gL10nMem.hxx"
#include "gConvPo.hxx"
-#define IMPLptr convert_gen_impl::mcImpl
-#define LOCptr ((convert_po *)convert_gen_impl::mcImpl)
+#define IMPLptr convert_gen::mcImpl
+#define LOCptr ((convert_po *)convert_gen::mcImpl)
/* enlarge token buffer to tokenize whole std::strings */
#undef YYLMAX
diff --git a/l10ntools/source/gLexSrc.l b/l10ntools/source/gLexSrc.l
index d298d0f..b9c0c3b 100644
--- a/l10ntools/source/gLexSrc.l
+++ b/l10ntools/source/gLexSrc.l
@@ -26,8 +26,8 @@
#include "gL10nMem.hxx"
#include "gConvSrc.hxx"
-#define IMPLptr convert_gen_impl::mcImpl
-#define LOCptr ((convert_src *)convert_gen_impl::mcImpl)
+#define IMPLptr convert_gen::mcImpl
+#define LOCptr ((convert_src *)convert_gen::mcImpl)
/* enlarge token buffer to tokenize whole std::strings */
#undef YYLMAX
diff --git a/l10ntools/source/gLexTree.l b/l10ntools/source/gLexTree.l
index 4b8aa2c9..095f681 100644
--- a/l10ntools/source/gLexTree.l
+++ b/l10ntools/source/gLexTree.l
@@ -26,8 +26,8 @@
#include "gL10nMem.hxx"
#include "gConvTree.hxx"
-#define IMPLptr convert_gen_impl::mcImpl
-#define LOCptr ((convert_tree *)convert_gen_impl::mcImpl)
+#define IMPLptr convert_gen::mcImpl
+#define LOCptr ((convert_tree *)convert_gen::mcImpl)
/* enlarge token buffer to tokenize whole std::strings */
#undef YYLMAX
diff --git a/l10ntools/source/gLexUlf.l b/l10ntools/source/gLexUlf.l
index bb204f2..45bc99c 100644
--- a/l10ntools/source/gLexUlf.l
+++ b/l10ntools/source/gLexUlf.l
@@ -26,8 +26,8 @@
#include "gL10nMem.hxx"
#include "gConvUlf.hxx"
-#define IMPLptr convert_gen_impl::mcImpl
-#define LOCptr ((convert_ulf *)convert_gen_impl::mcImpl)
+#define IMPLptr convert_gen::mcImpl
+#define LOCptr ((convert_ulf *)convert_gen::mcImpl)
/* enlarge token buffer to tokenize whole std::strings */
#undef YYLMAX
diff --git a/l10ntools/source/gLexXcs.l b/l10ntools/source/gLexXcs.l
index cfd11da..1b4a3b4 100644
--- a/l10ntools/source/gLexXcs.l
+++ b/l10ntools/source/gLexXcs.l
@@ -26,8 +26,8 @@
#include "gL10nMem.hxx"
#include "gConvXcs.hxx"
-#define IMPLptr convert_gen_impl::mcImpl
-#define LOCptr ((convert_xcs *)convert_gen_impl::mcImpl)
+#define IMPLptr convert_gen::mcImpl
+#define LOCptr ((convert_xcs *)convert_gen::mcImpl)
/* enlarge token buffer to tokenize whole std::strings */
#undef YYLMAX
diff --git a/l10ntools/source/gLexXcu.l b/l10ntools/source/gLexXcu.l
index b3095ef..9359e38 100644
--- a/l10ntools/source/gLexXcu.l
+++ b/l10ntools/source/gLexXcu.l
@@ -26,8 +26,8 @@
#include "gL10nMem.hxx"
#include "gConvXcu.hxx"
-#define IMPLptr convert_gen_impl::mcImpl
-#define LOCptr ((convert_xcu *)convert_gen_impl::mcImpl)
+#define IMPLptr convert_gen::mcImpl
+#define LOCptr ((convert_xcu *)convert_gen::mcImpl)
/* enlarge token buffer to tokenize whole std::strings */
#undef YYLMAX
diff --git a/l10ntools/source/gLexXhp.l b/l10ntools/source/gLexXhp.l
index a2c23fd..46b0764 100644
--- a/l10ntools/source/gLexXhp.l
+++ b/l10ntools/source/gLexXhp.l
@@ -26,8 +26,8 @@
#include "gL10nMem.hxx"
#include "gConvXhp.hxx"
-#define IMPLptr convert_gen_impl::mcImpl
-#define LOCptr ((convert_xhp *)convert_gen_impl::mcImpl)
+#define IMPLptr convert_gen::mcImpl
+#define LOCptr ((convert_xhp *)convert_gen::mcImpl)
/* enlarge token buffer to tokenize whole std::strings */
#undef YYLMAX
diff --git a/l10ntools/source/gLexXrm.l b/l10ntools/source/gLexXrm.l
index aadab8e..e8bbf23 100644
--- a/l10ntools/source/gLexXrm.l
+++ b/l10ntools/source/gLexXrm.l
@@ -26,8 +26,8 @@
#include "gL10nMem.hxx"
#include "gConvXrm.hxx"
-#define IMPLptr convert_gen_impl::mcImpl
-#define LOCptr ((convert_xrm *)convert_gen_impl::mcImpl)
+#define IMPLptr convert_gen::mcImpl
+#define LOCptr ((convert_xrm *)convert_gen::mcImpl)
/* enlarge token buffer to tokenize whole std::strings */
#undef YYLMAX
commit 48c2e04bdb60429823cb8b12a14d954af544a2bf
Author: jan iversen <jani at documentfoundation.org>
Date: Mon Mar 14 22:10:23 2016 +0100
genLang update
removed gL10nMemDB (combined with gL10nMemDB) to avoid CLANG problem.
removed (temporary) gL10nMem dependency on convPO (circular dep).
Change-Id: I17646be2ccc0feaaa8850a9b753f86c8c62e9f24
diff --git a/l10ntools/Executable_genlang.mk b/l10ntools/Executable_genlang.mk
index 13789e0..0badea2 100644
--- a/l10ntools/Executable_genlang.mk
+++ b/l10ntools/Executable_genlang.mk
@@ -28,7 +28,6 @@ $(eval $(call gb_Executable_add_scanners,genlang,\
$(eval $(call gb_Executable_add_exception_objects,genlang,\
l10ntools/source/gLang \
l10ntools/source/gL10nMem \
- l10ntools/source/gL10nMemDB \
l10ntools/source/gConvProp \
l10ntools/source/gConv \
l10ntools/source/gConvDB \
diff --git a/l10ntools/inc/gConv.hxx b/l10ntools/inc/gConv.hxx
index 7287a49..604e5ed 100644
--- a/l10ntools/inc/gConv.hxx
+++ b/l10ntools/inc/gConv.hxx
@@ -19,11 +19,33 @@
#ifndef GCON_HXX
#define GCON_HXX
-#include "gLang.hxx"
-
#include <iostream>
#include <fstream>
+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);
+};
/*****************************************************************************
diff --git a/l10ntools/inc/gL10nMem.hxx b/l10ntools/inc/gL10nMem.hxx
index e7dcd70..94e76c9 100644
--- a/l10ntools/inc/gL10nMem.hxx
+++ b/l10ntools/inc/gL10nMem.hxx
@@ -16,78 +16,77 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-
#ifndef GL10NMEM_HXX
#define GL10NMEM_HXX
-#include "gLang.hxx"
-
-
-
-class l10nMem_lang_entry
-{
- public:
- l10nMem_lang_entry(const std::string& sMsgStr, bool bFuzzy);
- ~l10nMem_lang_entry();
-
- std::string msMsgStr; // translated text from po file
- bool mbFuzzy; // fuzzy flag
-};
-
-
-class l10nMem_enus_entry
+class l10nMem_enus_entry;
+class l10nMem_file_entry;
+class l10nMem_lang_list_entry;
+class l10nMem
{
- public:
- l10nMem_enus_entry(const std::string& sKey,
- const std::string& sMsgId,
- int iLineNo,
- int iFileInx,
- int iLangSize,
- l10nMem::ENTRY_STATE eState);
- ~l10nMem_enus_entry();
-
- std::string msKey; // key in po file and 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
- std::vector<l10nMem_lang_entry> mcLangText; // language texts (index is languageId)
-};
-
-
-
-class l10nMem_file_entry
-{
- public:
- l10nMem_file_entry(const std::string& sFileName, int iStart);
- ~l10nMem_file_entry();
-
- std::string msFileName; // file Name with relative path
- std::string msPureName; // just filename
- int miStart; // start index of entries in mcMasterEntries (l10Mem_db::mcENUS)
- int miEnd; // last index of entries in mcMasterEntries (l10Mem_db::mcENUS)
-};
-
-
-
-class l10nMem_lang_list_entry
-{
- public:
- l10nMem_lang_list_entry(const std::string& sName);
- ~l10nMem_lang_list_entry();
-
- std::string msName; // language Name
- bool mbChanged; // used for "convert", true if language is modified
-};
-
-
-
-class l10nMem_db
-{
- public:
- l10nMem_db();
- ~l10nMem_db();
-
+public:
+ l10nMem();
+ ~l10nMem();
+
+ typedef enum
+ {
+ ENTRY_DELETED,
+ ENTRY_ADDED,
+ ENTRY_CHANGED,
+ ENTRY_NORMAL
+ } ENTRY_STATE;
+
+ 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 void keyToUpper(std::string& sKey);
+
+ 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 setVerbose(const bool doVerbose);
+ void setDebug(const bool doDebug);
+
+
+ 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();
+ bool isError();
+
+ void convertToInetString(std::string& sText);
+ void convertFromInetString(std::string& sText);
+
+private:
+ bool mbVerbose;
+ bool mbDebug;
+ bool mbInError;
+ std::string msModuleName;
int miCurFileInx;
int miCurLangInx;
int miCurENUSinx;
@@ -98,41 +97,43 @@ class l10nMem_db
std::vector<l10nMem_file_entry> mcFileList;
std::vector<l10nMem_lang_list_entry> mcLangList;
-
- void loadENUSkey (int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sMsgId);
- void setLanguage (const std::string& sLanguage,
- 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& sMsgId,
- const std::string& sMsgStr,
- bool bFuzzy);
-
-
- bool locateKey (int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sMsgId,
- bool bThrow);
- void reorganize (bool bConvert);
- void addKey (int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- 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);
+ 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);
+
+ void loadENUSkey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId);
+ void loadLangKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
+ bool bFuzzy);
+ void reorganize(bool bConvert);
+ bool locateKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ bool bThrow);
+ void addKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ l10nMem::ENTRY_STATE eStat);
+ bool findFileName(const std::string& sSourceFile);
};
#endif
diff --git a/l10ntools/inc/gLang.hxx b/l10ntools/inc/gLang.hxx
deleted file mode 100644
index 381d4d9..0000000
--- a/l10ntools/inc/gLang.hxx
+++ /dev/null
@@ -1,135 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#ifndef GLANG_HXX
-#define GLANG_HXX
-#include <string>
-#include <vector>
-
-
-
-class l10nMem_db;
-class l10nMem
-{
- 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;
-};
-
-
-
-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);
-};
-#endif
diff --git a/l10ntools/source/gConv.cxx b/l10ntools/source/gConv.cxx
index 164b245..eb81024 100644
--- a/l10ntools/source/gConv.cxx
+++ b/l10ntools/source/gConv.cxx
@@ -16,7 +16,10 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <string>
+#include <vector>
+#include "gL10nMem.hxx"
#include "gConv.hxx"
#include "gConvDB.hxx"
#include "gConvPo.hxx"
diff --git a/l10ntools/source/gConvDB.cxx b/l10ntools/source/gConvDB.cxx
index a6d01a7..36689c8 100644
--- a/l10ntools/source/gConvDB.cxx
+++ b/l10ntools/source/gConvDB.cxx
@@ -16,7 +16,10 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <string>
+#include <vector>
+#include "gL10nMem.hxx"
#include "gConvDB.hxx"
diff --git a/l10ntools/source/gConvPo.cxx b/l10ntools/source/gConvPo.cxx
index 8bbedc7..82dcf44 100644
--- a/l10ntools/source/gConvPo.cxx
+++ b/l10ntools/source/gConvPo.cxx
@@ -16,7 +16,10 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <string>
+#include <vector>
+#include "gL10nMem.hxx"
#include "gConvPo.hxx"
#include <iostream>
#include <fstream>
diff --git a/l10ntools/source/gConvProp.cxx b/l10ntools/source/gConvProp.cxx
index a506761..b9e5755 100644
--- a/l10ntools/source/gConvProp.cxx
+++ b/l10ntools/source/gConvProp.cxx
@@ -16,7 +16,10 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <string>
+#include <vector>
+#include "gL10nMem.hxx"
#include "gConvProp.hxx"
diff --git a/l10ntools/source/gConvSrc.cxx b/l10ntools/source/gConvSrc.cxx
index f579d47..08b4aa1 100644
--- a/l10ntools/source/gConvSrc.cxx
+++ b/l10ntools/source/gConvSrc.cxx
@@ -16,13 +16,16 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <string>
+#include <vector>
+
+#include "gL10nMem.hxx"
#include "gConvSrc.hxx"
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <sstream>
-#include <string.h>
/*****************************************************************************
diff --git a/l10ntools/source/gConvTree.cxx b/l10ntools/source/gConvTree.cxx
index d7fca81..45ff1bd 100644
--- a/l10ntools/source/gConvTree.cxx
+++ b/l10ntools/source/gConvTree.cxx
@@ -16,7 +16,10 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <string>
+#include <vector>
+#include "gL10nMem.hxx"
#include "gConvTree.hxx"
diff --git a/l10ntools/source/gConvUlf.cxx b/l10ntools/source/gConvUlf.cxx
index c766d53..361065a 100644
--- a/l10ntools/source/gConvUlf.cxx
+++ b/l10ntools/source/gConvUlf.cxx
@@ -16,11 +16,11 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <string>
+#include <vector>
+#include "gL10nMem.hxx"
#include "gConvUlf.hxx"
-#include <iostream>
-#include <fstream>
-#include <cstdlib>
diff --git a/l10ntools/source/gConvXcs.cxx b/l10ntools/source/gConvXcs.cxx
index ec010d4..31cbaee 100644
--- a/l10ntools/source/gConvXcs.cxx
+++ b/l10ntools/source/gConvXcs.cxx
@@ -16,11 +16,11 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <string>
+#include <vector>
+#include "gL10nMem.hxx"
#include "gConvXcs.hxx"
-#include <iostream>
-#include <fstream>
-#include <cstdlib>
diff --git a/l10ntools/source/gConvXcu.cxx b/l10ntools/source/gConvXcu.cxx
index 8cf309b..e8070bc 100644
--- a/l10ntools/source/gConvXcu.cxx
+++ b/l10ntools/source/gConvXcu.cxx
@@ -16,11 +16,11 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <string>
+#include <vector>
+#include "gL10nMem.hxx"
#include "gConvXcu.hxx"
-#include <iostream>
-#include <fstream>
-#include <cstdlib>
/*****************************************************************************
diff --git a/l10ntools/source/gConvXhp.cxx b/l10ntools/source/gConvXhp.cxx
index 0cb925f..b2c58ac 100644
--- a/l10ntools/source/gConvXhp.cxx
+++ b/l10ntools/source/gConvXhp.cxx
@@ -16,7 +16,10 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <string>
+#include <vector>
+#include "gL10nMem.hxx"
#include "gConvXhp.hxx"
diff --git a/l10ntools/source/gConvXrm.cxx b/l10ntools/source/gConvXrm.cxx
index b86c579..0c22744 100644
--- a/l10ntools/source/gConvXrm.cxx
+++ b/l10ntools/source/gConvXrm.cxx
@@ -16,7 +16,10 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <string>
+#include <vector>
+#include "gL10nMem.hxx"
#include "gConvXrm.hxx"
diff --git a/l10ntools/source/gL10nMem.cxx b/l10ntools/source/gL10nMem.cxx
index 44eed38..604a6d6 100644
--- a/l10ntools/source/gL10nMem.cxx
+++ b/l10ntools/source/gL10nMem.cxx
@@ -16,29 +16,132 @@
* 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 <string>
+#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
+#include "gL10nMem.hxx"
+
l10nMem *myMem;
+class l10nMem_lang_list_entry
+{
+public:
+ l10nMem_lang_list_entry(const std::string& sName) :
+ msName(sName),
+ mbChanged(false)
+ {}
+
+ ~l10nMem_lang_list_entry() {};
+
+ std::string msName; // language Name
+ bool mbChanged; // used for "convert", true if language is modified
+};
+
+
+class l10nMem_file_entry
+{
+public:
+ l10nMem_file_entry(const std::string& sFileName, int iStart)
+ :
+ msFileName(sFileName),
+ miStart(iStart),
+ miEnd(iStart)
+ {
+ // Store fileName without relative path
+ int i = msFileName.rfind("/");
+ if (i == (int)std::string::npos)
+ msPureName = msFileName;
+ else
+ msPureName = msFileName.substr(i + 1);
+ }
+ ~l10nMem_file_entry() {};
+
+ std::string msFileName; // file Name with relative path
+ std::string msPureName; // just filename
+ int miStart; // start index of entries in mcMasterEntries (l10Mem_db::mcENUS)
+ int miEnd; // last index of entries in mcMasterEntries (l10Mem_db::mcENUS)
+};
+
+
+
+class l10nMem_lang_entry
+{
+public:
+ l10nMem_lang_entry(const std::string& sMsgStr, bool bFuzzy)
+ :
+ msMsgStr(sMsgStr),
+ mbFuzzy(bFuzzy)
+ {}
+ ~l10nMem_lang_entry() {};
+
+ std::string msMsgStr; // translated text from po file
+ bool mbFuzzy; // fuzzy flag
+};
+
+
+
+class l10nMem_enus_entry
+{
+public:
+ l10nMem_enus_entry(const std::string& sKey,
+ const std::string& sMsgId,
+ int iLineNo,
+ int iFileInx,
+ int iLangSize,
+ l10nMem::ENTRY_STATE eState)
+ :
+ msMsgId(sMsgId),
+ meState(eState),
+ miFileInx(iFileInx),
+ miLineNo(iLineNo)
+ {
+ int i;
+
+ // add dummy language entries
+ for (i = 0; i < iLangSize; ++i)
+ mcLangText.push_back(l10nMem_lang_entry("", false));
+
+ // convert key to upper case
+ msKey = sKey;
+ l10nMem::keyToUpper(msKey);
+ }
+
+ ~l10nMem_enus_entry() {};
+
+ std::string msKey; // key in po file and 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
+ std::vector<l10nMem_lang_entry> mcLangText; // language texts (index is languageId)
+};
+
l10nMem::l10nMem()
: mbVerbose(false),
mbDebug(false),
- mbInError(false)
+ mbInError(false),
+ miCurFileInx(0),
+ miCurLangInx(0),
+ miCurENUSinx(0),
+ mbNeedWrite(false),
+ mbConvertMode(false),
+ mbStrictMode(false)
{
- mcDb = new l10nMem_db;
myMem = this;
+ mcFileList.push_back(l10nMem_file_entry("-genLang-", 0));
+ mcLangList.push_back(l10nMem_lang_list_entry("-genLang-"));
+ mcENUSlist.push_back(l10nMem_enus_entry("-genLang-", "-genLang-", 0, 0, 0, l10nMem::ENTRY_DELETED));
}
l10nMem::~l10nMem()
{
- delete mcDb;
}
@@ -97,17 +200,69 @@ const std::string& l10nMem::getModuleName()
void l10nMem::setLanguage(const std::string& sLanguage,
- bool bCreate)
+ bool bCreate)
{
- mcDb->setLanguage(sLanguage, bCreate);
+ int i, iSize;
+
+ // regular load or convert of old po files
+ miCurFileInx = 0;
+
+ // With no languages selected only en-US is generated
+ if (!sLanguage.size())
+ {
+ miCurLangInx = 0;
+ return;
+ }
+
+ // en-US is loaded as master and cannot be loaded again
+ if (sLanguage == "en-US")
+ throw l10nMem::showError("en-US is loaded automatically");
+
+ // check if language is already loaded
+ iSize = mcLangList.size();
+ for (miCurLangInx = 0; miCurLangInx < iSize && mcLangList[miCurLangInx].msName != sLanguage; ++miCurLangInx);
+ if (miCurLangInx < iSize)
+ {
+ if (bCreate)
+ throw showError("loading " + sLanguage + " twice");
+ return;
+ }
+
+ // language does not exist in db
+ if (!bCreate)
+ throw showError("language " + sLanguage + " not loaded");
+
+ // create language
+ mcLangList.push_back(sLanguage);
+
+ // add language to all ENUS entries
+ iSize = mcENUSlist.size();
+ for (i = 0; i < iSize; ++i)
+ mcENUSlist[i].mcLangText.push_back(l10nMem_lang_entry("", false));
}
void l10nMem::setConvert(bool bConvert,
- bool bStrict)
+ bool bStrict)
+{
+ // regular load or convert of old po files
+ mbConvertMode = bConvert;
+ mbStrictMode = bStrict;
+}
+
+
+
+void l10nMem::setVerbose(bool doVerbose)
{
- mcDb->setConvert(bConvert, bStrict);
+ mbVerbose = doVerbose;
+}
+
+
+
+void l10nMem::setDebug(bool doDebug)
+{
+ mbDebug = doDebug;
}
@@ -119,12 +274,12 @@ void l10nMem::loadEntryKey(int iLineNo,
const std::string& sMsgStr,
bool bIsFuzzy)
{
- if (mcDb->mbConvertMode)
+ if (mbConvertMode)
convEntryKey(iLineNo, sSourceFile, sKey, sMsgId, sMsgStr, bIsFuzzy);
- else if (!mcDb->miCurLangInx)
- mcDb->loadENUSkey(iLineNo, sSourceFile, sKey, sMsgId);
+ else if (!miCurLangInx)
+ loadENUSkey(iLineNo, sSourceFile, sKey, sMsgId);
else
- mcDb->loadLangKey(iLineNo, sSourceFile, sKey, sMsgId, sMsgStr, bIsFuzzy);
+ loadLangKey(iLineNo, sSourceFile, sKey, sMsgId, sMsgStr, bIsFuzzy);
}
@@ -157,14 +312,14 @@ void l10nMem::setSourceKey(int iLineNo,
}
// if key exist update state
- if (mcDb->locateKey(iLineNo, sSourceFile, sKey, newText, false))
- mcDb->mcENUSlist[mcDb->miCurENUSinx].meState = ENTRY_NORMAL;
+ if (locateKey(iLineNo, sSourceFile, sKey, newText, false))
+ mcENUSlist[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);
+ addKey(iLineNo, sSourceFile, sKey, newText, ENTRY_ADDED);
}
}
@@ -172,7 +327,7 @@ void l10nMem::setSourceKey(int iLineNo,
void l10nMem::saveTemplates(const std::string& sTargetDir, bool bKid, bool bForce)
{
-// int iEsize = mcDb->mcENUSlist.size();
+// int iEsize = mcENUSlist.size();
std::string sFileName = msModuleName + ".pot";
// Dummy to satisfy compiler
@@ -181,8 +336,8 @@ void l10nMem::saveTemplates(const std::string& sTargetDir, bool bKid, bool bForc
showError(sTargetDir);
// and reorganize db if needed
- mcDb->miCurFileInx = 0;
- mcDb->reorganize(false);
+ miCurFileInx = 0;
+ reorganize(false);
// no save if there has been errors
if (!needWrite(sFileName, bForce))
@@ -196,13 +351,13 @@ void l10nMem::saveTemplates(const std::string& sTargetDir, bool bKid, bool bForc
savePo.startSave("templates/", sFileName);
for (iE = 1; iE < iEsize; ++iE) {
- l10nMem_enus_entry& cE = mcDb->mcENUSlist[iE];
+ l10nMem_enus_entry& cE = mcENUSlist[iE];
// remove deleted entries
if (cE.meState == ENTRY_DELETED)
continue;
- savePo.save(mcDb->mcFileList[cE.miFileInx].msFileName, cE.msKey, cE.msMsgId, "", false);
+ savePo.save(mcFileList[cE.miFileInx].msFileName, cE.msKey, cE.msMsgId, "", false);
}
savePo.endSave();
#endif
@@ -212,14 +367,19 @@ void l10nMem::saveTemplates(const std::string& sTargetDir, bool bKid, bool bForc
void l10nMem::saveLanguages(l10nMem& cMem, const std::string& sTargetDir, bool bForce)
{
- int iE, iEsize = mcDb->mcENUSlist.size();
- int iL, iLsize = mcDb->mcLangList.size();
+// int iE, iEsize = mcENUSlist.size();
+// int iEsize = mcENUSlist.size();
+ int iL, iLsize = mcLangList.size();
std::string sFileName = msModuleName + ".po";
+ cMem.dumpMem("jan");
+ showDebug(sTargetDir);
+ if (bForce)
+ showDebug("debug");
// and reorganize db if needed
- mcDb->miCurFileInx = 0;
- mcDb->reorganize(true);
+ miCurFileInx = 0;
+ reorganize(true);
// no save if there has been errors
if (!needWrite(sFileName, bForce))
@@ -228,15 +388,16 @@ void l10nMem::saveLanguages(l10nMem& cMem, const std::string& sTargetDir, bool b
// save all languages
for (iL = 1; iL < iLsize; ++iL) {
// only save language file if modified
- if (!mcDb->mcLangList[iL].mbChanged)
+ if (!mcLangList[iL].mbChanged)
continue;
- mcDb->mcLangList[iL].mbChanged = false;
+ mcLangList[iL].mbChanged = false;
+#if 0
convert_gen savePo(cMem, sTargetDir, sTargetDir, sFileName);
- savePo.startSave(mcDb->mcLangList[iL].msName + "/", sFileName);
+ savePo.startSave(mcLangList[iL].msName + "/", sFileName);
for (iE = 1; iE < iEsize; ++iE) {
- l10nMem_enus_entry& cE = mcDb->mcENUSlist[iE];
+ l10nMem_enus_entry& cE = mcENUSlist[iE];
l10nMem_lang_entry& cL = cE.mcLangText[iL];
bool bF = cL.mbFuzzy;
@@ -244,9 +405,10 @@ void l10nMem::saveLanguages(l10nMem& cMem, const std::string& sTargetDir, bool b
if (cE.meState == ENTRY_DELETED)
continue;
- savePo.save(mcDb->mcFileList[cE.miFileInx].msFileName, cE.msKey, cE.msMsgId, cL.msMsgStr, bF);
+ savePo.save(mcFileList[cE.miFileInx].msFileName, cE.msKey, cE.msMsgId, cL.msMsgStr, bF);
}
savePo.endSave();
+#endif
}
}
@@ -254,10 +416,10 @@ void l10nMem::saveLanguages(l10nMem& cMem, const std::string& sTargetDir, bool b
void l10nMem::showNOconvert()
{
- int iE, iEsize = mcDb->mcENUSlist.size();
+ int iE, iEsize = mcENUSlist.size();
for (iE = 1; iE < iEsize; ++iE) {
- l10nMem_enus_entry& cE = mcDb->mcENUSlist[iE];
+ l10nMem_enus_entry& cE = mcENUSlist[iE];
if (cE.meState == ENTRY_DELETED)
showError("template key(" + cE.msKey + ") msgId(" + cE.msMsgId + ") not in pot file", 0);
@@ -306,7 +468,8 @@ void l10nMem::convertFromInetString(std::string& sText)
int l10nMem::prepareMerge()
{
- return mcDb->prepareMerge();
+ miCurLangInx = 0;
+ return mcLangList.size();
}
@@ -314,7 +477,7 @@ int l10nMem::prepareMerge()
void l10nMem::dumpMem(const std::string& sFileName)
{
// and reorganize db if needed
- mcDb->reorganize(false);
+ reorganize(false);
// no save if there has been errors
if (!needWrite(sFileName, true))
@@ -325,9 +488,19 @@ void l10nMem::dumpMem(const std::string& sFileName)
-bool l10nMem::getMergeLang(std::string& sL, std::string& sT)
+bool l10nMem::getMergeLang(std::string& sLang, std::string& sMsgStr)
{
- return mcDb->getMergeLang(sL, sT);
+ miCurLangInx++;
+ if (miCurLangInx >= (int)mcLangList.size())
+ return false;
+
+ // update pointers
+ sLang = mcLangList[miCurLangInx].msName;
+ if (!sMsgStr.size())
+ sMsgStr = "NOT TRANSLATED";
+ else
+ sMsgStr = mcENUSlist[miCurENUSinx].mcLangText[miCurLangInx].msMsgStr;
+ return true;
}
@@ -335,8 +508,8 @@ bool l10nMem::getMergeLang(std::string& sL, std::string& sT)
void l10nMem::formatAndShowText(const std::string& sType, int iLineNo, const std::string& sText)
{
std::cout << sType;
- if (mcDb->miCurFileInx > 0)
- std::cout << " in " << mcDb->mcFileList[mcDb->miCurFileInx].msFileName;
+ if (miCurFileInx > 0)
+ std::cout << " in " << mcFileList[miCurFileInx].msFileName;
if (iLineNo)
std::cout << "(" << iLineNo << ")";
std::cout << ": " << sText << std::endl;
@@ -346,7 +519,7 @@ void l10nMem::formatAndShowText(const std::string& sType, int iLineNo, const std
bool l10nMem::needWrite(const std::string sFileName, bool bForce)
{
- int iE, iEsize = mcDb->mcENUSlist.size();
+ int iE, iEsize = mcENUSlist.size();
int iCntDeleted = 0, iCntChanged = 0, iCntAdded = 0;
// no save if there has been errors
@@ -355,18 +528,18 @@ bool l10nMem::needWrite(const std::string sFileName, bool bForce)
// Check number of changes
for (iE = 1; iE < iEsize; ++iE) {
- l10nMem_enus_entry& cur = mcDb->mcENUSlist[iE];
+ l10nMem_enus_entry& cur = mcENUSlist[iE];
if (cur.meState == ENTRY_ADDED)
++iCntAdded;
if (cur.meState == ENTRY_CHANGED) {
++iCntChanged;
- if (mcDb->mbStrictMode)
+ if (mbStrictMode)
cur.meState = ENTRY_NORMAL;
}
if (cur.meState == ENTRY_DELETED)
++iCntDeleted;
}
- if (!mcDb->mbConvertMode)
+ if (!mbConvertMode)
iCntDeleted -= iCntChanged;
if (!iCntAdded && !iCntChanged && !iCntDeleted) {
std::cout << "genLang: No changes in " << sFileName;
@@ -515,11 +688,11 @@ void l10nMem::convEntryKey(int iLineNo,
// Find all matching file names (old system does not have directory.
// build list of potential entries
- iSize = mcDb->mcFileList.size();
+ iSize = 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;
+ if (curFileName == mcFileList[curFileIndex].msPureName) {
+ int j = mcFileList[curFileIndex].miStart;
+ int iEnd = mcFileList[curFileIndex].miEnd;
for (; j <= iEnd; ++j)
ivEntryList.push_back(j);
@@ -534,10 +707,10 @@ void l10nMem::convEntryKey(int iLineNo,
// Loop through all potential en-US entries
for (curENUSindex = -1, i = 0; i < iSize; ++i) {
- l10nMem_enus_entry& curE = mcDb->mcENUSlist[ivEntryList[i]];
+ l10nMem_enus_entry& curE = mcENUSlist[ivEntryList[i]];
// The entry must be unconverted if strict mode (comparing .pot files)
- if (mcDb->mbStrictMode && curE.meState != ENTRY_DELETED)
+ if (mbStrictMode && curE.meState != ENTRY_DELETED)
continue;
// msgId must match
@@ -550,14 +723,14 @@ void l10nMem::convEntryKey(int iLineNo,
}
// do we need to do advanced find
- if (curENUSindex == -1 || mcDb->mbStrictMode) {
+ if (curENUSindex == -1 || mbStrictMode) {
// make copy of key in upper case
curKeyUpper = sKey;
- l10nMem_db::keyToUpper(curKeyUpper);
+ keyToUpper(curKeyUpper);
// Loop through all potential en-US entries
for (i = 0; i < iSize; ++i) {
- l10nMem_enus_entry& curE = mcDb->mcENUSlist[ivEntryList[i]];
+ l10nMem_enus_entry& curE = mcENUSlist[ivEntryList[i]];
// compare keys, but be aware of different length
if (curKeyUpper.find(curE.msKey) != std::string::npos) {
@@ -574,13 +747,237 @@ void l10nMem::convEntryKey(int iLineNo,
}
// update language text
- l10nMem_enus_entry& curE = mcDb->mcENUSlist[curENUSindex];
- l10nMem_lang_entry& curL = curE.mcLangText[mcDb->miCurLangInx];
+ l10nMem_enus_entry& curE = mcENUSlist[curENUSindex];
+ l10nMem_lang_entry& curL = curE.mcLangText[miCurLangInx];
if (sMsgStr != curL.msMsgStr) {
curL.msMsgStr = sMsgStr;
curL.mbFuzzy = bIsFuzzy;
curE.meState = ENTRY_CHANGED;
- mcDb->mcLangList[mcDb->miCurLangInx].mbChanged = true;
+ mcLangList[miCurLangInx].mbChanged = true;
+ }
+}
+
+
+
+void l10nMem::loadENUSkey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId)
+{
+ // add it to vector and update file pointer
+ addKey(iLineNo, sSourceFile, sKey, sMsgId, ENTRY_DELETED);
+}
+
+void l10nMem::loadLangKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
+ bool bFuzzy)
+{
+ 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.msMsgStr = sMsgStr;
+ xCur.mbFuzzy = bFuzzy;
+}
+
+
+
+void l10nMem::reorganize(bool bConvert)
+{
+ int iE, iEsize = mcENUSlist.size();
+ int iD, iDsize;
+ std::vector<int> listDel, listAdd;
+
+
+ // Check number of changes
+ for (iE = 1; iE < iEsize; ++iE)
+ {
+ l10nMem_enus_entry& cur = mcENUSlist[iE];
+ if (cur.meState == l10nMem::ENTRY_ADDED)
+ listAdd.push_back(iE);
+ if (cur.meState == l10nMem::ENTRY_DELETED)
+ {
+ if (bConvert)
+ cur.meState = l10nMem::ENTRY_NORMAL;
+ else
+ listDel.push_back(iE);
+ }
+ }
+
+ if (!listDel.size() || !listAdd.size())
+ return;
+
+ // loop through added text and see if key match deleted text
+ iEsize = listAdd.size();
+ iDsize = listDel.size();
+ for (iE = 0; iE < iEsize; ++iE)
+ {
+ l10nMem_enus_entry& curAdd = mcENUSlist[listAdd[iE]];
+ for (iD = 0; iD < iDsize; ++iD)
+ {
+ l10nMem_enus_entry& curE = mcENUSlist[listDel[iD]];
+
+ if (curE.miFileInx != curAdd.miFileInx)
+ continue;
+ if (curE.msKey == curAdd.msKey)
+ break;
+ if (curE.msMsgId == curAdd.msMsgId)
+ break;
+ }
+ if (iD == iDsize)
+ continue;
+
+ // Update deleted entry (original), because lang is connected here
+ l10nMem_enus_entry& curDel = mcENUSlist[listDel[iD]];
+ curDel.msMsgId = curAdd.msMsgId;
+ curDel.msKey = curAdd.msKey;
+ curDel.meState = l10nMem::ENTRY_CHANGED;
+ curAdd.meState = l10nMem::ENTRY_DELETED;
+ }
+}
+
+
+
+bool l10nMem::locateKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ bool bThrow)
+{
+ std::string sUpperKey(sKey);
+ int i, iSize = sUpperKey.size();
+ char ch;
+
+ // Position file pointer
+ if (!findFileName(sSourceFile))
+ return false;
+
+ // convert key to upper case
+ for (i = 0; i < iSize; ++i)
+ {
+ ch = sUpperKey[i];
+ if (ch == ' ' || ch == '*' || ch == '+' || ch == '%')
+ sUpperKey[i] = '_';
+ else
+ sUpperKey[i] = toupper(sUpperKey[i]);
+ }
+
+ // Fast check, to see if next key is the one (normal with load and source without change)
+ if (++miCurENUSinx < (int)mcENUSlist.size())
+ {
+ l10nMem_enus_entry& nowEntry = mcENUSlist[miCurENUSinx];
+ if (nowEntry.msMsgId == sMsgId && nowEntry.msKey == sUpperKey)
+ return true;
+ }
+
+ // Start from beginning of file and to end
+ l10nMem_file_entry& cCur = mcFileList[miCurFileInx];
+
+ // Find match with key and text
+ for (miCurENUSinx = cCur.miStart; miCurENUSinx <= cCur.miEnd; ++miCurENUSinx)
+ {
+ l10nMem_enus_entry& cEntry = mcENUSlist[miCurENUSinx];
+ if (cEntry.msMsgId == sMsgId && cEntry.msKey == sUpperKey)
+ return true;
}
+
+ if (bThrow)
+ throw l10nMem::showError("cannot find key(" + sUpperKey + ") with text(" + sMsgId + ")", iLineNo);
+ return false;
}
+
+
+
+void l10nMem::addKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ l10nMem::ENTRY_STATE eStat)
+{
+ // check file
+ if (!findFileName(sSourceFile))
+ {
+ // prepare for new entry
+ miCurENUSinx = mcENUSlist.size();
+ miCurFileInx = mcFileList.size();
+
+ // Create file
+ 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, sMsgId, iLineNo, miCurFileInx,
+ mcLangList.size(), eStat));
+ mcFileList[miCurFileInx].miEnd = miCurENUSinx;
+ }
+ else
+ {
+ int iFsize = mcFileList.size();
+ l10nMem_file_entry& curF = mcFileList[miCurFileInx];
+ std::vector<l10nMem_enus_entry>::iterator it = mcENUSlist.begin();
+
+ // file is registred, so we need to add the entry at the end of the file range
+ curF.miEnd++;
+ miCurENUSinx = curF.miEnd;
+ mcENUSlist.insert(it + curF.miEnd,
+ l10nMem_enus_entry(sKey, sMsgId, iLineNo, miCurFileInx,
+ mcLangList.size(), eStat));
+ for (int i = miCurFileInx + 1; i < iFsize; ++i)
+ {
+ l10nMem_file_entry& curF2 = mcFileList[i];
+ if (curF2.miStart >= curF.miEnd)
+ curF2.miStart++;
+ if (curF2.miEnd >= curF.miEnd)
+ curF2.miEnd++;
+ }
+ }
+}
+
+
+bool l10nMem::findFileName(const std::string& sSourceFile)
+{
+ int iSize = mcFileList.size();
+
+ // Check this or next file
+ if (mcFileList[miCurFileInx].msFileName == sSourceFile || mcFileList[miCurFileInx].msPureName == sSourceFile)
+ return true;
+ if (++miCurFileInx < iSize && mcFileList[miCurFileInx].msFileName == sSourceFile)
+ return true;
+
+ for (miCurFileInx = 1;
+ miCurFileInx < iSize && mcFileList[miCurFileInx].msFileName != sSourceFile &&
+ mcFileList[miCurFileInx].msPureName != sSourceFile;
+ ++miCurFileInx);
+ if (miCurFileInx == iSize)
+ {
+ miCurFileInx = 0;
+ return false;
+ }
+ else
+ return true;
+}
+
+
+
+
+void l10nMem::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);
+ }
+}
+
+
+
+
diff --git a/l10ntools/source/gL10nMemDB.cxx b/l10ntools/source/gL10nMemDB.cxx
deleted file mode 100644
index 5133424..0000000
--- a/l10ntools/source/gL10nMemDB.cxx
+++ /dev/null
@@ -1,453 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "gL10nMem.hxx"
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-l10nMem_lang_entry::l10nMem_lang_entry(const std::string& sMsgStr, bool bFuzzy)
- :
- msMsgStr(sMsgStr),
- mbFuzzy(bFuzzy)
-{
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-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& sMsgId,
- int iLineNo,
- int iFileInx,
- int iLangSize,
- l10nMem::ENTRY_STATE eState)
- :
- msMsgId(sMsgId),
- meState(eState),
- miFileInx(iFileInx),
- miLineNo(iLineNo)
-{
- int i;
-
- // add dummy language entries
- for (i = 0; i < iLangSize; ++i)
- mcLangText.push_back(l10nMem_lang_entry("", false));
-
- // convert key to upper case
- msKey = sKey;
- l10nMem_db::keyToUpper(msKey);
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-l10nMem_enus_entry::~l10nMem_enus_entry()
-{
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-l10nMem_file_entry::l10nMem_file_entry(const std::string& sFileName, int iStart)
- :
- msFileName(sFileName),
- miStart(iStart),
- miEnd(iStart)
-{
- // Store fileName without relative path
- int i = msFileName.rfind("/");
- if (i == (int)std::string::npos)
- msPureName = msFileName;
- else
- msPureName = msFileName.substr(i+1);
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-l10nMem_file_entry::~l10nMem_file_entry()
-{
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-l10nMem_lang_list_entry::l10nMem_lang_list_entry(const std::string& sName)
- :
- msName(sName),
- mbChanged(false)
-{
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-l10nMem_lang_list_entry::~l10nMem_lang_list_entry()
-{
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-l10nMem_db::l10nMem_db()
- :
- miCurFileInx(0),
- miCurLangInx(0),
- miCurENUSinx(0),
- mbNeedWrite(false),
- mbConvertMode(false),
- mbStrictMode(false)
-{
- mcFileList.push_back(l10nMem_file_entry("-genLang-", 0));
- mcLangList.push_back(l10nMem_lang_list_entry("-genLang-"));
- mcENUSlist.push_back(l10nMem_enus_entry("-genLang-", "-genLang-", 0, 0, 0, l10nMem::ENTRY_DELETED));
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-l10nMem_db::~l10nMem_db()
-{
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_db::loadENUSkey(int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sMsgId)
-{
- // add it to vector and update file pointer
- 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)
-{
- int i, iSize;
-
- // regular load or convert of old po files
- miCurFileInx = 0;
-
- // With no languages selected only en-US is generated
- if (!sLanguage.size())
- {
- miCurLangInx = 0;
- return;
- }
-
- // en-US is loaded as master and cannot be loaded again
- if (sLanguage == "en-US")
- throw l10nMem::showError("en-US is loaded automatically");
-
- // check if language is already loaded
- iSize = mcLangList.size();
- for (miCurLangInx = 0; miCurLangInx < iSize && mcLangList[miCurLangInx].msName != sLanguage; ++miCurLangInx) ;
- if (miCurLangInx < iSize)
- {
- if (bCreate)
- throw l10nMem::showError("loading " + sLanguage + " twice");
- return;
- }
-
- // language does not exist in db
- if (!bCreate)
- throw l10nMem::showError("language " + sLanguage + " not loaded");
-
- // create language
- mcLangList.push_back(sLanguage);
-
- // add language to all ENUS entries
- iSize = mcENUSlist.size();
- for (i = 0; i < iSize; ++i)
- mcENUSlist[i].mcLangText.push_back(l10nMem_lang_entry("", false));
-}
-
-
-
-/********************** 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();
-
- // Check this or next file
- if (mcFileList[miCurFileInx].msFileName == sSourceFile || mcFileList[miCurFileInx].msPureName == sSourceFile)
- return true;
- if (++miCurFileInx < iSize && mcFileList[miCurFileInx].msFileName == sSourceFile)
- return true;
-
- for (miCurFileInx = 1;
- miCurFileInx < iSize && mcFileList[miCurFileInx].msFileName != sSourceFile &&
- mcFileList[miCurFileInx].msPureName != sSourceFile;
- ++miCurFileInx) ;
- if (miCurFileInx == iSize)
- {
- miCurFileInx = 0;
- return false;
- }
- else
- return true;
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_db::loadLangKey(int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sMsgId,
- const std::string& sMsgStr,
- bool bFuzzy)
-{
- 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.msMsgStr = sMsgStr;
- xCur.mbFuzzy = bFuzzy;
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_db::reorganize(bool bConvert)
-{
- int iE, iEsize = mcENUSlist.size();
- int iD, iDsize;
- std::vector<int> listDel, listAdd;
-
-
- // Check number of changes
- for (iE = 1; iE < iEsize; ++iE)
- {
- l10nMem_enus_entry& cur = mcENUSlist[iE];
- if (cur.meState == l10nMem::ENTRY_ADDED)
- listAdd.push_back(iE);
- if (cur.meState == l10nMem::ENTRY_DELETED)
- {
- if (bConvert)
- cur.meState = l10nMem::ENTRY_NORMAL;
- else
- listDel.push_back(iE);
- }
- }
-
- if (!listDel.size() || !listAdd.size())
- return;
-
- // loop through added text and see if key match deleted text
- iEsize = listAdd.size();
- iDsize = listDel.size();
- for (iE = 0; iE < iEsize; ++iE)
- {
- l10nMem_enus_entry& curAdd = mcENUSlist[listAdd[iE]];
- for (iD = 0; iD < iDsize; ++iD)
- {
- l10nMem_enus_entry& curE = mcENUSlist[listDel[iD]];
-
- if (curE.miFileInx != curAdd.miFileInx)
- continue;
- if (curE.msKey == curAdd.msKey)
- break;
- if (curE.msMsgId == curAdd.msMsgId)
- break;
- }
- if (iD == iDsize)
- continue;
-
- // Update deleted entry (original), because lang is connected here
- l10nMem_enus_entry& curDel = mcENUSlist[listDel[iD]];
- curDel.msMsgId = curAdd.msMsgId;
- curDel.msKey = curAdd.msKey;
- curDel.meState = l10nMem::ENTRY_CHANGED;
- curAdd.meState = l10nMem::ENTRY_DELETED;
- }
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-bool l10nMem_db::locateKey(int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sMsgId,
- bool bThrow)
-{
- std::string sUpperKey(sKey);
- int i, iSize = sUpperKey.size();
- char ch;
-
- // Position file pointer
- if (!findFileName(sSourceFile))
- return false;
-
- // convert key to upper case
- for (i = 0; i < iSize; ++i)
- {
- ch = sUpperKey[i];
- if (ch == ' ' || ch == '*' || ch == '+' || ch == '%')
- sUpperKey[i] = '_';
- else
- sUpperKey[i] = toupper(sUpperKey[i]);
- }
-
- // Fast check, to see if next key is the one (normal with load and source without change)
- if (++miCurENUSinx < (int)mcENUSlist.size())
- {
- l10nMem_enus_entry& nowEntry = mcENUSlist[miCurENUSinx];
- if (nowEntry.msMsgId == sMsgId && nowEntry.msKey == sUpperKey)
- return true;
- }
-
- // Start from beginning of file and to end
- l10nMem_file_entry& cCur = mcFileList[miCurFileInx];
-
- // Find match with key and text
- for (miCurENUSinx = cCur.miStart; miCurENUSinx <= cCur.miEnd; ++miCurENUSinx)
- {
- l10nMem_enus_entry& cEntry = mcENUSlist[miCurENUSinx];
- if (cEntry.msMsgId == sMsgId && cEntry.msKey == sUpperKey)
- return true;
- }
-
- if (bThrow)
- throw l10nMem::showError("cannot find key(" + sUpperKey +") with text(" + sMsgId + ")", iLineNo);
- return false;
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-void l10nMem_db::addKey(int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sMsgId,
- l10nMem::ENTRY_STATE eStat)
-{
- // check file
- if (!findFileName(sSourceFile))
- {
- // prepare for new entry
- miCurENUSinx = mcENUSlist.size();
- miCurFileInx = mcFileList.size();
-
- // Create file
- 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, sMsgId, iLineNo, miCurFileInx,
- mcLangList.size(), eStat));
- mcFileList[miCurFileInx].miEnd = miCurENUSinx;
- }
- else
- {
- int iFsize = mcFileList.size();
- l10nMem_file_entry& curF = mcFileList[miCurFileInx];
- std::vector<l10nMem_enus_entry>::iterator it = mcENUSlist.begin();
-
- // file is registred, so we need to add the entry at the end of the file range
- curF.miEnd++;
- miCurENUSinx = curF.miEnd;
- mcENUSlist.insert(it + curF.miEnd,
- l10nMem_enus_entry(sKey, sMsgId, iLineNo, miCurFileInx,
- mcLangList.size(), eStat));
- for (int i = miCurFileInx+1; i < iFsize; ++i)
- {
- l10nMem_file_entry& curF2 = mcFileList[i];
- if (curF2.miStart >= curF.miEnd)
- curF2.miStart++;
- if (curF2.miEnd >= curF.miEnd)
- curF2.miEnd++;
- }
- }
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-int l10nMem_db::prepareMerge()
-{
- miCurLangInx = 0;
- return mcLangList.size();
-}
-
-
-
-/********************** I M P L E M E N T A T I O N **********************/
-bool l10nMem_db::getMergeLang(std::string& sLang,
- std::string& sMsgStr)
-{
- miCurLangInx++;
- if (miCurLangInx >= (int)mcLangList.size())
- return false;
-
- // update pointers
- sLang = mcLangList[miCurLangInx].msName;
- if (!sMsgStr.size())
- sMsgStr = "NOT TRANSLATED";
- else
- 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);
- }
-}
diff --git a/l10ntools/source/gLang.cxx b/l10ntools/source/gLang.cxx
index da07828..757e9eb 100644
--- a/l10ntools/source/gLang.cxx
+++ b/l10ntools/source/gLang.cxx
@@ -16,8 +16,12 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "gLang.hxx"
#include <iostream>
+#include <string>
+#include <vector>
+
+#include "gL10nMem.hxx"
+#include "gConv.hxx"
@@ -34,7 +38,6 @@ class handler
private:
bool mbForceSave;
- bool mbSave;
enum {DO_CONVERT, DO_EXTRACT, DO_MERGE_KID, DO_MERGE} meWorkMode;
std::string msTargetDir;
std::string msPoDir;
@@ -170,7 +173,7 @@ void handler::checkCommandLine(int argc, char *argv[])
// Set default
- mbForceSave = mbSave = false;
+ mbForceSave = false;
// check for fixed parameter: genLang <cmd>
if (argc < 2)
@@ -189,7 +192,7 @@ void handler::checkCommandLine(int argc, char *argv[])
sWorkText = argv[i];
if (sWorkText == "-d") {
// show debug information
- mcMemory.mbDebug = true;
+ mcMemory.setDebug(true);
}
else if (sWorkText == "-k") {
// generate key identifier version
@@ -199,11 +202,11 @@ void handler::checkCommandLine(int argc, char *argv[])
}
else if (sWorkText == "-v") {
// show progress information
- mcMemory.mbVerbose = true;
+ mcMemory.setVerbose(true);
}
else if (sWorkText == "-s") {
// forced save
- mbSave = true;
+ mbForceSave = true;
}
else if (sWorkText == "--files") {
// list of input files
@@ -323,7 +326,7 @@ void handler::loadL10MEM(bool onlyTemplates)
// load texts from en-US po file (master)
// tell system
- mcMemory.showDebug("genLang loading master text from file " + sLoad);
+ l10nMem::showDebug("genLang loading master text from file " + sLoad);
// and load file
mcMemory.setLanguage("", true);
@@ -341,7 +344,7 @@ void handler::loadL10MEM(bool onlyTemplates)
mcMemory.setLanguage(*siLang, true);
// tell system
- mcMemory.showDebug("genLang loading text from language file " + sLoad);
+ l10nMem::showDebug("genLang loading text from language file " + sLoad);
convert_gen(mcMemory, sLoad, msTargetDir, "").execute(false, false);
}
@@ -362,7 +365,7 @@ void handler::runConvert()
for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource)
{
// tell system
- mcMemory.showDebug("genLang compare template " + *siSource);
+ l10nMem::showDebug("genLang compare template " + *siSource);
// get converter and extract files
convert_gen convertObj(mcMemory, "./", msTargetDir, *siSource);
@@ -378,7 +381,7 @@ void handler::runConvert()
mcMemory.setLanguage(*siLang, false);
// tell system
- mcMemory.showDebug("genLang convert text from file " +
+ l10nMem::showDebug("genLang convert text from file " +
sFilePath + *siSource + " language " + *siLang);
// get converter and extract files
@@ -405,7 +408,7 @@ void handler::runExtract()
for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource)
{
// tell system
- mcMemory.showDebug("genLang extracting text from file " + *siSource);
+ l10nMem::showDebug("genLang extracting text from file " + *siSource);
// get converter and extract file
convert_gen convertObj(mcMemory, "", msTargetDir, *siSource);
@@ -429,7 +432,7 @@ void handler::runMerge(bool bKid)
for (siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource)
{
// tell system
- mcMemory.showDebug("genLang merging translated text to file " + *siSource);
+ l10nMem::showDebug("genLang merging translated text to file " + *siSource);
// get converter and extract file
convert_gen convertObj(mcMemory, "", msTargetDir, *siSource);
diff --git a/l10ntools/source/gLexPo.l b/l10ntools/source/gLexPo.l
index bc4507c..3d6bfc3 100644
--- a/l10ntools/source/gLexPo.l
+++ b/l10ntools/source/gLexPo.l
@@ -35,6 +35,10 @@
/*************** O V E R W R I T I N G F U N C T I O N S ***************/
%top{
+#include <string>
+#include <vector>
+
+#include "gL10nMem.hxx"
#include "gConvPo.hxx"
#define IMPLptr convert_gen_impl::mcImpl
diff --git a/l10ntools/source/gLexSrc.l b/l10ntools/source/gLexSrc.l
index 3d5b000..d298d0f 100644
--- a/l10ntools/source/gLexSrc.l
+++ b/l10ntools/source/gLexSrc.l
@@ -20,6 +20,10 @@
/*************** O V E R W R I T I N G F U N C T I O N S ***************/
%top{
+#include <string>
+#include <vector>
+
+#include "gL10nMem.hxx"
#include "gConvSrc.hxx"
#define IMPLptr convert_gen_impl::mcImpl
diff --git a/l10ntools/source/gLexTree.l b/l10ntools/source/gLexTree.l
index c9f25f5..4b8aa2c9 100644
--- a/l10ntools/source/gLexTree.l
+++ b/l10ntools/source/gLexTree.l
@@ -20,6 +20,10 @@
/*************** O V E R W R I T I N G F U N C T I O N S ***************/
%top{
+#include <string>
+#include <vector>
+
+#include "gL10nMem.hxx"
#include "gConvTree.hxx"
#define IMPLptr convert_gen_impl::mcImpl
diff --git a/l10ntools/source/gLexUlf.l b/l10ntools/source/gLexUlf.l
index ccac793..bb204f2 100644
--- a/l10ntools/source/gLexUlf.l
+++ b/l10ntools/source/gLexUlf.l
@@ -20,6 +20,10 @@
/*************** O V E R W R I T I N G F U N C T I O N S ***************/
%top{
+#include <string>
+#include <vector>
+
+#include "gL10nMem.hxx"
#include "gConvUlf.hxx"
#define IMPLptr convert_gen_impl::mcImpl
diff --git a/l10ntools/source/gLexXcs.l b/l10ntools/source/gLexXcs.l
index d099f9f..cfd11da 100644
--- a/l10ntools/source/gLexXcs.l
+++ b/l10ntools/source/gLexXcs.l
@@ -20,6 +20,10 @@
/*************** O V E R W R I T I N G F U N C T I O N S ***************/
%top{
+#include <string>
+#include <vector>
+
+#include "gL10nMem.hxx"
#include "gConvXcs.hxx"
#define IMPLptr convert_gen_impl::mcImpl
diff --git a/l10ntools/source/gLexXcu.l b/l10ntools/source/gLexXcu.l
index 3d956aa..b3095ef 100644
--- a/l10ntools/source/gLexXcu.l
+++ b/l10ntools/source/gLexXcu.l
@@ -20,6 +20,10 @@
/*************** O V E R W R I T I N G F U N C T I O N S ***************/
%top{
+#include <string>
+#include <vector>
+
+#include "gL10nMem.hxx"
#include "gConvXcu.hxx"
#define IMPLptr convert_gen_impl::mcImpl
diff --git a/l10ntools/source/gLexXhp.l b/l10ntools/source/gLexXhp.l
index f99e93f..a2c23fd 100644
--- a/l10ntools/source/gLexXhp.l
+++ b/l10ntools/source/gLexXhp.l
@@ -20,6 +20,10 @@
/*************** O V E R W R I T I N G F U N C T I O N S ***************/
%top{
+#include <string>
+#include <vector>
+
+#include "gL10nMem.hxx"
#include "gConvXhp.hxx"
#define IMPLptr convert_gen_impl::mcImpl
diff --git a/l10ntools/source/gLexXrm.l b/l10ntools/source/gLexXrm.l
index 292a666..aadab8e 100644
--- a/l10ntools/source/gLexXrm.l
+++ b/l10ntools/source/gLexXrm.l
@@ -20,6 +20,10 @@
/*************** O V E R W R I T I N G F U N C T I O N S ***************/
%top{
+#include <string>
+#include <vector>
+
+#include "gL10nMem.hxx"
#include "gConvXrm.hxx"
#define IMPLptr convert_gen_impl::mcImpl
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index 7789e3b..3922e89 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -121,22 +121,13 @@ bool MergeEntrys::GetText( OString &rReturn,
return bReturn;
}
-namespace
-{
- OString GetDoubleBars()
- {
- //DOUBLE VERTICAL LINE instead of || because the translations make their
- //way into action_names under gtk3 where || is illegal
- return OUStringToOString(OUString(static_cast<sal_Unicode>(0x2016)), RTL_TEXTENCODING_UTF8);
- }
-}
OString MergeEntrys::GetQTZText(const ResData& rResData, const OString& rOrigText)
{
const OString sFilename = rResData.sFilename.copy(rResData.sFilename.lastIndexOf('/')+1);
const OString sKey =
PoEntry::genKeyId(sFilename + rResData.sGId + rResData.sId + rResData.sResTyp + rOrigText);
- return sKey + GetDoubleBars() + rOrigText;
+ return sKey + "||" + rOrigText;
}
@@ -420,9 +411,9 @@ void MergeDataFile::InsertEntry(
const OString sTemp = rInFilename + rGID + rLID + rTYP;
pMergeEntrys->InsertEntry(
nLANG,
- rTEXT.isEmpty()? rTEXT : PoEntry::genKeyId(sTemp + rTEXT) + GetDoubleBars() + rTEXT,
- rQHTEXT.isEmpty()? rQHTEXT : PoEntry::genKeyId(sTemp + rQHTEXT) + GetDoubleBars() + rQHTEXT,
- rTITLE.isEmpty()? rTITLE : PoEntry::genKeyId(sTemp + rTITLE) + GetDoubleBars() + rTITLE );
+ rTEXT.isEmpty()? rTEXT : PoEntry::genKeyId(sTemp + rTEXT) + "||" + rTEXT,
+ rQHTEXT.isEmpty()? rQHTEXT : PoEntry::genKeyId(sTemp + rQHTEXT) + "||" + rQHTEXT,
+ rTITLE.isEmpty()? rTITLE : PoEntry::genKeyId(sTemp + rTITLE) + "||" + rTITLE );
}
else
{
More information about the Libreoffice-commits
mailing list