mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-27 01:26:30 +00:00
Merge with develop
--HG-- branch : compatibility-develop
This commit is contained in:
commit
7e2bbe1f37
9 changed files with 244 additions and 226 deletions
|
@ -144,12 +144,10 @@ public:
|
||||||
* 16 bits encoding can be recognized by the official header :
|
* 16 bits encoding can be recognized by the official header :
|
||||||
* FF, FE, witch can be reversed if the data are MSB first.
|
* FF, FE, witch can be reversed if the data are MSB first.
|
||||||
*
|
*
|
||||||
* Optionally, you can force the reader to consider the file as
|
|
||||||
* UTF-8 encoded.
|
|
||||||
* Optionally, you can ask the reader to interpret #include commands.
|
* Optionally, you can ask the reader to interpret #include commands.
|
||||||
*/
|
*/
|
||||||
static void readTextFile(const std::string &filename,
|
static void readTextFile(const std::string &filename,
|
||||||
ucstring &result, bool forceUtf8 = false,
|
ucstring &result,
|
||||||
bool fileLookup = true,
|
bool fileLookup = true,
|
||||||
bool preprocess = false,
|
bool preprocess = false,
|
||||||
TLineFormat lineFmt = LINE_FMT_NO_CARE,
|
TLineFormat lineFmt = LINE_FMT_NO_CARE,
|
||||||
|
@ -259,7 +257,7 @@ private:
|
||||||
|
|
||||||
/// The internal read function, it does the real job of readTextFile
|
/// The internal read function, it does the real job of readTextFile
|
||||||
static void _readTextFile(const std::string &filename,
|
static void _readTextFile(const std::string &filename,
|
||||||
ucstring &result, bool forceUtf8,
|
ucstring &result,
|
||||||
bool fileLookup,
|
bool fileLookup,
|
||||||
bool preprocess,
|
bool preprocess,
|
||||||
TLineFormat lineFmt,
|
TLineFormat lineFmt,
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "nel/misc/app_context.h"
|
#include "nel/misc/app_context.h"
|
||||||
#include "nel/misc/dynloadlib.h"
|
#include "nel/misc/dynloadlib.h"
|
||||||
#include "nel/misc/command.h"
|
#include "nel/misc/command.h"
|
||||||
#include "nel/misc/system_utils.h"
|
|
||||||
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
|
|
|
@ -412,7 +412,7 @@ void CConfigFile::reparse (bool lookupPaths)
|
||||||
if (!CPath::lookup(fn, false).empty())
|
if (!CPath::lookup(fn, false).empty())
|
||||||
{
|
{
|
||||||
ucstring content;
|
ucstring content;
|
||||||
CI18N::readTextFile(fn, content, true, true, true);
|
CI18N::readTextFile(fn, content, true, true);
|
||||||
string utf8 = content.toUtf8();
|
string utf8 = content.toUtf8();
|
||||||
|
|
||||||
CMemStream stream;
|
CMemStream stream;
|
||||||
|
|
|
@ -117,7 +117,7 @@ bool loadStringFile(const std::string filename, vector<TStringInfo> &stringInfos
|
||||||
*/
|
*/
|
||||||
ucstring text;
|
ucstring text;
|
||||||
|
|
||||||
CI18N::readTextFile(filename, text, false, false, true, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, text, false, true, CI18N::LINE_FMT_LF);
|
||||||
// CI18N::readTextBuffer(buffer, size, text);
|
// CI18N::readTextBuffer(buffer, size, text);
|
||||||
// delete [] buffer;
|
// delete [] buffer;
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ bool readPhraseFile(const std::string &filename, vector<TPhrase> &phrases, bool
|
||||||
{
|
{
|
||||||
ucstring doc;
|
ucstring doc;
|
||||||
|
|
||||||
CI18N::readTextFile(filename, doc, false, false, true, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, doc, false, true, CI18N::LINE_FMT_LF);
|
||||||
|
|
||||||
return readPhraseFileFromString(doc, filename, phrases, forceRehash);
|
return readPhraseFileFromString(doc, filename, phrases, forceRehash);
|
||||||
}
|
}
|
||||||
|
@ -416,9 +416,14 @@ bool readPhraseFileFromString(ucstring const& doc, const std::string &filename,
|
||||||
phrase.Clauses.size()+1);
|
phrase.Clauses.size()+1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only prepend a space if required
|
||||||
|
if (!clause.Conditions.empty()) clause.Conditions += " ";
|
||||||
|
|
||||||
clause.Conditions += "(" + cond + ")";
|
clause.Conditions += "(" + cond + ")";
|
||||||
CI18N::skipWhiteSpace(first, last, &clause.Comments);
|
CI18N::skipWhiteSpace(first, last, &clause.Comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first == last)
|
if (first == last)
|
||||||
{
|
{
|
||||||
nlwarning("DT: in '%s': Found end of file in non closed block for phrase %s\n",
|
nlwarning("DT: in '%s': Found end of file in non closed block for phrase %s\n",
|
||||||
|
@ -626,7 +631,7 @@ bool loadExcelSheet(const string filename, TWorksheet &worksheet, bool checkUniq
|
||||||
fp.close();
|
fp.close();
|
||||||
|
|
||||||
ucstring str;
|
ucstring str;
|
||||||
CI18N::readTextFile(filename, str, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, str, false, false, CI18N::LINE_FMT_LF);
|
||||||
|
|
||||||
if (!readExcelSheet(str, worksheet, checkUnique))
|
if (!readExcelSheet(str, worksheet, checkUnique))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -502,25 +502,39 @@ void CI18N::skipWhiteSpace(ucstring::const_iterator &it, ucstring::const_iterato
|
||||||
if (storeComments && *it == '/' && it+1 != last && *(it+1) == '/')
|
if (storeComments && *it == '/' && it+1 != last && *(it+1) == '/')
|
||||||
{
|
{
|
||||||
// found a one line C comment. Store it until end of line.
|
// found a one line C comment. Store it until end of line.
|
||||||
while (it != last && *it != '\n')
|
while (it != last && (*it != '\n' && *it != '\r'))
|
||||||
storeComments->push_back(*it++);
|
storeComments->push_back(*it++);
|
||||||
|
|
||||||
// store the final '\n'
|
// store the final '\n'
|
||||||
if (it != last)
|
if (it != last)
|
||||||
storeComments->push_back(*it++);
|
storeComments->push_back('\n');
|
||||||
}
|
}
|
||||||
else if (storeComments && *it == '/' && it+1 != last && *(it+1) == '*')
|
else if (storeComments && *it == '/' && it+1 != last && *(it+1) == '*')
|
||||||
{
|
{
|
||||||
// found a multi line C++ comment. store until we found the closing '*/'
|
// found a multi line C++ comment. store until we found the closing '*/'
|
||||||
while (it != last && !(*it == '*' && it + 1 != last && *(it + 1) == '/'))
|
while (it != last && !(*it == '*' && it + 1 != last && *(it + 1) == '/'))
|
||||||
|
{
|
||||||
|
// don't put \r
|
||||||
|
if (*it == '\r')
|
||||||
|
{
|
||||||
|
// skip it
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
storeComments->push_back(*it++);
|
storeComments->push_back(*it++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// store the final '*'
|
// store the final '*'
|
||||||
if (it != last)
|
if (it != last)
|
||||||
storeComments->push_back(*it++);
|
storeComments->push_back(*it++);
|
||||||
|
|
||||||
// store the final '/'
|
// store the final '/'
|
||||||
if (it != last)
|
if (it != last)
|
||||||
storeComments->push_back(*it++);
|
storeComments->push_back(*it++);
|
||||||
|
|
||||||
// and a new line.
|
// and a new line.
|
||||||
storeComments->push_back('\r');
|
|
||||||
storeComments->push_back('\n');
|
storeComments->push_back('\n');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -656,7 +670,6 @@ bool CI18N::parseMarkedString(ucchar openMark, ucchar closeMark, ucstring::const
|
||||||
|
|
||||||
void CI18N::readTextFile(const string &filename,
|
void CI18N::readTextFile(const string &filename,
|
||||||
ucstring &result,
|
ucstring &result,
|
||||||
bool forceUtf8,
|
|
||||||
bool fileLookup,
|
bool fileLookup,
|
||||||
bool preprocess,
|
bool preprocess,
|
||||||
TLineFormat lineFmt,
|
TLineFormat lineFmt,
|
||||||
|
@ -666,7 +679,7 @@ void CI18N::readTextFile(const string &filename,
|
||||||
TReadContext readContext;
|
TReadContext readContext;
|
||||||
|
|
||||||
// call the inner function
|
// call the inner function
|
||||||
_readTextFile(filename, result, forceUtf8, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext);
|
_readTextFile(filename, result, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext);
|
||||||
|
|
||||||
if (!readContext.IfStack.empty())
|
if (!readContext.IfStack.empty())
|
||||||
{
|
{
|
||||||
|
@ -709,7 +722,6 @@ void CI18N::skipLine(ucstring::const_iterator &it, ucstring::const_iterator end,
|
||||||
|
|
||||||
void CI18N::_readTextFile(const string &filename,
|
void CI18N::_readTextFile(const string &filename,
|
||||||
ucstring &result,
|
ucstring &result,
|
||||||
bool forceUtf8,
|
|
||||||
bool fileLookup,
|
bool fileLookup,
|
||||||
bool preprocess,
|
bool preprocess,
|
||||||
TLineFormat lineFmt,
|
TLineFormat lineFmt,
|
||||||
|
@ -819,7 +831,7 @@ void CI18N::_readTextFile(const string &filename,
|
||||||
subFilename.c_str());
|
subFilename.c_str());
|
||||||
|
|
||||||
ucstring inserted;
|
ucstring inserted;
|
||||||
_readTextFile(subFilename, inserted, forceUtf8, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext);
|
_readTextFile(subFilename, inserted, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext);
|
||||||
final += inserted;
|
final += inserted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -873,7 +885,7 @@ void CI18N::_readTextFile(const string &filename,
|
||||||
subFilename.c_str());
|
subFilename.c_str());
|
||||||
|
|
||||||
ucstring inserted;
|
ucstring inserted;
|
||||||
_readTextFile(subFilename, inserted, forceUtf8, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext);
|
_readTextFile(subFilename, inserted, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext);
|
||||||
final += inserted;
|
final += inserted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,7 +550,7 @@ void executeScriptBuf(const string &text)
|
||||||
void executeScriptFile(const string &filename)
|
void executeScriptFile(const string &filename)
|
||||||
{
|
{
|
||||||
ucstring temp;
|
ucstring temp;
|
||||||
CI18N::readTextFile(filename, temp, false, false, false);
|
CI18N::readTextFile(filename, temp, false, false);
|
||||||
|
|
||||||
if (temp.empty())
|
if (temp.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,6 +98,10 @@ int main(int argc, char *argv[])
|
||||||
QApplication::setApplicationVersion(RYZOM_VERSION);
|
QApplication::setApplicationVersion(RYZOM_VERSION);
|
||||||
QApplication::setWindowIcon(QIcon(":/icons/ryzom.ico"));
|
QApplication::setWindowIcon(QIcon(":/icons/ryzom.ico"));
|
||||||
|
|
||||||
|
// remove first argument because it's not really an argument
|
||||||
|
QStringList args = QApplication::arguments();
|
||||||
|
args.removeFirst();
|
||||||
|
|
||||||
QLocale locale = QLocale::system();
|
QLocale locale = QLocale::system();
|
||||||
|
|
||||||
// load application translations
|
// load application translations
|
||||||
|
@ -199,7 +203,7 @@ int main(int argc, char *argv[])
|
||||||
nlinfo("Launching %s", Q2C(tempFile));
|
nlinfo("Launching %s", Q2C(tempFile));
|
||||||
|
|
||||||
// launch copy in TEMP directory with same arguments
|
// launch copy in TEMP directory with same arguments
|
||||||
if (QProcess::startDetached(tempFile, QApplication::arguments())) return 0;
|
if (QProcess::startDetached(tempFile, args, tempPath)) return 0;
|
||||||
|
|
||||||
nlwarning("Unable to launch %s", Q2C(tempFile));
|
nlwarning("Unable to launch %s", Q2C(tempFile));
|
||||||
}
|
}
|
||||||
|
@ -309,7 +313,7 @@ int main(int argc, char *argv[])
|
||||||
QFile::setPermissions(config.getInstallerInstalledFilePath(), QFile::permissions(config.getInstallerInstalledFilePath()) | QFile::ExeGroup | QFile::ExeUser | QFile::ExeOther);
|
QFile::setPermissions(config.getInstallerInstalledFilePath(), QFile::permissions(config.getInstallerInstalledFilePath()) | QFile::ExeGroup | QFile::ExeUser | QFile::ExeOther);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (QProcess::startDetached(config.getInstallerInstalledFilePath())) return 0;
|
if (QProcess::startDetached(config.getInstallerInstalledFilePath(), args, config.getInstallationDirectory())) return 0;
|
||||||
|
|
||||||
nlwarning("Unable to restart Installer %s", Q2C(config.getInstallerInstalledFilePath()));
|
nlwarning("Unable to restart Installer %s", Q2C(config.getInstallerInstalledFilePath()));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -74,7 +74,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
ucstring str;
|
ucstring str;
|
||||||
CI18N::readTextFile(inputFile, str, false, false, false);
|
CI18N::readTextFile(inputFile, str, false, false);
|
||||||
|
|
||||||
if (outMode == ASCII)
|
if (outMode == ASCII)
|
||||||
{
|
{
|
||||||
|
|
|
@ -151,13 +151,11 @@ void showUsage(char *exeName)
|
||||||
LOG("Reference language is always the first language in languages.txt\n");
|
LOG("Reference language is always the first language in languages.txt\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void verifyVersion(ucstring& doc, int versionId)
|
void verifyVersion(ucstring& doc, int versionId)
|
||||||
{
|
{
|
||||||
ucstring version1("// DIFF_VERSION 1\r\n");
|
ucstring version1("// DIFF_VERSION 1\n");
|
||||||
ucstring::size_type version1Size = version1.size();
|
ucstring::size_type version1Size = version1.size();
|
||||||
ucstring version2("// DIFF_VERSION 2\r\n");
|
ucstring version2("// DIFF_VERSION 2\n");
|
||||||
ucstring::size_type version2Size = version2.size();
|
ucstring::size_type version2Size = version2.size();
|
||||||
|
|
||||||
switch (versionId)
|
switch (versionId)
|
||||||
|
@ -190,7 +188,7 @@ bool readPhraseFile1(const std::string &filename, vector<TPhrase> &phrases, bool
|
||||||
{
|
{
|
||||||
ucstring doc;
|
ucstring doc;
|
||||||
|
|
||||||
CI18N::readTextFile(filename, doc, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, doc, false, false, CI18N::LINE_FMT_LF);
|
||||||
verifyVersion(doc, 1);
|
verifyVersion(doc, 1);
|
||||||
return readPhraseFileFromString(doc, filename, phrases, forceRehash);
|
return readPhraseFileFromString(doc, filename, phrases, forceRehash);
|
||||||
}
|
}
|
||||||
|
@ -199,7 +197,7 @@ bool readPhraseFile2(const std::string &filename, vector<TPhrase> &phrases, bool
|
||||||
{
|
{
|
||||||
ucstring doc;
|
ucstring doc;
|
||||||
|
|
||||||
CI18N::readTextFile(filename, doc, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, doc, false, false, CI18N::LINE_FMT_LF);
|
||||||
verifyVersion(doc, 2);
|
verifyVersion(doc, 2);
|
||||||
return readPhraseFileFromString(doc, filename, phrases, forceRehash);
|
return readPhraseFileFromString(doc, filename, phrases, forceRehash);
|
||||||
}
|
}
|
||||||
|
@ -352,7 +350,7 @@ bool mergeStringDiff(vector<TStringInfo> &strings, const string &language, const
|
||||||
{
|
{
|
||||||
// Check if the diff is translated
|
// Check if the diff is translated
|
||||||
ucstring text;
|
ucstring text;
|
||||||
CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(diffs[i], text, false, false, CI18N::LINE_FMT_LF);
|
||||||
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
|
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
|
||||||
{
|
{
|
||||||
LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(diffs[i]).c_str());
|
LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(diffs[i]).c_str());
|
||||||
|
@ -432,6 +430,7 @@ public:
|
||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAdd(uint addIndex, uint refIndex, TStringDiffContext &context)
|
void onAdd(uint addIndex, uint refIndex, TStringDiffContext &context)
|
||||||
{
|
{
|
||||||
TStringInfo si = context.Addition[addIndex];
|
TStringInfo si = context.Addition[addIndex];
|
||||||
|
@ -442,6 +441,7 @@ public:
|
||||||
nlinfo("Added %s at %u", si.Identifier.c_str(), addIndex);
|
nlinfo("Added %s at %u", si.Identifier.c_str(), addIndex);
|
||||||
context.Diff.push_back(si);
|
context.Diff.push_back(si);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onRemove(uint addIndex, uint refIndex, TStringDiffContext &context)
|
void onRemove(uint addIndex, uint refIndex, TStringDiffContext &context)
|
||||||
{
|
{
|
||||||
TStringInfo si = context.Reference[refIndex];
|
TStringInfo si = context.Reference[refIndex];
|
||||||
|
@ -453,6 +453,7 @@ public:
|
||||||
nlinfo("Removed %s at %u", si.Identifier.c_str(), addIndex);
|
nlinfo("Removed %s at %u", si.Identifier.c_str(), addIndex);
|
||||||
context.Diff.push_back(si);
|
context.Diff.push_back(si);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onChanged(uint addIndex, uint refIndex, TStringDiffContext &context)
|
void onChanged(uint addIndex, uint refIndex, TStringDiffContext &context)
|
||||||
{
|
{
|
||||||
TStringInfo si = context.Addition[addIndex];
|
TStringInfo si = context.Addition[addIndex];
|
||||||
|
@ -475,8 +476,6 @@ public:
|
||||||
si.Comments = ucstring(temp) + nl + nl;
|
si.Comments = ucstring(temp) + nl + nl;
|
||||||
context.Diff.push_back(si);
|
context.Diff.push_back(si);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -679,7 +678,7 @@ void cleanComment(const std::string & filename)
|
||||||
ucstring text;
|
ucstring text;
|
||||||
uint nbOldValue=0;
|
uint nbOldValue=0;
|
||||||
|
|
||||||
CI18N::readTextFile(filename, text, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, text, false, false, CI18N::LINE_FMT_LF);
|
||||||
|
|
||||||
ucstring newText;
|
ucstring newText;
|
||||||
ucstring::size_type last = 0;
|
ucstring::size_type last = 0;
|
||||||
|
@ -697,7 +696,7 @@ void cleanComment(const std::string & filename)
|
||||||
ucstring toAdd = text.substr(last, size);
|
ucstring toAdd = text.substr(last, size);
|
||||||
newText += toAdd;
|
newText += toAdd;
|
||||||
ucstring::size_type commentEnd = text.find(ucstring("*/"), commentBegin);
|
ucstring::size_type commentEnd = text.find(ucstring("*/"), commentBegin);
|
||||||
if (commentEnd != ucstring::npos) { commentEnd += 4; }
|
if (commentEnd != ucstring::npos) { commentEnd += 2 + nl.size(); }
|
||||||
last = commentEnd;
|
last = commentEnd;
|
||||||
++nbOldValue;
|
++nbOldValue;
|
||||||
}
|
}
|
||||||
|
@ -800,7 +799,7 @@ int mergeStringDiff(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// backup the original file
|
// backup the original file
|
||||||
ucstring old;
|
ucstring old;
|
||||||
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, old, true, false, CI18N::LINE_FMT_LF);
|
||||||
if (old != str)
|
if (old != str)
|
||||||
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
|
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
|
||||||
}
|
}
|
||||||
|
@ -840,7 +839,7 @@ bool mergePhraseDiff(vector<TPhrase> &phrases, const string &language, bool only
|
||||||
{
|
{
|
||||||
// Check if the diff is translated
|
// Check if the diff is translated
|
||||||
ucstring text;
|
ucstring text;
|
||||||
CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(diffs[i], text, false, false, CI18N::LINE_FMT_LF);
|
||||||
verifyVersion(text, 1);
|
verifyVersion(text, 1);
|
||||||
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
|
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
|
||||||
{
|
{
|
||||||
|
@ -1072,7 +1071,7 @@ int makePhraseDiff(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
LOG("Writing difference file for language %s\n", Languages[l].c_str());
|
LOG("Writing difference file for language %s\n", Languages[l].c_str());
|
||||||
ucstring text;
|
ucstring text;
|
||||||
text += "// DIFF_VERSION 1\r\n";
|
text += "// DIFF_VERSION 1\n";
|
||||||
text += preparePhraseFile(diff, false);
|
text += preparePhraseFile(diff, false);
|
||||||
// add the tag for non translation
|
// add the tag for non translation
|
||||||
text += nl + ucstring ("// REMOVE THE FOLOWING LINE WHEN TRANSLATION IS DONE") + nl + ucstring("// DIFF NOT TRANSLATED") + nl;
|
text += nl + ucstring ("// REMOVE THE FOLOWING LINE WHEN TRANSLATION IS DONE") + nl + ucstring("// DIFF NOT TRANSLATED") + nl;
|
||||||
|
@ -1164,7 +1163,7 @@ int mergePhraseDiff(int argc, char *argv[], int version)
|
||||||
{
|
{
|
||||||
// backup the original file
|
// backup the original file
|
||||||
ucstring old;
|
ucstring old;
|
||||||
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, old, true, false, CI18N::LINE_FMT_LF);
|
||||||
if (old != str)
|
if (old != str)
|
||||||
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
|
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
|
||||||
}
|
}
|
||||||
|
@ -1333,7 +1332,7 @@ int mergeClauseDiff(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// backup the original file
|
// backup the original file
|
||||||
ucstring old;
|
ucstring old;
|
||||||
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, old, true, false, CI18N::LINE_FMT_LF);
|
||||||
if (old != str)
|
if (old != str)
|
||||||
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
|
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
|
||||||
}
|
}
|
||||||
|
@ -1358,7 +1357,7 @@ bool mergeWorksheetDiff(const std::string filename, TWorksheet &sheet, bool only
|
||||||
if (onlyTranslated)
|
if (onlyTranslated)
|
||||||
{
|
{
|
||||||
ucstring text;
|
ucstring text;
|
||||||
CI18N::readTextFile(fileList[i], text, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(fileList[i], text, false, false, CI18N::LINE_FMT_LF);
|
||||||
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
|
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
|
||||||
{
|
{
|
||||||
LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(fileList[i]).c_str());
|
LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(fileList[i]).c_str());
|
||||||
|
@ -1691,7 +1690,7 @@ int mergeWorksheetDiff(int argc, char *argv[], const std::string &filename, cons
|
||||||
// there is no translated file yet, build one from the working file.
|
// there is no translated file yet, build one from the working file.
|
||||||
ucstring str;
|
ucstring str;
|
||||||
string addfn = addDir+additionFile;
|
string addfn = addDir+additionFile;
|
||||||
CI18N::readTextFile(addfn, str, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(addfn, str, false, false, CI18N::LINE_FMT_LF);
|
||||||
str = str.substr(0, str.find(nl)+2);
|
str = str.substr(0, str.find(nl)+2);
|
||||||
CI18N::writeTextFile(transDir+filename, str);
|
CI18N::writeTextFile(transDir+filename, str);
|
||||||
// reread the file.
|
// reread the file.
|
||||||
|
@ -1711,7 +1710,7 @@ int mergeWorksheetDiff(int argc, char *argv[], const std::string &filename, cons
|
||||||
{
|
{
|
||||||
// backup the original file
|
// backup the original file
|
||||||
ucstring old;
|
ucstring old;
|
||||||
CI18N::readTextFile(transDir+filename, old, false, true, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(transDir+filename, old, true, false, CI18N::LINE_FMT_LF);
|
||||||
if (old != str)
|
if (old != str)
|
||||||
{
|
{
|
||||||
string fn(CFile::getFilenameWithoutExtension(filename)), ext(CFile::getExtension(filename));
|
string fn(CFile::getFilenameWithoutExtension(filename)), ext(CFile::getExtension(filename));
|
||||||
|
@ -1865,7 +1864,7 @@ void cropLines(const std::string &filename, uint32 nbLines)
|
||||||
|
|
||||||
LOG("Cropping %u lines from file '%s'\n", nbLines, filename.c_str());
|
LOG("Cropping %u lines from file '%s'\n", nbLines, filename.c_str());
|
||||||
|
|
||||||
CI18N::readTextFile(filename, utext, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, utext, false, false, CI18N::LINE_FMT_LF);
|
||||||
|
|
||||||
string text = utext.toUtf8();
|
string text = utext.toUtf8();
|
||||||
|
|
||||||
|
@ -1910,7 +1909,7 @@ int makeWork()
|
||||||
// change #include "*_en.txt" into #include "*_wk.txt"
|
// change #include "*_en.txt" into #include "*_wk.txt"
|
||||||
ucstring utext;
|
ucstring utext;
|
||||||
|
|
||||||
CI18N::readTextFile(filename, utext, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, utext, false, false, CI18N::LINE_FMT_LF);
|
||||||
string text = utext.toUtf8();
|
string text = utext.toUtf8();
|
||||||
|
|
||||||
bool changedFile = false;
|
bool changedFile = false;
|
||||||
|
@ -2217,7 +2216,6 @@ ucstring preparePhraseFile2(const vector<TPhrase> &phrases, bool removeDiffComme
|
||||||
ret += cond + nl;
|
ret += cond + nl;
|
||||||
}
|
}
|
||||||
ret += '\t';
|
ret += '\t';
|
||||||
// ucstring text = CI18N::makeMarkedString('[', ']', c.Text);
|
|
||||||
|
|
||||||
ucstring text = CI18N::makeMarkedString('[', ']', c.Text);;
|
ucstring text = CI18N::makeMarkedString('[', ']', c.Text);;
|
||||||
ucstring text2;
|
ucstring text2;
|
||||||
|
@ -2331,14 +2329,14 @@ bool sortTransPhrase()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nlinfo("Updating hashcode of phrase file for %s.", Languages[l].c_str());
|
||||||
nlinfo("Updating hashcode of phrase file for %s.\n", Languages[l].c_str());
|
|
||||||
// build the diff file for each language.
|
// build the diff file for each language.
|
||||||
ucstring str = preparePhraseFile(phrases2, false);
|
ucstring str = preparePhraseFile(phrases2, false);
|
||||||
std::string pharseName(transDir+refFile);
|
std::string pharseName(transDir+refFile);
|
||||||
CFile::createDirectoryTree( CFile::getPath(pharseName) );
|
CFile::createDirectoryTree( CFile::getPath(pharseName) );
|
||||||
CI18N::writeTextFile(pharseName, str);
|
CI18N::writeTextFile(pharseName, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2348,7 +2346,7 @@ void patchWorkFile(vector<TPhrase> &updatedPhrase, const std::string & filename)
|
||||||
{
|
{
|
||||||
ucstring text;
|
ucstring text;
|
||||||
if ( updatedPhrase.empty() ) { return; }
|
if ( updatedPhrase.empty() ) { return; }
|
||||||
CI18N::readTextFile(filename, text, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, text, false, false, CI18N::LINE_FMT_LF);
|
||||||
vector<TPhrase>::const_iterator first(updatedPhrase.begin());
|
vector<TPhrase>::const_iterator first(updatedPhrase.begin());
|
||||||
vector<TPhrase>::const_iterator last(updatedPhrase.end());
|
vector<TPhrase>::const_iterator last(updatedPhrase.end());
|
||||||
for (; first != last; ++first)
|
for (; first != last; ++first)
|
||||||
|
@ -2415,7 +2413,6 @@ int updatePhraseWork()
|
||||||
uint lastFile = (uint)outputResult.size();
|
uint lastFile = (uint)outputResult.size();
|
||||||
for (; firstFile != lastFile ; ++firstFile)
|
for (; firstFile != lastFile ; ++firstFile)
|
||||||
{
|
{
|
||||||
|
|
||||||
ucstring doc = outputResult[firstFile].first;
|
ucstring doc = outputResult[firstFile].first;
|
||||||
std::vector<TPhrase> phrases;
|
std::vector<TPhrase> phrases;
|
||||||
readPhraseFileFromString(outputResult[firstFile].first, outputResult[firstFile].second, phrases, true);
|
readPhraseFileFromString(outputResult[firstFile].first, outputResult[firstFile].second, phrases, true);
|
||||||
|
@ -2447,7 +2444,7 @@ int updatePhraseWork()
|
||||||
firstClause->HashValue = clauseHashValue;
|
firstClause->HashValue = clauseHashValue;
|
||||||
}
|
}
|
||||||
updatedPhrases.push_back(transPhrase);
|
updatedPhrases.push_back(transPhrase);
|
||||||
updatedPhrases.back().Comments= ucstring("");
|
updatedPhrases.back().Comments.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2489,7 +2486,7 @@ bool mergePhraseDiff2(vector<TPhrase> &phrases, const string &language, bool onl
|
||||||
{
|
{
|
||||||
// Check if the diff is translated
|
// Check if the diff is translated
|
||||||
ucstring text;
|
ucstring text;
|
||||||
CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(diffs[i], text, false, false, CI18N::LINE_FMT_LF);
|
||||||
verifyVersion(text, 2);
|
verifyVersion(text, 2);
|
||||||
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
|
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
|
||||||
{
|
{
|
||||||
|
@ -2806,7 +2803,7 @@ int makePhraseDiff2(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
LOG("Writing difference file for language %s\n", Languages[l].c_str());
|
LOG("Writing difference file for language %s\n", Languages[l].c_str());
|
||||||
ucstring text;
|
ucstring text;
|
||||||
text += "// DIFF_VERSION 2\r\n";
|
text += "// DIFF_VERSION 2\n";
|
||||||
text += preparePhraseFile(diff, false);
|
text += preparePhraseFile(diff, false);
|
||||||
// add the tag for non translation
|
// add the tag for non translation
|
||||||
text += nl + ucstring ("// REMOVE THE FOLOWING LINE WHEN TRANSLATION IS DONE") + nl + ucstring("// DIFF NOT TRANSLATED") + nl;
|
text += nl + ucstring ("// REMOVE THE FOLOWING LINE WHEN TRANSLATION IS DONE") + nl + ucstring("// DIFF NOT TRANSLATED") + nl;
|
||||||
|
@ -2973,14 +2970,19 @@ void preprocessTextFile(const std::string &filename,
|
||||||
|
|
||||||
ucstring name = line.substr(firstFilename +1, lastFilename - firstFilename -1);
|
ucstring name = line.substr(firstFilename +1, lastFilename - firstFilename -1);
|
||||||
string subFilename = name.toString();
|
string subFilename = name.toString();
|
||||||
{
|
|
||||||
CIFile testFile;
|
if (!CFile::fileExists(subFilename))
|
||||||
if (!testFile.open(subFilename))
|
|
||||||
{
|
{
|
||||||
// try to open the include file relative to current file
|
// try to open the include file relative to current file
|
||||||
subFilename = CFile::getPath(filename)+subFilename;
|
subFilename = CFile::getPath(filename)+subFilename;
|
||||||
|
|
||||||
|
if (!CFile::fileExists(subFilename))
|
||||||
|
{
|
||||||
|
nlwarning("Unable to open %s", subFilename.c_str());
|
||||||
|
subFilename.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preprocessTextFile(subFilename, outputResult);
|
preprocessTextFile(subFilename, outputResult);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2991,8 +2993,6 @@ void preprocessTextFile(const std::string &filename,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outputResult.push_back( std::pair<ucstring, std::string> ( current, fullName ) );
|
outputResult.push_back( std::pair<ucstring, std::string> ( current, fullName ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3029,7 +3029,7 @@ int mergePhraseDiff(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// backup the original file
|
// backup the original file
|
||||||
ucstring old;
|
ucstring old;
|
||||||
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF);
|
CI18N::readTextFile(filename, old, true, false, CI18N::LINE_FMT_LF);
|
||||||
if (old != str)
|
if (old != str)
|
||||||
CFile::moveFile((historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename)).c_str(), filename.c_str());
|
CFile::moveFile((historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename)).c_str(), filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue