summaryrefslogtreecommitdiffstats
path: root/tools/linguist/shared/qm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/linguist/shared/qm.cpp')
-rw-r--r--tools/linguist/shared/qm.cpp23
1 files changed, 20 insertions, 3 deletions
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).