Kaydet (Commit) 40a218ba authored tarafından jan iversen's avatar jan iversen

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
üst f7f97dad
......@@ -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
......@@ -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
......@@ -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;
}
}
......
......@@ -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
}
......
......@@ -346,7 +346,7 @@ void handler::runExtract()
}
// and generate language file
mcMemory.saveTemplates(msPoDir, false, mbForceSave);
mcMemory.saveTemplates(msTargetDir, false, mbForceSave);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment