summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorjan iversen <jani@documentfoundation.org>2016-03-19 20:04:54 +0100
committerjan iversen <jani@documentfoundation.org>2016-03-22 16:32:19 +0100
commit40a218baf8823d883c8d9d2839ff95780e7ff0ed (patch)
tree79066f1712aca611daedef46af3a5bcd7e42a158 /l10ntools
parentf7f97dadcd33ed191ef04436fe630821c2330e3d (diff)
genlang, moved save function to convPO from convGen.
.pot files can only be generated in convPO, therefore it is logical to have the functions at this level. Added a fix due to LO standard for saving .pot files (this fix might need to be updated, when moving on from .xrm) Ready to save .xrm input as .pot, and compare results. Change-Id: I1849e896258942f7895e5f6bd3b834391e7a7e95
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/inc/gConv.hxx17
-rw-r--r--l10ntools/inc/gConvPo.hxx19
-rw-r--r--l10ntools/source/gConv.cxx41
-rw-r--r--l10ntools/source/gL10nMem.cxx16
-rw-r--r--l10ntools/source/gLang.cxx2
5 files changed, 27 insertions, 68 deletions
diff --git a/l10ntools/inc/gConv.hxx b/l10ntools/inc/gConv.hxx
index 710d0ff848cf..cda748346308 100644
--- a/l10ntools/inc/gConv.hxx
+++ b/l10ntools/inc/gConv.hxx
@@ -41,18 +41,6 @@ class convert_gen
// 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();
- static bool checkAccess(std::string& sFile);
- static bool createDir(std::string& sDir, std::string& sFile);
-
// utility functions for converters
void lexRead(char *sBuf, int *nResult, int nMax_size);
std::string& copySource(char const *yyText, bool bDoClear = true);
@@ -74,8 +62,9 @@ class convert_gen
// utility functions for converters
void writeSourceFile(const std::string& line);
-
- private:
+ static bool checkAccess(std::string& sFile);
+ static bool createDir(std::string& sDir, std::string& sFile);
+private:
std::ofstream mcOutputFile;
};
#endif
diff --git a/l10ntools/inc/gConvPo.hxx b/l10ntools/inc/gConvPo.hxx
index ab120d916b66..7ca45bff93a2 100644
--- a/l10ntools/inc/gConvPo.hxx
+++ b/l10ntools/inc/gConvPo.hxx
@@ -41,6 +41,16 @@ class convert_po : public convert_gen
void setMsgStr ();
void handleNL ();
+ // Used to save .pot files
+ 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();
+
private:
std::string msId;
std::string msStr;
@@ -49,14 +59,5 @@ class convert_po : public convert_gen
std::filebuf outBuffer;
void execute() override;
-
- void startSave(const std::string& sLanguage,
- const std::string& sFile) override;
- void save(const std::string& sFileName,
- const std::string& sKey,
- const std::string& sENUStext,
- const std::string& sText,
- bool bFuzzy) override;
- void endSave() override;
};
#endif
diff --git a/l10ntools/source/gConv.cxx b/l10ntools/source/gConv.cxx
index f90a8b6f387c..d2446230497e 100644
--- a/l10ntools/source/gConv.cxx
+++ b/l10ntools/source/gConv.cxx
@@ -112,40 +112,6 @@ bool convert_gen::execute(const bool bMerge, const bool bKid)
-void convert_gen::startSave(const std::string& sLanguage,
- const std::string& sFile)
-{
- std::string x;
-
- x = sLanguage;
- x = sFile;
- throw l10nMem::showError("startSave called with non .po file");
-}
-
-
-
-void convert_gen::save(const std::string& sFileName,
- const std::string& sKey,
- const std::string& sENUStext,
- const std::string& sText,
- bool bFuzzy)
-{
- std::string x;
-
- if (bFuzzy)
- x = sFileName + sKey + sENUStext + sText;
- throw l10nMem::showError("save called with non .po file");
-}
-
-
-
-void convert_gen::endSave()
-{
- throw l10nMem::showError("endSave called with non .po file");
-}
-
-
-
bool convert_gen::checkAccess(std::string& sFile)
{
return (OS_ACCESS(sFile.c_str(), 0) == 0);
@@ -236,13 +202,14 @@ void convert_gen::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);
- *nResult = nMax_size;
+ msSourceBuffer.copy(sBuf, nMax_size, miSourceReadIndex);
+ l10nMem::showDebug(sBuf);
+ *nResult = nMax_size;
miSourceReadIndex += nMax_size;
}
}
diff --git a/l10ntools/source/gL10nMem.cxx b/l10ntools/source/gL10nMem.cxx
index 0d8277baaf1f..ef7774fb918f 100644
--- a/l10ntools/source/gL10nMem.cxx
+++ b/l10ntools/source/gL10nMem.cxx
@@ -23,6 +23,7 @@
#include <sstream>
#include "gL10nMem.hxx"
+#include "gConvPO.hxx"
l10nMem *myMem;
@@ -134,6 +135,7 @@ l10nMem::l10nMem()
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));
+ msModuleName = "default";
}
@@ -323,13 +325,15 @@ void l10nMem::setSourceKey(int iLineNo,
void l10nMem::saveTemplates(const std::string& sTargetDir, bool bKid, bool bForce)
{
- // int iEsize = mcENUSlist.size();
- std::string sFileName = msModuleName + ".pot";
+ int iE, iEsize = mcENUSlist.size();
+ // std::string sFileName = msModuleName + ".pot";
+
+ // Fix for new LO standard, at least valid for xrm
+ std::string sFileName = sTargetDir;
// Dummy to satisfy compiler
if (bKid)
- return;
- showError(sTargetDir);
+ throw "-k not implemented";
// and reorganize db if needed
miCurFileInx = 0;
@@ -342,8 +346,7 @@ void l10nMem::saveTemplates(const std::string& sTargetDir, bool bKid, bool bForc
//JIX save HANDLE KID
// Save en-US
-#if 0
- convert_gen savePo(cMem, sTargetDir, sTargetDir, sFileName);
+ convert_po savePo(*this);
savePo.startSave("templates/", sFileName);
for (iE = 1; iE < iEsize; ++iE) {
@@ -356,7 +359,6 @@ void l10nMem::saveTemplates(const std::string& sTargetDir, bool bKid, bool bForc
savePo.save(mcFileList[cE.miFileInx].msFileName, cE.msKey, cE.msMsgId, "", false);
}
savePo.endSave();
-#endif
}
diff --git a/l10ntools/source/gLang.cxx b/l10ntools/source/gLang.cxx
index 264874f239e9..1c09507fa9b1 100644
--- a/l10ntools/source/gLang.cxx
+++ b/l10ntools/source/gLang.cxx
@@ -346,7 +346,7 @@ void handler::runExtract()
}
// and generate language file
- mcMemory.saveTemplates(msPoDir, false, mbForceSave);
+ mcMemory.saveTemplates(msTargetDir, false, mbForceSave);
}