diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-06-23 09:37:48 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-06-23 09:44:17 (GMT) |
commit | d710a09bd26728a78963e6ad464540daea46f6a4 (patch) | |
tree | fd4f3b13976993fdf1272c87e7ab4f81986e451b /tools/linguist | |
parent | 29f5f6eeae00fc0890a171398f6717bc543dff38 (diff) | |
download | Qt-d710a09bd26728a78963e6ad464540daea46f6a4.zip Qt-d710a09bd26728a78963e6ad464540daea46f6a4.tar.gz Qt-d710a09bd26728a78963e6ad464540daea46f6a4.tar.bz2 |
mark plural messages as such in the qm reader
this contains both a "clean" code path based on translation count and a
fallback path based on looking for "%n" (for languages with only one
form).
Diffstat (limited to 'tools/linguist')
-rw-r--r-- | tools/linguist/shared/qm.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index c6f3602..323bd29 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -550,6 +550,15 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) 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; @@ -634,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) { |