diff --git a/libs/main/application/pisystemmonitor.cpp b/libs/main/application/pisystemmonitor.cpp index 522df17b..98a5e428 100644 --- a/libs/main/application/pisystemmonitor.cpp +++ b/libs/main/application/pisystemmonitor.cpp @@ -19,13 +19,14 @@ #include "pisystemmonitor.h" -#include - #include "pidir.h" #include "piliterals_string.h" #include "piprocess.h" #include "pisysteminfo.h" #include "pitime_win.h" +#include "pitranslator.h" + +#include #ifdef WINDOWS # include # include @@ -114,7 +115,7 @@ bool PISystemMonitor::startOnProcess(int pID, PISystemTime interval) { # else PRIVATE->hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pID_); if (PRIVATE->hProc == 0) { - piCoutObj << "Can`t open process with ID = " << pID_ << "," << errorString(); + piCoutObj << "Can`t open process with ID = "_tr << pID_ << "," << errorString(); return false; } PRIVATE->tm.reset(); diff --git a/main.cpp b/main.cpp index 9634f88f..49821cc7 100644 --- a/main.cpp +++ b/main.cpp @@ -23,16 +23,12 @@ int main(int argc, char * argv[]) { // piCout << PIString::readableSize(50_KiB); // piCout << PIString::readableSize(1_GB); PITranslator::loadLang("ru"); - PITranslator::loadConfig("[C]\ntest string=\n"_u8); - piCout << "test string1"; - piCout << "test string2"_tr; - piCout << piTr("test string", "C1"); + PITranslator::loadConfig("[]\ntest \\\nstring=привет\n"_u8); + piCout << "test\nstring"_tr; PITranslator::clear(); - piCout << "test string3"; - piCout << "test string4"_tr; - piCout << piTr("test string", "C2"); - // PICodeParser parser; - // parser.parseFile("cmg_test.h"); + piCout << "test\nstring"_tr; + // PICodeParser parser; + // parser.parseFile("cmg_test.h"); /*for (auto m: parser.macros) { piCout << ""; piCout << m.name << m.args << m.value; diff --git a/utils/qt_support/ts_file.cpp b/utils/qt_support/ts_file.cpp index f3a26192..281bf26e 100644 --- a/utils/qt_support/ts_file.cpp +++ b/utils/qt_support/ts_file.cpp @@ -71,9 +71,26 @@ TSFile::Content TSFile::read(const PIString & path) { PIIOTextStream ts(&f); Context * cc = nullptr; Message msg; - int phase = 0; + int phase = 0; + bool multi_source = false, multi_translation = false; while (!ts.isEnd()) { auto line = ts.readLine().trim(); + if (multi_source) { + if (line.endsWith("")) { + line.cutRight(9); + multi_source = false; + } + msg.source += "\n" + unmask(line); + continue; + } + if (multi_translation) { + if (line.endsWith("")) { + line.cutRight(14); + multi_translation = false; + } + msg.translation += "\n" + unmask(line); + continue; + } switch (phase) { case 0: if (line == "") phase = 1; @@ -97,7 +114,11 @@ TSFile::Content TSFile::read(const PIString & path) { if (cc) cc->messages[msg.source] = msg; phase = 2; } else if (line.startsWith("")) { - line.cutLeft(8).cutRight(9); + line.cutLeft(8); + if (line.endsWith("")) + line.cutRight(9); + else + multi_source = true; msg.source = unmask(line); } else if (line.startsWith("').cutLeft(8); @@ -117,7 +138,10 @@ TSFile::Content TSFile::read(const PIString & path) { PIString v = trs.takeRange('\"', '\"'); if (t == "type") msg.type = v; } - line.cutRight(14); + if (line.endsWith("")) + line.cutRight(14); + else + multi_translation = true; msg.translation = unmask(line); } break; diff --git a/utils/translator/main.cpp b/utils/translator/main.cpp index 819a521d..050dce55 100644 --- a/utils/translator/main.cpp +++ b/utils/translator/main.cpp @@ -68,6 +68,11 @@ void help() { } +PIString fromCode(const PIString & in) { + return in.replacedAll("\\n", '\n').replaceAll("\\r", '\r').replaceAll("\\t", '\t'); +} + + void gatherStrings(TSFile::Content & content, const PIString & file, const PIString & file_loc) { PIString source, context; int pos = -1, ppos = 0, line = -1; @@ -129,14 +134,13 @@ void gatherStrings(TSFile::Content & content, const PIString & file, const PIStr } } - content[context].confirm(source, file_loc, line); + content[context].confirm(fromCode(source), file_loc, line); pos = ppos; piCout << "Context = \"" << context << "\", message = \"" << source << "\""; } } auto & ec(content[""]); - content[context].confirm(source, file_loc, line); pos = -1; for (;;) { source.clear(); @@ -156,7 +160,7 @@ void gatherStrings(TSFile::Content & content, const PIString & file, const PIStr continue; } } - ec.confirm(source, file_loc, file.lineNumber(pos)); + ec.confirm(fromCode(source), file_loc, file.lineNumber(pos)); piCout << "_tr = \"" << source << "\""; } } @@ -186,7 +190,7 @@ int main(int argc, char * argv[]) { PIString out_path = cli.argumentValue("output"); PIStringList files; - const static PIStringList ext({"*.h", "*.hpp", "*.cpp", "*.cxx"}); + const static PIStringList ext({"h", "hpp", "cpp", "cxx"}); for (const PIString & a: cli.optionalArguments()) { if (PIDir::isExists(a)) { auto dl = PIDir(a).allEntries();