From db07b8b18f3ca7bcfd8ce7949b646417da4544f2 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 1 Aug 2023 05:07:04 +0000 Subject: [PATCH] implement -fuzzy and -obsolete options for trc tool -fuzzy to be used (potentially) by Katana Signed-off-by: Ivailo Monev --- src/tools/moc/moc.1 | 2 +- src/tools/qdbus/qdbus.1 | 2 +- src/tools/qdbus/qdbuscpp2xml.1 | 2 +- src/tools/qdbus/qdbusxml2cpp.1 | 2 +- src/tools/qscript/qscript.1 | 2 +- src/tools/trc/trc.1 | 12 ++++++++++-- src/tools/trc/trc.pod | 8 ++++++++ src/tools/trc/trcmain.cpp | 18 +++++++++++++++++- src/tools/uic/uic.1 | 2 +- 9 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/tools/moc/moc.1 b/src/tools/moc/moc.1 index e9f38da39..9b73c74a7 100644 --- a/src/tools/moc/moc.1 +++ b/src/tools/moc/moc.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) +.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== diff --git a/src/tools/qdbus/qdbus.1 b/src/tools/qdbus/qdbus.1 index f6e1f2a2c..401fff9a8 100644 --- a/src/tools/qdbus/qdbus.1 +++ b/src/tools/qdbus/qdbus.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) +.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== diff --git a/src/tools/qdbus/qdbuscpp2xml.1 b/src/tools/qdbus/qdbuscpp2xml.1 index 5a3cabc09..4379fb3c8 100644 --- a/src/tools/qdbus/qdbuscpp2xml.1 +++ b/src/tools/qdbus/qdbuscpp2xml.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) +.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== diff --git a/src/tools/qdbus/qdbusxml2cpp.1 b/src/tools/qdbus/qdbusxml2cpp.1 index 4d16676db..055865791 100644 --- a/src/tools/qdbus/qdbusxml2cpp.1 +++ b/src/tools/qdbus/qdbusxml2cpp.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) +.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== diff --git a/src/tools/qscript/qscript.1 b/src/tools/qscript/qscript.1 index 8edb7efbe..5b8433bfb 100644 --- a/src/tools/qscript/qscript.1 +++ b/src/tools/qscript/qscript.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) +.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== diff --git a/src/tools/trc/trc.1 b/src/tools/trc/trc.1 index 1500b1dd2..ecf8ee02c 100644 --- a/src/tools/trc/trc.1 +++ b/src/tools/trc/trc.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) +.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== @@ -71,7 +71,7 @@ .\" ======================================================================== .\" .IX Title "TRC 1" -.TH TRC 1 "2022-11-21" "Katie 4.13.0" "Katie Manual" +.TH TRC 1 "2023-08-01" "Katie 4.13.0" "Katie Manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -87,6 +87,14 @@ trc reads a program translation (.po) file and creates corresponding .tr file. .SH "OPTIONS" .IX Header "OPTIONS" .Vb 3 +\& \-f +\& \-fuzzy +\& Process fuzzy translations. +\& +\& \-b +\& \-obsolete +\& Process obsolete translations. +\& \& \-h \& \-help \& Display this help and exit. diff --git a/src/tools/trc/trc.pod b/src/tools/trc/trc.pod index 3980b0b0f..49e03af53 100644 --- a/src/tools/trc/trc.pod +++ b/src/tools/trc/trc.pod @@ -12,6 +12,14 @@ trc reads a program translation (.po) file and creates corresponding .tr file. =head1 OPTIONS + -f + -fuzzy + Process fuzzy translations. + + -b + -obsolete + Process obsolete translations. + -h -help Display this help and exit. diff --git a/src/tools/trc/trcmain.cpp b/src/tools/trc/trcmain.cpp index 74fb93ce9..7f6388867 100644 --- a/src/tools/trc/trcmain.cpp +++ b/src/tools/trc/trcmain.cpp @@ -89,6 +89,12 @@ void showHelp() fprintf(stderr, "Usage:\n" " trc [options] \n\n" "Options:\n" + " -f\n" + " -fuzzy\n" + " Process fuzzy translations.\n\n" + " -b\n" + " -obsolete\n" + " Process obsolete translations.\n\n" " -h\n" " -help\n" " Display this help and exit.\n\n" @@ -105,6 +111,8 @@ int runTrc(int argc, char *argv[]) QString outputfilepath; int arg = 1; + bool fuzzy = false; + bool obsolete = false; while (arg < argc) { const QString opt = QString::fromLocal8Bit(argv[arg]); if (opt == QLatin1String("-h") || opt == QLatin1String("-help")) { @@ -113,6 +121,10 @@ int runTrc(int argc, char *argv[]) } else if (opt == QLatin1String("-v") || opt == QLatin1String("-version")) { fprintf(stderr, "Katie Translation Compiler version %s\n", QT_VERSION_STR); return 0; + } else if (opt == QLatin1String("-f") || opt == QLatin1String("-fuzzy")) { + fuzzy = true; + } else if (opt == QLatin1String("-b") || opt == QLatin1String("-obsolete")) { + obsolete = true; } else if (opt == QLatin1String("-o") || opt == QLatin1String("-output")) { ++arg; if (!argv[arg]) { @@ -165,7 +177,11 @@ int runTrc(int argc, char *argv[]) po_message_iterator_t gettext_iterator = po_message_iterator(gettext_file, NULL); po_message_t gettext_message = po_next_message(gettext_iterator); while (gettext_message != NULL) { - if (po_message_is_obsolete(gettext_message) || po_message_is_fuzzy(gettext_message)) { + if (po_message_is_obsolete(gettext_message) && !obsolete) { + gettext_message = po_next_message(gettext_iterator); + continue; + } + if (po_message_is_fuzzy(gettext_message) && !fuzzy) { gettext_message = po_next_message(gettext_iterator); continue; } diff --git a/src/tools/uic/uic.1 b/src/tools/uic/uic.1 index 45700bb07..eba906c50 100644 --- a/src/tools/uic/uic.1 +++ b/src/tools/uic/uic.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) +.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== -- 2.11.0