From 4438ab108c0a1fcd752cd2f45a7105204ec9c3a7 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 7 Nov 2016 14:12:11 +0100 Subject: [PATCH] Merge with develop --- code/nel/include/nel/misc/i18n.h | 6 +- code/nel/src/misc/app_context.cpp | 1 - code/nel/src/misc/config_file/config_file.cpp | 2 +- code/nel/src/misc/diff_tool.cpp | 13 +- code/nel/src/misc/i18n.cpp | 32 +- .../tools/georges/georges2csv/georges2csv.cpp | 2 +- .../tools/client/ryzom_installer/src/main.cpp | 8 +- .../tools/leveldesign/uni_conv/uni_conv.cpp | 2 +- code/ryzom/tools/translation_tools/main.cpp | 404 +++++++++--------- 9 files changed, 244 insertions(+), 226 deletions(-) diff --git a/code/nel/include/nel/misc/i18n.h b/code/nel/include/nel/misc/i18n.h index a24596911..d50313357 100644 --- a/code/nel/include/nel/misc/i18n.h +++ b/code/nel/include/nel/misc/i18n.h @@ -144,12 +144,10 @@ public: * 16 bits encoding can be recognized by the official header : * 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. */ static void readTextFile(const std::string &filename, - ucstring &result, bool forceUtf8 = false, + ucstring &result, bool fileLookup = true, bool preprocess = false, TLineFormat lineFmt = LINE_FMT_NO_CARE, @@ -259,7 +257,7 @@ private: /// The internal read function, it does the real job of readTextFile static void _readTextFile(const std::string &filename, - ucstring &result, bool forceUtf8, + ucstring &result, bool fileLookup, bool preprocess, TLineFormat lineFmt, diff --git a/code/nel/src/misc/app_context.cpp b/code/nel/src/misc/app_context.cpp index 6bf2d10e1..5206681f9 100644 --- a/code/nel/src/misc/app_context.cpp +++ b/code/nel/src/misc/app_context.cpp @@ -18,7 +18,6 @@ #include "nel/misc/app_context.h" #include "nel/misc/dynloadlib.h" #include "nel/misc/command.h" -#include "nel/misc/system_utils.h" #include diff --git a/code/nel/src/misc/config_file/config_file.cpp b/code/nel/src/misc/config_file/config_file.cpp index bab1c123b..b1ef3bef6 100644 --- a/code/nel/src/misc/config_file/config_file.cpp +++ b/code/nel/src/misc/config_file/config_file.cpp @@ -412,7 +412,7 @@ void CConfigFile::reparse (bool lookupPaths) if (!CPath::lookup(fn, false).empty()) { ucstring content; - CI18N::readTextFile(fn, content, true, true, true); + CI18N::readTextFile(fn, content, true, true); string utf8 = content.toUtf8(); CMemStream stream; diff --git a/code/nel/src/misc/diff_tool.cpp b/code/nel/src/misc/diff_tool.cpp index 6c453d14e..2b2a490bc 100644 --- a/code/nel/src/misc/diff_tool.cpp +++ b/code/nel/src/misc/diff_tool.cpp @@ -117,7 +117,7 @@ bool loadStringFile(const std::string filename, vector &stringInfos */ 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); // delete [] buffer; @@ -313,7 +313,7 @@ bool readPhraseFile(const std::string &filename, vector &phrases, bool { 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); } @@ -416,9 +416,14 @@ bool readPhraseFileFromString(ucstring const& doc, const std::string &filename, phrase.Clauses.size()+1); return false; } - clause.Conditions += "(" + cond + ") "; + + // only prepend a space if required + if (!clause.Conditions.empty()) clause.Conditions += " "; + + clause.Conditions += "(" + cond + ")"; CI18N::skipWhiteSpace(first, last, &clause.Comments); } + if (first == last) { 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(); 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)) return false; diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index b004ef886..3d617bef4 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -502,25 +502,39 @@ void CI18N::skipWhiteSpace(ucstring::const_iterator &it, ucstring::const_iterato if (storeComments && *it == '/' && it+1 != last && *(it+1) == '/') { // 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++); + // store the final '\n' if (it != last) - storeComments->push_back(*it++); + storeComments->push_back('\n'); } else if (storeComments && *it == '/' && it+1 != last && *(it+1) == '*') { // found a multi line C++ comment. store until we found the closing '*/' - while (it != last && !(*it == '*' && it+1 != last && *(it+1) == '/')) - storeComments->push_back(*it++); + while (it != last && !(*it == '*' && it + 1 != last && *(it + 1) == '/')) + { + // don't put \r + if (*it == '\r') + { + // skip it + ++it; + } + else + { + storeComments->push_back(*it++); + } + } + // store the final '*' if (it != last) storeComments->push_back(*it++); + // store the final '/' if (it != last) storeComments->push_back(*it++); + // and a new line. - storeComments->push_back('\r'); storeComments->push_back('\n'); } else @@ -656,7 +670,6 @@ bool CI18N::parseMarkedString(ucchar openMark, ucchar closeMark, ucstring::const void CI18N::readTextFile(const string &filename, ucstring &result, - bool forceUtf8, bool fileLookup, bool preprocess, TLineFormat lineFmt, @@ -666,7 +679,7 @@ void CI18N::readTextFile(const string &filename, TReadContext readContext; // 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()) { @@ -709,7 +722,6 @@ void CI18N::skipLine(ucstring::const_iterator &it, ucstring::const_iterator end, void CI18N::_readTextFile(const string &filename, ucstring &result, - bool forceUtf8, bool fileLookup, bool preprocess, TLineFormat lineFmt, @@ -819,7 +831,7 @@ void CI18N::_readTextFile(const string &filename, subFilename.c_str()); ucstring inserted; - _readTextFile(subFilename, inserted, forceUtf8, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); + _readTextFile(subFilename, inserted, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); final += inserted; } } @@ -873,7 +885,7 @@ void CI18N::_readTextFile(const string &filename, subFilename.c_str()); ucstring inserted; - _readTextFile(subFilename, inserted, forceUtf8, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); + _readTextFile(subFilename, inserted, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); final += inserted; } } diff --git a/code/nel/tools/georges/georges2csv/georges2csv.cpp b/code/nel/tools/georges/georges2csv/georges2csv.cpp index 339479bfe..99dd920ef 100644 --- a/code/nel/tools/georges/georges2csv/georges2csv.cpp +++ b/code/nel/tools/georges/georges2csv/georges2csv.cpp @@ -550,7 +550,7 @@ void executeScriptBuf(const string &text) void executeScriptFile(const string &filename) { ucstring temp; - CI18N::readTextFile(filename, temp, false, false, false); + CI18N::readTextFile(filename, temp, false, false); if (temp.empty()) { diff --git a/code/ryzom/tools/client/ryzom_installer/src/main.cpp b/code/ryzom/tools/client/ryzom_installer/src/main.cpp index 499bd0198..ad95075e3 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/main.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/main.cpp @@ -98,6 +98,10 @@ int main(int argc, char *argv[]) QApplication::setApplicationVersion(RYZOM_VERSION); 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(); // load application translations @@ -199,7 +203,7 @@ int main(int argc, char *argv[]) nlinfo("Launching %s", Q2C(tempFile)); // 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)); } @@ -309,7 +313,7 @@ int main(int argc, char *argv[]) QFile::setPermissions(config.getInstallerInstalledFilePath(), QFile::permissions(config.getInstallerInstalledFilePath()) | QFile::ExeGroup | QFile::ExeUser | QFile::ExeOther); #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())); #endif diff --git a/code/ryzom/tools/leveldesign/uni_conv/uni_conv.cpp b/code/ryzom/tools/leveldesign/uni_conv/uni_conv.cpp index fa593d67d..d6afe9a57 100644 --- a/code/ryzom/tools/leveldesign/uni_conv/uni_conv.cpp +++ b/code/ryzom/tools/leveldesign/uni_conv/uni_conv.cpp @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) } ucstring str; - CI18N::readTextFile(inputFile, str, false, false, false); + CI18N::readTextFile(inputFile, str, false, false); if (outMode == ASCII) { diff --git a/code/ryzom/tools/translation_tools/main.cpp b/code/ryzom/tools/translation_tools/main.cpp index 8d5609d90..aacfe41f1 100644 --- a/code/ryzom/tools/translation_tools/main.cpp +++ b/code/ryzom/tools/translation_tools/main.cpp @@ -21,10 +21,10 @@ * I work with two different file format : * - phrase file witch contain a complex grammar description * - string file withc contain only pair of identifier / string value. -* +* * This tool can do 6 different work : * - make diff string file file for each language from a reference string file. -* +* * - merge the translated diff string file into there respective string file after * translation * @@ -43,10 +43,10 @@ * * Before invocation, you must be in the translation repository (see localisation_system_in_ryzom.doc) * Invocation should be as folow : -* trans_tool make_string_diff -* trans_tool merge_string_diff +* trans_tool make_string_diff +* trans_tool merge_string_diff * trans_tool make_words_diff -* trans_tool merge_words_diff +* trans_tool merge_words_diff * trans_tool make_phrase_diff * trans_tool merge_phrase_diff * trans_tool make_clause_diff @@ -151,24 +151,22 @@ void showUsage(char *exeName) LOG("Reference language is always the first language in languages.txt\n"); } - - 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 version2("// DIFF_VERSION 2\r\n"); + ucstring version2("// DIFF_VERSION 2\n"); ucstring::size_type version2Size = version2.size(); switch (versionId) { - case 1: + case 1: if (doc.size() < version1Size|| doc.substr(0, version1Size) != version1 ) { nlerror("Loading wrong diff version"); nlassert(0); - } - doc = doc.substr(version1Size); + } + doc = doc.substr(version1Size); break; case 2: @@ -176,7 +174,7 @@ void verifyVersion(ucstring& doc, int versionId) { nlerror("Loading wrong diff version"); nlassert(0); - } + } doc = doc.substr(version2Size); break; @@ -190,7 +188,7 @@ bool readPhraseFile1(const std::string &filename, vector &phrases, bool { 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); return readPhraseFileFromString(doc, filename, phrases, forceRehash); } @@ -199,7 +197,7 @@ bool readPhraseFile2(const std::string &filename, vector &phrases, bool { 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); return readPhraseFileFromString(doc, filename, phrases, forceRehash); } @@ -251,7 +249,7 @@ bool parseDiffCommandFromComment(const ucstring &comments, TDiffInfo &diffInfo) diffInfo.Command = diff_none; return false; } - + CI18N::skipWhiteSpace(it, last); // ok, parse the index. string indexStr; @@ -352,7 +350,7 @@ bool mergeStringDiff(vector &strings, const string &language, const { // Check if the diff is translated 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) { LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(diffs[i]).c_str()); @@ -423,7 +421,7 @@ public: void run(const vector &addition, vector &reference, vector &diff) { TStringDiffContext context(addition, reference, diff); - + CMakeDiff differ; differ.makeDiff(this, context); } @@ -432,6 +430,7 @@ public: { // nothing to do } + void onAdd(uint addIndex, uint refIndex, TStringDiffContext &context) { TStringInfo si = context.Addition[addIndex]; @@ -442,6 +441,7 @@ public: nlinfo("Added %s at %u", si.Identifier.c_str(), addIndex); context.Diff.push_back(si); } + void onRemove(uint addIndex, uint refIndex, TStringDiffContext &context) { TStringInfo si = context.Reference[refIndex]; @@ -453,6 +453,7 @@ public: nlinfo("Removed %s at %u", si.Identifier.c_str(), addIndex); context.Diff.push_back(si); } + void onChanged(uint addIndex, uint refIndex, TStringDiffContext &context) { TStringInfo si = context.Addition[addIndex]; @@ -471,12 +472,10 @@ public: char temp[1024]; sprintf(temp, "// DIFF SWAP %u %u (swaping %s and %s)", newIndex, refIndex, context.Reference[newIndex].Identifier.c_str(), context.Reference[refIndex].Identifier.c_str()); // sprintf(temp, "// DIFF SWAP %u %u", newIndex, refIndex); - - si.Comments = ucstring(temp) + nl +nl; + + si.Comments = ucstring(temp) + nl + nl; context.Diff.push_back(si); } - - }; @@ -501,7 +500,7 @@ void makeStringDiff(const vector &addition, vector &re vector::iterator it; if (addCount == addition.size() - || + || ( !equal // && find_if(addition.begin()+addCount, addition.end(), TFindStringInfo(reference[refCount].Identifier)) == addition.end() @@ -521,7 +520,7 @@ void makeStringDiff(const vector &addition, vector &re ++refCount; } else if (refCount == reference.size() - || + || ( !equal // && find_if(reference.begin()+refCount, reference.end(), TFindStringInfo(addition[addCount].Identifier)) == reference.end() @@ -564,7 +563,7 @@ void makeStringDiff(const vector &addition, vector &re TStringInfo si; char temp[1024]; sprintf(temp, "// DIFF SWAP %u %u", it - reference.begin(), refCount); - + si.Comments = ucstring(temp) + nl; diff.push_back(si); } @@ -596,7 +595,7 @@ void makeStringDiff(const vector &addition, vector &re int makeStringDiff(int argc, char *argv[]) { - // this will generate diff from 'addition' directory + // this will generate diff from 'addition' directory // for the reference .uxt file // with the same file in the 'translated' directory. @@ -617,7 +616,7 @@ int makeStringDiff(int argc, char *argv[]) for (uint l=0; l 4 && text.substr(commentBegin-1, 1) == ucstring(":")) @@ -738,12 +737,12 @@ void cleanComment(const std::string & filename) ) { newText += comment; - } + } } last = commentEnd; ++nbOldValue; } - } + } } nlinfo("cleaning : %s, (%d comments deleted)...\n", filename.c_str(), nbOldValue); CI18N::writeTextFile(filename , newText); @@ -754,14 +753,14 @@ REMOVE OLDVALUE: from a diff string file */ int cleanStringDiff(int argc, char *argv[]) { - + LOG("Cleaning string diffs\n"); uint i,l; for (l=0; l diffs; getPathContentFiltered(diffDir+Languages[l]+"_diff_", ".uxt", diffs); @@ -800,7 +799,7 @@ int mergeStringDiff(int argc, char *argv[]) { // backup the original file 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) CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename); } @@ -840,7 +839,7 @@ bool mergePhraseDiff(vector &phrases, const string &language, bool only { // Check if the diff is translated 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); if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos) { @@ -878,9 +877,9 @@ bool mergePhraseDiff(vector &phrases, const string &language, bool only switch(diffInfo.Command) { case diff_swap: - nlassertex(diffInfo.Index1 <= phrases.size(), + nlassertex(diffInfo.Index1 <= phrases.size(), ("In SWAP, Index1 (%u) is not less than number of phrase (%u)", diffInfo.Index1, phrases.size())); - nlassertex(diffInfo.Index2 <= phrases.size(), + nlassertex(diffInfo.Index2 <= phrases.size(), ("In SWAP Index2 (%u) is not less than number of phrase (%u)", diffInfo.Index2, phrases.size())); swap(phrases[diffInfo.Index1], phrases[diffInfo.Index2]); // remove the swap from the comments @@ -888,7 +887,7 @@ bool mergePhraseDiff(vector &phrases, const string &language, bool only j--; break; case diff_add: - nlassertex(diffInfo.Index1 <= phrases.size(), + nlassertex(diffInfo.Index1 <= phrases.size(), ("In ADD, Index1 (%u) is not less than number of phrase (%u)", diffInfo.Index1, phrases.size())); phrases.insert(phrases.begin()+diffInfo.Index1, diff[j]); break; @@ -925,7 +924,7 @@ public: void run(const vector &addition, vector &reference, vector &diff) { TPhraseDiffContext context(addition, reference, diff); - + CMakeDiff differ; differ.makeDiff(this, context); } @@ -972,9 +971,9 @@ public: if (context.Addition[addIndex].Clauses[i].Identifier != context.Reference[refIndex].Clauses[i].Identifier) chg += ucstring("// Clause ") + toString(i) + " : identifier changed." + nl; else if (context.Addition[addIndex].Clauses[i].Conditions != context.Reference[refIndex].Clauses[i].Conditions) - chg += ucstring("// Clause ") + toString(i) + " : condition changed." + nl; + chg += ucstring("// Clause ") + toString(i) + " : condition changed." + nl; else if (context.Addition[addIndex].Clauses[i].Text != context.Reference[refIndex].Clauses[i].Text) - chg += ucstring("// Clause ") + toString(i) + " : text changed." + nl; + chg += ucstring("// Clause ") + toString(i) + " : text changed." + nl; } } @@ -983,15 +982,15 @@ public: chg = ucstring("// WARNING : Hash code changed ! check translation workflow.") + nl; } nldebug("Changed detected : %s", chg.toString().c_str()); - + // changed element TPhrase phrase = context.Addition[addIndex]; vector tempV; tempV.push_back(context.Reference[refIndex]); - ucstring tempT = preparePhraseFile(tempV, false); + ucstring tempT = preparePhraseFile(tempV, false); CI18N::removeCComment(tempT); phrase.Comments = ucstring("// DIFF CHANGED ") + toString(addIndex) + nl + phrase.Comments; - phrase.Comments = phrase.Comments + ucstring("/* OLD VALUE : ["+nl) + tabLines(1, tempT) +nl + "] */" + nl; + phrase.Comments = phrase.Comments + ucstring("/* OLD VALUE : [" + nl) + tabLines(1, tempT) + nl + "] */" + nl; phrase.Comments = phrase.Comments + chg; nlinfo("Changed %s at %u", phrase.Identifier.c_str(), addIndex); @@ -1003,7 +1002,7 @@ public: TPhrase phrase; char temp[1024]; sprintf(temp, "// DIFF SWAP %u %u (swaping %s and %s)", newIndex, refIndex, context.Reference[newIndex].Identifier.c_str(), context.Reference[refIndex].Identifier.c_str()); - + nldebug("Swap for %u %u", newIndex, refIndex); phrase.Comments = ucstring(temp) + nl; context.Diff.push_back(phrase); @@ -1017,7 +1016,7 @@ int makePhraseDiff(int argc, char *argv[]) { // Generate the diff file from phrase_.txt compared to the same file in translated. // The diff is generated only from the reference language for and all the languages - + LOG("Generating phrase diffs\nLoading the working file for language %s\n", Languages[0].c_str()); @@ -1071,11 +1070,11 @@ int makePhraseDiff(int argc, char *argv[]) else { LOG("Writing difference file for language %s\n", Languages[l].c_str()); - ucstring text; - text += "// DIFF_VERSION 1\r\n"; + ucstring text; + text += "// DIFF_VERSION 1\n"; text += preparePhraseFile(diff, false); // 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; CI18N::writeTextFile(diffDir+"phrase_"+Languages[l]+"_diff_"+diffVersion+".txt", text); } } @@ -1088,22 +1087,22 @@ int makePhraseDiff(int argc, char *argv[]) REMOVE OLDVALUE: from a diff clause file */ int cleanPhraseDiff(int argc, char *argv[]) -{ - +{ + LOG("Cleaning phrase diffs\n"); - + uint i,l; for (l=0; l diffs; getPathContentFiltered(diffDir+"phrase_"+Languages[l]+"_diff_", ".txt", diffs); for (i=0; i.txt file // with the same file in the 'translated' directory. @@ -1229,19 +1228,19 @@ int makeClauseDiff(int argc, char *argv[]) if (!si.Identifier.empty()) - { + { vector::const_iterator first2 = addition.begin(); vector::const_iterator last2 = addition.end(); for ( ;first2!=last2 && first2->Identifier != si.Identifier; ++first2) {} bool isAllreadyThere = first2 != last2; if (isAllreadyThere) { - warnings.push_back("The clause " +si.Identifier +" in the phrase " + p.Identifier +" exists more than once."); + warnings.push_back("The clause " +si.Identifier +" in the phrase " + p.Identifier +" exists more than once."); } else { addition.push_back(si); - } + } } } } @@ -1254,7 +1253,7 @@ int makeClauseDiff(int argc, char *argv[]) return -1; } mergeStringDiff(reference, Languages[l], "clause_", ".txt", false); - + vector diff; makeStringDiff(addition, reference, diff); @@ -1270,7 +1269,7 @@ int makeClauseDiff(int argc, char *argv[]) ucstring str = prepareStringFile(diff, false); // add the tag for non translation - str += nl + ucstring ("// REMOVE THE FOLOWING LINE WHEN TRANSLATION IS DONE")+nl+ucstring("// DIFF NOT TRANSLATED")+nl; + str += nl + ucstring ("// REMOVE THE FOLOWING LINE WHEN TRANSLATION IS DONE") + nl + ucstring("// DIFF NOT TRANSLATED") + nl; std::string diffName(diffDir+"clause_"+Languages[l]+"_diff_"+diffVersion+".txt"); CI18N::writeTextFile(diffName, str); @@ -1286,16 +1285,16 @@ REMOVE OLDVALUE: from a diff clause file */ int cleanClauseDiff(int argc, char *argv[]) { - + LOG("Cleaning clause diffs\n"); uint i,l; for (l=0; l diffs; getPathContentFiltered(diffDir+"clause_"+Languages[l]+"_diff_", ".txt", diffs); @@ -1333,7 +1332,7 @@ int mergeClauseDiff(int argc, char *argv[]) { // backup the original file 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) 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) { 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) { LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(fileList[i]).c_str()); @@ -1471,7 +1470,7 @@ public: void run(const TWorksheet &addition, TWorksheet &reference, TWorksheet &diff) { TWordsDiffContext context(addition, reference, diff); - + TWorkSheetDiff differ; differ.makeDiff(this, context, true); } @@ -1560,14 +1559,14 @@ REMOVE OLDVALUE: from a diff words file */ int cleanWordsDiff(int argc, char *argv[]) { - + LOG("Cleaning words diffs\n"); uint i,l; for (l=0; l diffs; getPathContentFiltered(diffDir+"clause_"+Languages[l]+"_diff_", ".txt", diffs); @@ -1662,12 +1661,12 @@ int makeWorksheetDiff(int argc, char *argv[], const std::string &additionFilenam ucstring str = prepareExcelSheet(diff); // add the tag for non translation - str += ucstring ("REMOVE THE FOLOWING TWO LINE WHEN TRANSLATION IS DONE")+nl+ucstring("DIFF NOT TRANSLATED")+nl; + str += ucstring ("REMOVE THE FOLOWING TWO LINE WHEN TRANSLATION IS DONE") + nl + ucstring("DIFF NOT TRANSLATED") + nl; string fn(CFile::getFilenameWithoutExtension(referenceFilename)), ext(CFile::getExtension(referenceFilename)); std::string diffName(diffDir+fn+"_diff_"+diffVersion+"."+ext); CI18N::writeTextFile(diffName, str); - + } return 0; @@ -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. ucstring str; 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); CI18N::writeTextFile(transDir+filename, str); // reread the file. @@ -1711,7 +1710,7 @@ int mergeWorksheetDiff(int argc, char *argv[], const std::string &filename, cons { // backup the original file 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) { string fn(CFile::getFilenameWithoutExtension(filename)), ext(CFile::getExtension(filename)); @@ -1784,7 +1783,7 @@ int mergeWordsDiff(int argc, char *argv[]) --i; } } - + // for each language for (uint l=0; l& reference) } } } - + } @@ -2052,7 +2051,7 @@ void mergePhraseDiff2Impl(vector& reference, const vector& add { nlassert( phrases.find(first->Identifier) != phrases.end() ); phrases[first->Identifier] = *first; - } + } else if ( first->Comments.find(ucstring("DIFF ADD")) != ucstring::npos) { nlassert( phrases.find(first->Identifier) == phrases.end() ); @@ -2067,13 +2066,13 @@ void mergePhraseDiff2Impl(vector& reference, const vector& add else { // nlassert(0 && "INVALID DIFF COMMAND"); - } + } } } { reference.clear(); - reference.reserve(phrases.size()); + reference.reserve(phrases.size()); TMap::const_iterator first( phrases.begin() ); TMap::const_iterator last( phrases.end() ); for( ; first != last; ++first) { reference.push_back(first->second); } @@ -2089,11 +2088,11 @@ void removeHashValueComment(ucstring & comments) if (first != ucstring::npos) { last = comments.find(ucstring("\n"), first); - if (last != ucstring::npos) - { + if (last != ucstring::npos) + { last += 1; ucstring tmp1 = comments.substr(0, first); - ucstring tmp2 = last !=comments.size() + ucstring tmp2 = last !=comments.size() ? comments.substr(last) : ucstring(""); comments = tmp1 + tmp2; @@ -2112,10 +2111,10 @@ void removeHashValueComment(ucstring & comments) bool updateClauseHashValue(const std::map >& validValues, const std::string & dirPath = "") { - + for (uint l=0; l clauses; std::string refFile(basename+".txt"); @@ -2137,7 +2136,7 @@ bool updateClauseHashValue(const std::map clauses[i].HashValue = validValues.find(Identifier)->second.first; removeHashValueComment(clauses[i].Comments); changed = true; - } + } } } @@ -2150,7 +2149,7 @@ bool updateClauseHashValue(const std::map nlinfo("Updating hashcode of clause file for %s.\n", Languages[l].c_str()); // build the diff file for each language. ucstring str = prepareStringFile(clauses, false); - std::string clauseName(dirPath+ transDir + basename +".txt"); + std::string clauseName(dirPath+ transDir + basename +".txt"); CFile::createDirectoryTree( CFile::getPath(clauseName) ); CI18N::writeTextFile(clauseName, str); } @@ -2217,7 +2216,6 @@ ucstring preparePhraseFile2(const vector &phrases, bool removeDiffComme ret += cond + nl; } ret += '\t'; -// ucstring text = CI18N::makeMarkedString('[', ']', c.Text); ucstring text = CI18N::makeMarkedString('[', ']', c.Text);; ucstring text2; @@ -2230,9 +2228,9 @@ ucstring preparePhraseFile2(const vector &phrases, bool removeDiffComme text = text.substr(pos+2); } text2 += text;//.substr(0, pos+2); - + text.swap(text2); - + text = tabLines(3, text); // remove begin tabs text = text.substr(3); @@ -2248,10 +2246,10 @@ ucstring preparePhraseFile2(const vector &phrases, bool removeDiffComme bool updatePhraseHashValue(const std::map > & validValues, const std::string & dirPath = "") { - + for (uint l=0; l phrases; std::string refFile(basename+".txt"); @@ -2269,7 +2267,7 @@ bool updatePhraseHashValue(const std::map { if (!validValues.find(Identifier)->second.second || phrases[i].HashValue == validValues.find(Identifier)->second.second ) { - + phrases[i].HashValue = validValues.find(Identifier)->second.first; removeHashValueComment(phrases[i].Comments); changed = true; @@ -2286,7 +2284,7 @@ bool updatePhraseHashValue(const std::map nlinfo("Updating hashcode of phrase file for %s.\n", Languages[l].c_str()); // build the diff file for each language. ucstring str = preparePhraseFile(phrases, false); - std::string pharseName(dirPath+ transDir + basename +".txt"); + std::string pharseName(dirPath+ transDir + basename +".txt"); CFile::createDirectoryTree( CFile::getPath(pharseName) ); CI18N::writeTextFile(pharseName, str); } @@ -2298,10 +2296,10 @@ bool updatePhraseHashValue(const std::map bool sortTransPhrase() { - + for (uint l=0; l phrases; vector phrases2; @@ -2312,9 +2310,9 @@ bool sortTransPhrase() LOG("Error will loading file %s", (transDir+refFile).c_str()); return false; } - - { - + + { + std::vector::const_iterator first(phrases.begin()); std::vector::const_iterator last(phrases.end()); for ( ; first != last; ++first) @@ -2331,14 +2329,14 @@ bool sortTransPhrase() } } - - nlinfo("Updating hashcode of phrase file for %s.\n", Languages[l].c_str()); + nlinfo("Updating hashcode of phrase file for %s.", Languages[l].c_str()); // build the diff file for each language. ucstring str = preparePhraseFile(phrases2, false); - std::string pharseName(transDir+refFile); + std::string pharseName(transDir+refFile); CFile::createDirectoryTree( CFile::getPath(pharseName) ); CI18N::writeTextFile(pharseName, str); } + return true; } @@ -2348,12 +2346,12 @@ void patchWorkFile(vector &updatedPhrase, const std::string & filename) { ucstring text; 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::const_iterator first(updatedPhrase.begin()); vector::const_iterator last(updatedPhrase.end()); for (; first != last; ++first) { - + ucstring::size_type firstFun = text.find( ucstring(first->Identifier)); if (firstFun == ucstring::npos) { @@ -2370,26 +2368,26 @@ void patchWorkFile(vector &updatedPhrase, const std::string & filename) { std::vector param; param.push_back(*first); - + ucstring before = text.substr(0,firstFun); ucstring str = preparePhraseFile2(param, false); - ucstring after = text.substr(lastFun+1); - text = ""; + ucstring after = text.substr(lastFun+1); + text = ""; text += before; text += str; text += after; - } + } } } CI18N::writeTextFile( filename, text); - + } int updatePhraseWork() { std::string saveDir = diffDir + "update_"+ diffVersion + "/"; vector transPhrase; - std::map transPhraseMap; + std::map transPhraseMap; std::map > validClauseHashValue; std::map > validPhraseHashValue; std::vector< std::pair > outputResult; @@ -2408,16 +2406,15 @@ int updatePhraseWork() transPhraseMap[first->Identifier] = *first; } } - + preprocessTextFile(addDir+"phrase_wk.txt", outputResult); uint firstFile = 0; uint lastFile = (uint)outputResult.size(); for (; firstFile != lastFile ; ++firstFile) { - ucstring doc = outputResult[firstFile].first; - std::vector phrases; + std::vector phrases; readPhraseFileFromString(outputResult[firstFile].first, outputResult[firstFile].second, phrases, true); std::vector::iterator first(phrases.begin()); @@ -2442,35 +2439,35 @@ int updatePhraseWork() for (; firstClause != lastClause; ++firstClause) { uint64 clauseHashValue = CI18N::makeHash(firstClause->Text); - + validClauseHashValue[firstClause->Identifier] = std::pair(clauseHashValue, firstClause->HashValue); firstClause->HashValue = clauseHashValue; } updatedPhrases.push_back(transPhrase); - updatedPhrases.back().Comments= ucstring(""); - } + updatedPhrases.back().Comments.clear(); + } } } } - + std::string newFile = saveDir + outputResult[firstFile].second; std::string oldFile = outputResult[firstFile].second; CFile::createDirectoryTree(CFile::getPath(newFile)); if ( CFile::copyFile(newFile, oldFile) ) { - + patchWorkFile(updatedPhrases, newFile); } else { nlwarning("Can't copy %s", newFile.c_str()); } - - } + + } updatePhraseHashValue(validPhraseHashValue, saveDir); - updateClauseHashValue(validClauseHashValue, saveDir); + updateClauseHashValue(validClauseHashValue, saveDir); return 0; } @@ -2484,12 +2481,12 @@ bool mergePhraseDiff2(vector &phrases, const string &language, bool onl getPathContentFiltered(diffDir+"phrase_"+language+"_diff_", ".txt", diffs); for (uint i=0; i &phrases, const string &language, bool onl } } - + // we found a diff file for the addition file. LOG("Adding %s diff as reference\n", diffs[i].c_str()); @@ -2508,9 +2505,9 @@ bool mergePhraseDiff2(vector &phrases, const string &language, bool onl if (!readPhraseFile2(diffs[i], diff, false)) return false; - + mergePhraseDiff2Impl(phrases, diff); - + if (archiveDiff) { @@ -2541,13 +2538,13 @@ public: // bool clauseEqual(const TClause& left, const TClause& right) const; }; - + void run(const vector &addition, vector &reference, vector &diff); void onEquivalent(uint addIndex, uint refIndex, TPhraseDiffContext &context); void onAdd(uint addIndex, uint refIndex, TPhraseDiffContext &context); - + void onRemove(uint addIndex, uint refIndex, TPhraseDiffContext &context); void onChanged(uint addIndex, uint refIndex, TPhraseDiffContext &context); @@ -2562,12 +2559,12 @@ public: void CMakePhraseDiff2::run(const vector &addition, vector &reference, vector &diff) { - + TPhraseDiffContext context(addition, reference, diff); std::set phraseIdentifier; std::map mapAdd; - std::map mapRef; + std::map mapRef; { uint first = 0; @@ -2597,19 +2594,19 @@ void CMakePhraseDiff2::run(const vector &addition, vector &ref { nlwarning("Phrases are defined more than once in works directory"); } - + if (mapAdd.size() != addition.size()) { nlwarning("Phrases are defined more than once in translation directory"); } - - + + std::set::iterator first(phraseIdentifier.begin()); std::set::iterator last(phraseIdentifier.end()); for (; first != last; ++first) { - if ( mapAdd.find(*first) != mapAdd.end() + if ( mapAdd.find(*first) != mapAdd.end() && mapRef.find(*first) != mapRef.end()) { @@ -2622,17 +2619,17 @@ void CMakePhraseDiff2::run(const vector &addition, vector &ref onChanged(mapAdd[*first], mapRef[*first], context); } } - else if ( mapAdd.find(*first) != mapAdd.end() + else if ( mapAdd.find(*first) != mapAdd.end() && mapRef.find(*first) == mapRef.end()) { onAdd(mapAdd[*first], 0, context); } - else if ( mapAdd.find(*first) == mapAdd.end() + else if ( mapAdd.find(*first) == mapAdd.end() && mapRef.find(*first) != mapRef.end()) { onRemove(0, mapRef[*first], context); } - + } } @@ -2682,9 +2679,9 @@ void CMakePhraseDiff2::onChanged(uint addIndex, uint refIndex, TPhraseDiffContex if (context.Addition[addIndex].Clauses[i].Identifier != context.Reference[refIndex].Clauses[i].Identifier) chg += ucstring("// Clause ") + toString(i) + " : identifier changed." + nl; else if (context.Addition[addIndex].Clauses[i].Conditions != context.Reference[refIndex].Clauses[i].Conditions) - chg += ucstring("// Clause ") + toString(i) + " : condition changed." + nl; + chg += ucstring("// Clause ") + toString(i) + " : condition changed." + nl; else if (context.Addition[addIndex].Clauses[i].Text != context.Reference[refIndex].Clauses[i].Text) - chg += ucstring("// Clause ") + toString(i) + " : text changed." + nl; + chg += ucstring("// Clause ") + toString(i) + " : text changed." + nl; } } @@ -2693,15 +2690,15 @@ void CMakePhraseDiff2::onChanged(uint addIndex, uint refIndex, TPhraseDiffContex chg = ucstring("// WARNING : Hash code changed ! check translation workflow.") + nl; } nldebug("Changed detected : %s", chg.toString().c_str()); - + // changed element TPhrase phrase = context.Addition[addIndex]; vector tempV; tempV.push_back(context.Reference[refIndex]); - ucstring tempT = preparePhraseFile(tempV, false); + ucstring tempT = preparePhraseFile(tempV, false); CI18N::removeCComment(tempT); phrase.Comments = ucstring("// DIFF CHANGED ") + toString(addIndex) + nl + phrase.Comments; - phrase.Comments = phrase.Comments + ucstring("/* OLD VALUE : ["+nl) + tabLines(1, tempT) +nl + "] */" + nl; + phrase.Comments = phrase.Comments + ucstring("/* OLD VALUE : [" + nl) + tabLines(1, tempT) + nl + "] */" + nl; phrase.Comments = phrase.Comments + chg; nlinfo("Changed %s at %u", phrase.Identifier.c_str(), addIndex); @@ -2717,8 +2714,8 @@ bool CMakePhraseDiff2::CPhraseEqual::operator()( const TPhrase& left, const TPhr // bool clausesOk = clausesEqual(left.Clauses, right.Clauses); bool hashOk = left.HashValue== right.HashValue; - return identifierOk && hashOk;// && parameterOk && clausesOk; - + return identifierOk && hashOk;// && parameterOk && clausesOk; + } /* bool CMakePhraseDiff2::CPhraseEqual::clausesEqual( const std::vector& left, const std::vector& right) const @@ -2728,9 +2725,9 @@ bool CMakePhraseDiff2::CPhraseEqual::clausesEqual( const std::vector& l std::vector::const_iterator first2(right.begin()); if (left.size() != right.size()) return false; - + for ( ; first1 != last1 && !clauseEqual(*first1, *first2); ++first1, ++first2){} - + return first1 == last1; } @@ -2740,7 +2737,7 @@ bool CMakePhraseDiff2::CPhraseEqual::clauseEqual(const TClause& left, const TCla && left.Conditions != right.Conditions && left.Text != right.Text && left.Comments != right.Comments - && left.HashValue != right.HashValue; + && left.HashValue != right.HashValue; } */ @@ -2751,7 +2748,7 @@ int makePhraseDiff2(int argc, char *argv[]) { // Generate the diff file from phrase_.txt compared to the same file in translated. // The diff is generated only from the reference language for and all the languages - + LOG("Generating phrase diffs\nLoading the working file for language %s\n", Languages[0].c_str()); @@ -2806,10 +2803,10 @@ int makePhraseDiff2(int argc, char *argv[]) { LOG("Writing difference file for language %s\n", Languages[l].c_str()); ucstring text; - text += "// DIFF_VERSION 2\r\n"; + text += "// DIFF_VERSION 2\n"; text += preparePhraseFile(diff, false); // 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; CI18N::writeTextFile(diffDir+"phrase_"+Languages[l]+"_diff_"+diffVersion+".txt", text); } } @@ -2851,7 +2848,7 @@ int forgetPhraseDiff(int argc, char *argv[]) std::copy (subDiff.begin (), subDiff.end (), std::back_inserter (newPhrase)); } - // a optimiser par une map + // a optimiser par une map std::map > validClauseHashValue; std::map > validPhraseHashValue; for (uint i=0; i < newPhrase.size() ; ++i) @@ -2859,17 +2856,17 @@ int forgetPhraseDiff(int argc, char *argv[]) for (uint j=0; j < reference.size() ; ++j) { if (newPhrase[i].Identifier == reference[j].Identifier) - { - + { + uint64 newPhraseHash = STRING_MANAGER::makePhraseHash( newPhrase[i] ); uint64 oldPhraseHash = reference[j].HashValue; validPhraseHashValue[newPhrase[i].Identifier] = std::pair(newPhraseHash, oldPhraseHash); - + for (uint k=0; k < newPhrase[i].Clauses.size() ; ++k) { if (reference[j] .Clauses.size() != newPhrase[i].Clauses.size()) - { + { nlwarning("Want to forget minor update but phrase %s changes too much. The number of clauses has changed.", newPhrase[i].Identifier.c_str() ); exit(-1); } @@ -2879,7 +2876,7 @@ int forgetPhraseDiff(int argc, char *argv[]) if (!newClause.Identifier.empty() ) { if (newClause.Identifier != oldClause.Identifier) - { + { nlwarning("Want to forget minor update but phrase %s changes too much. Clauses order or clause identifier changed (%s).", newPhrase[i].Identifier.c_str(), newClause.Identifier.c_str()); exit(-1); } @@ -2891,7 +2888,7 @@ int forgetPhraseDiff(int argc, char *argv[]) } } } - + if (!mergePhraseDiff2(reference, Languages[0], true, false)) { @@ -2901,13 +2898,13 @@ int forgetPhraseDiff(int argc, char *argv[]) ucstring str = preparePhraseFile(reference, true); CI18N::writeTextFile(transDir+basename+".txt", str); - + updatePhraseHashValue(validPhraseHashValue); // updateClauseHashValue(validClauseHashValue); - + for (uint i=0; i > & outputResult + std::vector< std::pair > & outputResult ) - + { //nlinfo("preprocessing %s", filename.c_str()); ucstring result; @@ -2949,7 +2946,7 @@ void preprocessTextFile(const std::string &filename, if (!text.empty()) CI18N::readTextBuffer((uint8*)&text[0], (uint)text.size(), result); - + ucstring final; // parse the file, looking for preprocessor command. @@ -2962,9 +2959,9 @@ void preprocessTextFile(const std::string &filename, { pos = result.find(ucstring("\n"), pos); if (pos != ucstring::npos) { ++pos; } - + ucstring line( result.substr(lastPos, pos - lastPos) ); - + if ( line.find(includeCmd) != ucstring::npos) { @@ -2972,15 +2969,20 @@ void preprocessTextFile(const std::string &filename, ucstring::size_type lastFilename = line.find(ucstring("\""), firstFilename+1); ucstring name = line.substr(firstFilename +1, lastFilename - firstFilename -1); - string subFilename = name.toString(); + string subFilename = name.toString(); + + if (!CFile::fileExists(subFilename)) { - CIFile testFile; - if (!testFile.open(subFilename)) - { // 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); } else @@ -2988,11 +2990,9 @@ void preprocessTextFile(const std::string &filename, current += line; } lastPos = pos; - + } - - outputResult.push_back( std::pair ( current, fullName ) ); } @@ -3029,7 +3029,7 @@ int mergePhraseDiff(int argc, char *argv[]) { // backup the original file 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) CFile::moveFile((historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename)).c_str(), filename.c_str()); } @@ -3055,7 +3055,7 @@ int injectClause() vector clauses; vector phrases; - // load the clause file + // load the clause file std::string clausePath( transDir+"clause_"+Languages[l]+".txt" ); if (!loadStringFile(clausePath, clauses, false)) { @@ -3063,7 +3063,7 @@ int injectClause() return 1; } - // load the phrase file + // load the phrase file std::string phrasePath( transDir+"phrase_"+Languages[l]+".txt" ); if (!readPhraseFile(phrasePath, phrases, false)) { @@ -3075,7 +3075,7 @@ int injectClause() vector::iterator last(phrases.end()); for ( ; first != last; ++first) { - + vector::iterator firstClause( first->Clauses.begin()); vector::iterator lastClause( first->Clauses.end()); for ( ; firstClause != lastClause; ++firstClause) @@ -3093,11 +3093,11 @@ int injectClause() nlinfo("update clause %s from clause file %s.", firstClause->Identifier.c_str(), clausePath.c_str()); - } - } - } + } + } + } } - + std::string desDir(diffDir + "inject_clause_" + diffVersion + "/"); CFile::createDirectoryTree(desDir+ CFile::getPath(phrasePath)); ucstring str = preparePhraseFile(phrases, true); @@ -3138,7 +3138,7 @@ int main(int argc, char *argv[]) return 1; } std::string argv1(argv[1]); - + // create the diff version. char temp[16]; sprintf(temp, "%8.8X", (uint) ::time(NULL)); @@ -3189,7 +3189,7 @@ int main(int argc, char *argv[]) return extractBotNames(argc, argv); else if (strcmp(argv[1], "extract_new_sheet_names") == 0) return extractNewSheetNames(argc, argv); - + @@ -3220,35 +3220,35 @@ int main(int argc, char *argv[]) else if (strcmp(argv[1], "clean_string_diff") == 0) return cleanStringDiff(argc, argv); - else if (argv1 == "make_phrase_diff_old") + else if (argv1 == "make_phrase_diff_old") return makePhraseDiff(argc, argv); else if (argv1 == "merge_phrase_diff_old") return mergePhraseDiff(argc, argv, 1); - - else if (argv1 == "make_phrase_diff") + + else if (argv1 == "make_phrase_diff") return makePhraseDiff2(argc, argv); else if (argv1 == "merge_phrase_diff") return mergePhraseDiff(argc, argv, 2); else if (argv1 == "forget_phrase_diff") - return forgetPhraseDiff(argc, argv); + return forgetPhraseDiff(argc, argv); else if (argv1 == "update_phrase_work") return updatePhraseWork(); else if (argv1 == "clean_phrase_diff") - return cleanPhraseDiff(argc, argv); + return cleanPhraseDiff(argc, argv); else if (argv1 == "inject_clause") return injectClause(); - + else if (argv1 == "sort_trans_phrase") return sortTransPhrase(); - + else if (strcmp(argv[1], "make_clause_diff") == 0) return makeClauseDiff(argc, argv); else if (strcmp(argv[1], "merge_clause_diff") == 0) return mergeClauseDiff(argc, argv); else if (argv1 == "clean_clause_diff") - return cleanClauseDiff(argc, argv); + return cleanClauseDiff(argc, argv); else if (strcmp(argv[1], "make_words_diff") == 0) return makeWordsDiff(argc, argv);