summaryrefslogtreecommitdiffstats
path: root/tools/linguist
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-06-23 10:32:42 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-06-23 10:32:42 (GMT)
commite1eceedaa635d0180eb798b00c3da93156d7af63 (patch)
tree04325155309fd225d68a4cf118be34c2378cb26a /tools/linguist
parent2c96aeb45320ade7e2c074433560185f16631374 (diff)
parent71be46c61c582d2f4635a1e420e44d57ddb5857a (diff)
downloadQt-e1eceedaa635d0180eb798b00c3da93156d7af63.zip
Qt-e1eceedaa635d0180eb798b00c3da93156d7af63.tar.gz
Qt-e1eceedaa635d0180eb798b00c3da93156d7af63.tar.bz2
Merge commit 'origin/4.5'
Conflicts: src/sql/drivers/psql/qsql_psql.cpp
Diffstat (limited to 'tools/linguist')
-rw-r--r--tools/linguist/lconvert/main.cpp8
-rw-r--r--tools/linguist/shared/qm.cpp23
2 files changed, 28 insertions, 3 deletions
diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp
index 8ecdbc2..534bc11 100644
--- a/tools/linguist/lconvert/main.cpp
+++ b/tools/linguist/lconvert/main.cpp
@@ -80,6 +80,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"
@@ -138,6 +141,7 @@ int main(int argc, char *argv[])
Translator::LocationsType locations = Translator::DefaultLocations;
ConversionData cd;
+ cd.m_codecForSource = "Latin1";
Translator tr;
for (int i = 1; i < args.size(); ++i) {
@@ -166,6 +170,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..323bd29 100644
--- a/tools/linguist/shared/qm.cpp
+++ b/tools/linguist/shared/qm.cpp
@@ -545,12 +545,20 @@ 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");
+ QString strProN = QLatin1String("%n");
+ QLocale::Language l;
+ QLocale::Country c;
+ Translator::languageAndCountry(translator.languageCode(), &l, &c);
+ QStringList numerusForms;
+ bool guessPlurals = true;
+ if (getNumerusInfo(l, c, 0, &numerusForms))
+ guessPlurals = (numerusForms.count() == 1);
+
QString context, contextUtf8;
bool contextIsSystem, contextIsUtf8, contextNeeds8Bit;
QString sourcetext, sourcetextUtf8;
@@ -635,6 +643,15 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd)
end:;
TranslatorMessage msg;
msg.setType(TranslatorMessage::Finished);
+ if (translations.count() > 1) {
+ // If guessPlurals is not false here, plural form discard messages
+ // will be spewn out later.
+ msg.setPlural(true);
+ } else if (guessPlurals) {
+ // This might cause false positives, so it is a fallback only.
+ if (sourcetext.contains(strProN))
+ msg.setPlural(true);
+ }
msg.setTranslations(translations);
translations.clear();
if (contextNeeds8Bit || sourcetextNeeds8Bit || commentNeeds8Bit) {
@@ -649,7 +666,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).