From 2da57a4d248fe0d5728385d6b827bb67e0b53635 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 4 Nov 2016 09:09:51 +0100 Subject: [PATCH] Changed: Removed trailing spaces --- code/ryzom/tools/translation_tools/main.cpp | 316 ++++++++++---------- 1 file changed, 158 insertions(+), 158 deletions(-) diff --git a/code/ryzom/tools/translation_tools/main.cpp b/code/ryzom/tools/translation_tools/main.cpp index 8d5609d90..a5c1eb426 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 @@ -162,13 +162,13 @@ void verifyVersion(ucstring& doc, int versionId) 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 +176,7 @@ void verifyVersion(ucstring& doc, int versionId) { nlerror("Loading wrong diff version"); nlassert(0); - } + } doc = doc.substr(version2Size); break; @@ -190,7 +190,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, false, CI18N::LINE_FMT_LF); verifyVersion(doc, 1); return readPhraseFileFromString(doc, filename, phrases, forceRehash); } @@ -251,7 +251,7 @@ bool parseDiffCommandFromComment(const ucstring &comments, TDiffInfo &diffInfo) diffInfo.Command = diff_none; return false; } - + CI18N::skipWhiteSpace(it, last); // ok, parse the index. string indexStr; @@ -423,7 +423,7 @@ public: void run(const vector &addition, vector &reference, vector &diff) { TStringDiffContext context(addition, reference, diff); - + CMakeDiff differ; differ.makeDiff(this, context); } @@ -471,7 +471,7 @@ 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; context.Diff.push_back(si); } @@ -501,7 +501,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 +521,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 +564,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 +596,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 +617,7 @@ int makeStringDiff(int argc, char *argv[]) for (uint l=0; l 4 && text.substr(commentBegin-1, 1) == ucstring(":")) @@ -738,12 +738,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 +754,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); @@ -878,9 +878,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 +888,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 +925,7 @@ public: void run(const vector &addition, vector &reference, vector &diff) { TPhraseDiffContext context(addition, reference, diff); - + CMakeDiff differ; differ.makeDiff(this, context); } @@ -972,9 +972,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,12 +983,12 @@ 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; @@ -1003,7 +1003,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 +1017,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,7 +1071,7 @@ int makePhraseDiff(int argc, char *argv[]) else { LOG("Writing difference file for language %s\n", Languages[l].c_str()); - ucstring text; + ucstring text; text += "// DIFF_VERSION 1\r\n"; text += preparePhraseFile(diff, false); // add the tag for non translation @@ -1088,22 +1088,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 +1229,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 +1254,7 @@ int makeClauseDiff(int argc, char *argv[]) return -1; } mergeStringDiff(reference, Languages[l], "clause_", ".txt", false); - + vector diff; makeStringDiff(addition, reference, diff); @@ -1286,16 +1286,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); @@ -1471,7 +1471,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 +1560,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); @@ -1667,7 +1667,7 @@ int makeWorksheetDiff(int argc, char *argv[], const std::string &additionFilenam string fn(CFile::getFilenameWithoutExtension(referenceFilename)), ext(CFile::getExtension(referenceFilename)); std::string diffName(diffDir+fn+"_diff_"+diffVersion+"."+ext); CI18N::writeTextFile(diffName, str); - + } return 0; @@ -1784,7 +1784,7 @@ int mergeWordsDiff(int argc, char *argv[]) --i; } } - + // for each language for (uint l=0; l& reference) } } } - + } @@ -2052,7 +2052,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 +2067,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 +2089,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 +2112,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 +2137,7 @@ bool updateClauseHashValue(const std::map clauses[i].HashValue = validValues.find(Identifier)->second.first; removeHashValueComment(clauses[i].Comments); changed = true; - } + } } } @@ -2150,7 +2150,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); } @@ -2230,9 +2230,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 +2248,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 +2269,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 +2286,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 +2298,10 @@ bool updatePhraseHashValue(const std::map bool sortTransPhrase() { - + for (uint l=0; l phrases; vector phrases2; @@ -2312,9 +2312,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) @@ -2335,7 +2335,7 @@ bool sortTransPhrase() nlinfo("Updating hashcode of phrase file for %s.\n", 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); } @@ -2353,7 +2353,7 @@ void patchWorkFile(vector &updatedPhrase, const std::string & filename) 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 +2370,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,7 +2408,7 @@ int updatePhraseWork() transPhraseMap[first->Identifier] = *first; } } - + preprocessTextFile(addDir+"phrase_wk.txt", outputResult); uint firstFile = 0; @@ -2417,7 +2417,7 @@ int updatePhraseWork() { 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,32 +2442,32 @@ 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(""); - } + } } } } - + 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); @@ -2484,7 +2484,7 @@ 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 +2508,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 +2541,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 +2562,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 +2597,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 +2622,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 +2682,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,12 +2693,12 @@ 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; @@ -2717,8 +2717,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 +2728,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 +2740,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 +2751,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()); @@ -2851,7 +2851,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 +2859,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 +2879,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 +2891,7 @@ int forgetPhraseDiff(int argc, char *argv[]) } } } - + if (!mergePhraseDiff2(reference, Languages[0], true, false)) { @@ -2901,13 +2901,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 +2949,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 +2962,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,7 +2972,7 @@ 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(); { CIFile testFile; if (!testFile.open(subFilename)) @@ -2988,7 +2988,7 @@ void preprocessTextFile(const std::string &filename, current += line; } lastPos = pos; - + } @@ -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);