From 37d34a2f0f16ce0c50513445e2697245345412b9 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 4 Nov 2016 09:09:51 +0100 Subject: [PATCH 01/10] Changed: Removed trailing spaces --HG-- branch : develop --- 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); From b7c008c0148b669db61e82fc6e1982d2446c96a0 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 4 Nov 2016 09:14:08 +0100 Subject: [PATCH 02/10] Changed: Minor changes --HG-- branch : develop --- code/ryzom/tools/translation_tools/main.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/code/ryzom/tools/translation_tools/main.cpp b/code/ryzom/tools/translation_tools/main.cpp index a5c1eb426..3b58916b0 100644 --- a/code/ryzom/tools/translation_tools/main.cpp +++ b/code/ryzom/tools/translation_tools/main.cpp @@ -432,6 +432,7 @@ public: { // nothing to do } + void onAdd(uint addIndex, uint refIndex, TStringDiffContext &context) { TStringInfo si = context.Addition[addIndex]; @@ -442,6 +443,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 +455,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]; @@ -472,11 +475,9 @@ public: 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); } - - }; @@ -660,7 +661,7 @@ int makeStringDiff(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+Languages[l]+"_diff_"+diffVersion+".uxt"); CI18N::writeTextFile(diffName, str); @@ -991,7 +992,7 @@ public: 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); @@ -1075,7 +1076,7 @@ int makePhraseDiff(int argc, char *argv[]) text += "// DIFF_VERSION 1\r\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); } } @@ -1270,7 +1271,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); @@ -1662,7 +1663,7 @@ 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); @@ -2701,7 +2702,7 @@ void CMakePhraseDiff2::onChanged(uint addIndex, uint refIndex, TPhraseDiffContex 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); @@ -2809,7 +2810,7 @@ int makePhraseDiff2(int argc, char *argv[]) text += "// DIFF_VERSION 2\r\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); } } From 369a121aa11f1a86265172ba715fb66fe3ddfa60 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 4 Nov 2016 09:17:32 +0100 Subject: [PATCH 03/10] Fixed: Wrong size of nl --HG-- branch : develop --- code/ryzom/tools/translation_tools/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/translation_tools/main.cpp b/code/ryzom/tools/translation_tools/main.cpp index 3b58916b0..3cbaa195d 100644 --- a/code/ryzom/tools/translation_tools/main.cpp +++ b/code/ryzom/tools/translation_tools/main.cpp @@ -698,7 +698,7 @@ void cleanComment(const std::string & filename) ucstring toAdd = text.substr(last, size); newText += toAdd; ucstring::size_type commentEnd = text.find(ucstring("*/"), commentBegin); - if (commentEnd != ucstring::npos) { commentEnd += 4; } + if (commentEnd != ucstring::npos) { commentEnd += 2 + nl.size(); } last = commentEnd; ++nbOldValue; } From 9e0954fad51831bf05a9461a28913c166c193d62 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 4 Nov 2016 20:19:41 +0100 Subject: [PATCH 04/10] Changed: ForceUtf8 parameter useless now --HG-- branch : develop --- code/nel/include/nel/misc/i18n.h | 6 ++-- code/nel/src/misc/config_file/config_file.cpp | 2 +- code/nel/src/misc/diff_tool.cpp | 6 ++-- code/nel/src/misc/i18n.cpp | 8 ++--- .../tools/georges/georges2csv/georges2csv.cpp | 2 +- .../tools/leveldesign/uni_conv/uni_conv.cpp | 2 +- code/ryzom/tools/translation_tools/main.cpp | 32 +++++++++---------- 7 files changed, 27 insertions(+), 31 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/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..64d5a52c1 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); } @@ -626,7 +626,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 786060275..82f5c9a19 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -656,7 +656,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 +665,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 +708,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 +817,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 +871,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/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 3cbaa195d..6dadc8a4c 100644 --- a/code/ryzom/tools/translation_tools/main.cpp +++ b/code/ryzom/tools/translation_tools/main.cpp @@ -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, CI18N::LINE_FMT_LF); verifyVersion(doc, 1); return readPhraseFileFromString(doc, filename, phrases, forceRehash); } @@ -199,7 +199,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); } @@ -352,7 +352,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()); @@ -680,7 +680,7 @@ void cleanComment(const std::string & filename) ucstring text; 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::size_type last = 0; @@ -801,7 +801,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); } @@ -841,7 +841,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) { @@ -1165,7 +1165,7 @@ int mergePhraseDiff(int argc, char *argv[], int version) { // 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); } @@ -1334,7 +1334,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); } @@ -1359,7 +1359,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()); @@ -1692,7 +1692,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. @@ -1712,7 +1712,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)); @@ -1866,7 +1866,7 @@ void cropLines(const std::string &filename, uint32 nbLines) 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(); @@ -1911,7 +1911,7 @@ int makeWork() // change #include "*_en.txt" into #include "*_wk.txt" 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(); bool changedFile = false; @@ -2349,7 +2349,7 @@ 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) @@ -2490,7 +2490,7 @@ bool mergePhraseDiff2(vector &phrases, const string &language, bool onl { // 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, 2); if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos) { @@ -3030,7 +3030,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()); } From a2a7dfa02842f1a48af5df48d9f6fab8efa08b85 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 4 Nov 2016 20:20:39 +0100 Subject: [PATCH 05/10] Changed: Minor changes --HG-- branch : develop --- code/nel/src/misc/app_context.cpp | 1 - code/nel/src/misc/diff_tool.cpp | 1 + code/nel/src/misc/i18n.cpp | 2 ++ code/ryzom/tools/translation_tools/main.cpp | 6 ++---- 4 files changed, 5 insertions(+), 5 deletions(-) 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/diff_tool.cpp b/code/nel/src/misc/diff_tool.cpp index 64d5a52c1..cd1a74ddf 100644 --- a/code/nel/src/misc/diff_tool.cpp +++ b/code/nel/src/misc/diff_tool.cpp @@ -419,6 +419,7 @@ bool readPhraseFileFromString(ucstring const& doc, const std::string &filename, 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", diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index 82f5c9a19..b511197c8 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -516,9 +516,11 @@ void CI18N::skipWhiteSpace(ucstring::const_iterator &it, ucstring::const_iterato // 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'); diff --git a/code/ryzom/tools/translation_tools/main.cpp b/code/ryzom/tools/translation_tools/main.cpp index 6dadc8a4c..04ea60f61 100644 --- a/code/ryzom/tools/translation_tools/main.cpp +++ b/code/ryzom/tools/translation_tools/main.cpp @@ -151,8 +151,6 @@ 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"); @@ -2218,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; @@ -2340,6 +2337,7 @@ bool sortTransPhrase() CFile::createDirectoryTree( CFile::getPath(pharseName) ); CI18N::writeTextFile(pharseName, str); } + return true; } @@ -2471,7 +2469,7 @@ int updatePhraseWork() } updatePhraseHashValue(validPhraseHashValue, saveDir); - updateClauseHashValue(validClauseHashValue, saveDir); + updateClauseHashValue(validClauseHashValue, saveDir); return 0; } From 542c63f03dae5953fd77ab67b5427059a863fe8b Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 4 Nov 2016 20:21:18 +0100 Subject: [PATCH 06/10] Changed: Only put a space if several conditions --HG-- branch : develop --- code/nel/src/misc/diff_tool.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/nel/src/misc/diff_tool.cpp b/code/nel/src/misc/diff_tool.cpp index cd1a74ddf..2b2a490bc 100644 --- a/code/nel/src/misc/diff_tool.cpp +++ b/code/nel/src/misc/diff_tool.cpp @@ -416,7 +416,11 @@ 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); } From 9f934f77657bab1a811a495fde7f6a55d3ea70ae Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 4 Nov 2016 20:22:10 +0100 Subject: [PATCH 07/10] Changed: Discard \r and only use \n --HG-- branch : develop --- code/nel/src/misc/i18n.cpp | 22 ++++++++++++++++----- code/ryzom/tools/translation_tools/main.cpp | 8 ++++---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index b511197c8..f61bcddf6 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -502,17 +502,30 @@ 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++); @@ -522,7 +535,6 @@ void CI18N::skipWhiteSpace(ucstring::const_iterator &it, ucstring::const_iterato storeComments->push_back(*it++); // and a new line. - storeComments->push_back('\r'); storeComments->push_back('\n'); } else diff --git a/code/ryzom/tools/translation_tools/main.cpp b/code/ryzom/tools/translation_tools/main.cpp index 04ea60f61..456cd871e 100644 --- a/code/ryzom/tools/translation_tools/main.cpp +++ b/code/ryzom/tools/translation_tools/main.cpp @@ -153,9 +153,9 @@ void showUsage(char *exeName) 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) @@ -1071,7 +1071,7 @@ int makePhraseDiff(int argc, char *argv[]) { LOG("Writing difference file for language %s\n", Languages[l].c_str()); ucstring text; - text += "// DIFF_VERSION 1\r\n"; + 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; @@ -2805,7 +2805,7 @@ 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; From 589be3bbbb5afadd80b93245985995f6f843a947 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 4 Nov 2016 20:22:42 +0100 Subject: [PATCH 08/10] Changed: Don't display an error if file doesn't exist --HG-- branch : develop --- code/ryzom/tools/translation_tools/main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/code/ryzom/tools/translation_tools/main.cpp b/code/ryzom/tools/translation_tools/main.cpp index 456cd871e..906fe6bd6 100644 --- a/code/ryzom/tools/translation_tools/main.cpp +++ b/code/ryzom/tools/translation_tools/main.cpp @@ -2972,12 +2972,16 @@ void preprocessTextFile(const std::string &filename, ucstring name = line.substr(firstFilename +1, lastFilename - firstFilename -1); 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); From a9c3982d21ab2cf7fa6ba1bcc6a0cc0b3f31a7af Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 4 Nov 2016 20:23:01 +0100 Subject: [PATCH 09/10] Changed: Minor changes --HG-- branch : develop --- code/ryzom/tools/translation_tools/main.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/code/ryzom/tools/translation_tools/main.cpp b/code/ryzom/tools/translation_tools/main.cpp index 906fe6bd6..aacfe41f1 100644 --- a/code/ryzom/tools/translation_tools/main.cpp +++ b/code/ryzom/tools/translation_tools/main.cpp @@ -2329,8 +2329,7 @@ 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); @@ -2414,7 +2413,6 @@ int updatePhraseWork() uint lastFile = (uint)outputResult.size(); for (; firstFile != lastFile ; ++firstFile) { - ucstring doc = outputResult[firstFile].first; std::vector phrases; readPhraseFileFromString(outputResult[firstFile].first, outputResult[firstFile].second, phrases, true); @@ -2446,7 +2444,7 @@ int updatePhraseWork() firstClause->HashValue = clauseHashValue; } updatedPhrases.push_back(transPhrase); - updatedPhrases.back().Comments= ucstring(""); + updatedPhrases.back().Comments.clear(); } } } @@ -2984,6 +2982,7 @@ void preprocessTextFile(const std::string &filename, subFilename.clear(); } } + preprocessTextFile(subFilename, outputResult); } else @@ -2994,8 +2993,6 @@ void preprocessTextFile(const std::string &filename, } - - outputResult.push_back( std::pair ( current, fullName ) ); } From f9117d8e94bbe19bced69b9e23955905cc240abe Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 5 Nov 2016 19:46:12 +0100 Subject: [PATCH 10/10] Changed: Rerun Installer from a specific directory with right arguments --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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