diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-06-23 09:36:03 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-06-23 09:44:08 (GMT) |
commit | 29f5f6eeae00fc0890a171398f6717bc543dff38 (patch) | |
tree | b5d810486f1dbb169217e752f86b490e4f7036bb /tools | |
parent | 59725e0074541ae18868cc9a9922f8a2e1a8b8df (diff) | |
download | Qt-29f5f6eeae00fc0890a171398f6717bc543dff38.zip Qt-29f5f6eeae00fc0890a171398f6717bc543dff38.tar.gz Qt-29f5f6eeae00fc0890a171398f6717bc543dff38.tar.bz2 |
add -input-codec option for qm reader
basing the input codec on the locale was broken by design and didn't
really work anyway. so adding this option really is a bugfix, kind of.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/linguist/lconvert/main.cpp | 8 | ||||
-rw-r--r-- | tools/linguist/shared/qm.cpp | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index 336bf31..ddde578 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -85,6 +85,9 @@ static int usage(const QStringList &args) " -of <outformat>\n" " --output-format <outformat>\n" " Specify output format. See -if.\n\n" + " --input-codec <codec>\n" + " Specify encoding for .qm input files. Default is 'Latin1'.\n" + " UTF-8 is always tried as well, corresponding to the trUtf8() function.\n\n" " --drop-tags <regexp>\n" " Drop named extra tags when writing 'ts' or 'xlf' files.\n" " May be specified repeatedly.\n\n" @@ -136,6 +139,7 @@ int main(int argc, char *argv[]) bool verbose = false; ConversionData cd; + cd.m_codecForSource = "Latin1"; Translator tr; for (int i = 1; i < args.size(); ++i) { @@ -164,6 +168,10 @@ int main(int argc, char *argv[]) if (++i >= args.size()) return usage(args); inFormat = args[i]; + } else if (args[i] == QLatin1String("-input-codec")) { + if (++i >= args.size()) + return usage(args); + cd.m_codecForSource = args[i].toLatin1(); } else if (args[i] == QLatin1String("-drop-tag")) { if (++i >= args.size()) return usage(args); diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index 14f4c2c..c6f3602 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -545,8 +545,7 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) size_t numItems = offsetLength / (2 * sizeof(quint32)); //qDebug() << "NUMITEMS: " << numItems; - // FIXME: that's just a guess, the original locale data is lost... - QTextCodec *codec = QTextCodec::codecForLocale(); + QTextCodec *codec = QTextCodec::codecForName(cd.m_codecForSource); QTextCodec *utf8Codec = 0; if (codec->name() != "UTF-8") utf8Codec = QTextCodec::codecForName("UTF-8"); @@ -649,7 +648,7 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) } if (!(contextIsSystem && sourcetextIsSystem && commentIsSystem)) { cd.appendError(QLatin1String( - "Cannot read file with current system character codec")); + "Cannot read file with specified input codec")); return false; } // The message is 8-bit in the file's encoding (utf-8 or not). |