diff options
Diffstat (limited to 'tools/linguist/lconvert')
-rw-r--r-- | tools/linguist/lconvert/main.cpp | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index 9d8a644..52a3e56 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -51,21 +51,16 @@ static int usage(const QStringList &args) Q_UNUSED(args); QString loaders; - QString savers; - QString line = QString(QLatin1String(" %1 - %2\n")); - foreach (Translator::FileFormat format, Translator::registeredFileFormats()) { + QString line(QLatin1String(" %1 - %2\n")); + foreach (Translator::FileFormat format, Translator::registeredFileFormats()) loaders += line.arg(format.extension, -5).arg(format.description); - if (format.fileType != Translator::FileFormat::SourceCode) - savers += line.arg(format.extension, -5).arg(format.description); - } qWarning("%s", qPrintable(QString(QLatin1String("\nUsage:\n" " lconvert [options] <infile> [<infile>...]\n\n" "lconvert is part of Qt's Linguist tool chain. It can be used as a\n" - "stand-alone tool to convert translation data files from one of the\n" - "following input formats\n\n%1\n" - "to one of the following output formats\n\n%2\n" - "If multiple input files are specified the translations are merged with\n" + "stand-alone tool to convert and filter translation data files.\n" + "The following file formats are supported:\n\n%1\n" + "If multiple input files are specified, they are merged with\n" "translations from later files taking precedence.\n\n" "Options:\n" " -h\n" @@ -86,20 +81,20 @@ static int usage(const QStringList &args) " --output-format <outformat>\n" " Specify output format. See -if.\n\n" " --input-codec <codec>\n" - " Specify encoding for .qm and .po input files. Default is 'Latin1'\n" - " for .qm and 'UTF-8' for .po files. UTF-8 is always tried as well for\n" - " .qm, corresponding to the possible use of the trUtf8() function.\n\n" + " Specify encoding for QM and PO input files. Default is 'Latin1'\n" + " for QM and 'UTF-8' for PO files. UTF-8 is always tried as well for\n" + " QM, corresponding to the possible use of the trUtf8() function.\n\n" " --output-codec <codec>\n" - " Specify encoding for .po output files. Default is 'UTF-8'.\n\n" + " Specify encoding for PO output files. Default is 'UTF-8'.\n\n" " --drop-tags <regexp>\n" - " Drop named extra tags when writing 'ts' or 'xlf' files.\n" + " Drop named extra tags when writing TS or XLIFF files.\n" " May be specified repeatedly.\n\n" " --drop-translations\n" " Drop existing translations and reset the status to 'unfinished'.\n" " Note: this implies --no-obsolete.\n\n" " --source-language <language>[_<region>]\n" " Specify/override the language of the source strings. Defaults to\n" - " POSIX if not specified and the file does not name it yet.\n" + " POSIX if not specified and the file does not name it yet.\n\n" " --target-language <language>[_<region>]\n" " Specify/override the language of the translation.\n" " The target language is guessed from the file name if this option\n" @@ -108,6 +103,11 @@ static int usage(const QStringList &args) " Drop obsolete messages.\n\n" " --no-finished\n" " Drop finished messages.\n\n" + " --locations {absolute|relative|none}\n" + " Override how source code references are saved in TS files.\n" + " Default is absolute.\n\n" + " --no-ui-lines\n" + " Drop line numbers from references to UI files.\n\n" " --verbose\n" " be a bit more verbose\n\n" "Long options can be specified with only one leading dash, too.\n\n" @@ -115,7 +115,7 @@ static int usage(const QStringList &args) " 0 on success\n" " 1 on command line parse failures\n" " 2 on read failures\n" - " 3 on write failures\n")).arg(loaders).arg(savers))); + " 3 on write failures\n")).arg(loaders))); return 1; } @@ -140,6 +140,8 @@ int main(int argc, char *argv[]) bool noObsolete = false; bool noFinished = false; bool verbose = false; + bool noUiLines = false; + Translator::LocationsType locations = Translator::DefaultLocations; ConversionData cd; Translator tr; @@ -199,6 +201,19 @@ int main(int argc, char *argv[]) noObsolete = true; } else if (args[i] == QLatin1String("-no-finished")) { noFinished = true; + } else if (args[i] == QLatin1String("-locations")) { + if (++i >= args.size()) + return usage(args); + if (args[i] == QLatin1String("none")) + locations = Translator::NoLocations; + else if (args[i] == QLatin1String("relative")) + locations = Translator::RelativeLocations; + else if (args[i] == QLatin1String("absolute")) + locations = Translator::AbsoluteLocations; + else + return usage(args); + } else if (args[i] == QLatin1String("-no-ui-lines")) { + noUiLines = true; } else if (args[i] == QLatin1String("-verbose")) { verbose = true; } else if (args[i].startsWith(QLatin1Char('-'))) { @@ -243,6 +258,10 @@ int main(int argc, char *argv[]) tr.stripFinishedMessages(); if (dropTranslations) tr.dropTranslations(); + if (noUiLines) + tr.dropUiLines(); + if (locations != Translator::DefaultLocations) + tr.setLocationsType(locations); tr.normalizeTranslations(cd); if (!cd.errors().isEmpty()) { |