diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-10-07 05:53:25 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-10-07 05:53:25 (GMT) |
commit | af9d77acbf1dc80308df00526163d905e9b22421 (patch) | |
tree | 3ae8be23b73500d6652fa26e365a7817e5909b6a | |
parent | 7f3cd2949ccb16b1b611c05bf6ab7274cf04a0f8 (diff) | |
parent | 6086364d30ea2a4bef4d4f8f2c1bfb8f113ae233 (diff) | |
download | Qt-af9d77acbf1dc80308df00526163d905e9b22421.zip Qt-af9d77acbf1dc80308df00526163d905e9b22421.tar.gz Qt-af9d77acbf1dc80308df00526163d905e9b22421.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
purge "Translation Rules for Plurals"
add -list-languages option to lupdate
-rw-r--r-- | doc/src/internationalization/i18n.qdoc | 57 | ||||
-rw-r--r-- | tools/linguist/lupdate/main.cpp | 3 | ||||
-rw-r--r-- | tools/linguist/shared/numerus.cpp | 23 | ||||
-rw-r--r-- | tools/linguist/shared/translator.h | 2 |
4 files changed, 31 insertions, 54 deletions
diff --git a/doc/src/internationalization/i18n.qdoc b/doc/src/internationalization/i18n.qdoc index 2abc286..f706623 100644 --- a/doc/src/internationalization/i18n.qdoc +++ b/doc/src/internationalization/i18n.qdoc @@ -514,7 +514,6 @@ \ingroup internationalization \previouspage Internationalization with Qt \contentspage Internationalization with Qt - \nextpage Translation Rules for Plurals \brief How to write source code in a way that makes it possible for user-visible text to be translated. \tableofcontents @@ -700,8 +699,8 @@ set using QLocale::setDefault(). (If no default locale was specified, the "C" locale is used.) - A summary of the rules used to translate strings containing plurals can be - found in the \l{Translation Rules for Plurals} document. + A summary of supported languages and the rules used to translate strings + containing plurals can be obtained by running \tt{lupdate -list-languages}. \section1 Enabling Translation @@ -717,55 +716,5 @@ \section1 Further Reading - \l{Qt Linguist Manual}, \l{Hello tr() Example}, \l{Translation Rules for Plurals} -*/ - -/*! - \page i18n-plural-rules.html - \title Translation Rules for Plurals - \ingroup internationalization - \previouspage Writing Source Code for Translation - \contentspage Internationalization with Qt - \brief A summary of the translation rules for plurals produced by Qt's i18n tools. - - The table below shows the specific rules that are produced by Qt Linguist - and \c lrelease for a selection of languages. Cells marked \e otherwise - indicate the form used when none of the other rules are appropriate for a - specific language. - - \table 80% - \header \o Language \o Rule 1 \o Rule 2 \o Rule 3 - \row \o English \o \c{n == 1} - \o \e{otherwise} \o N/A - \row \o French \o \c{n < 2} - \o \e{otherwise} \o N/A - \row \o Czech \o \c{n % 100 == 1} - \o \c{n % 100 >= 2 && n % 100 <= 4} - \o \e{otherwise} - \row \o Irish \o \c{n == 1} - \o \c{n == 2} \o \e{otherwise} - \row \o Latvian \o \c{n % 10 == 1&& n % 100 != 11} - \o \c{n != 0} \o \e{otherwise} - \row \o Lithuanian \o \c{n % 10 == 1&& n % 100 != 11} - \o \c{n % 100 != 12 && n % 10 == 2} - \o \e{otherwise} - \row \o Macedonian \o \c{n % 10 == 1} - \o \c{n % 10 == 2} \o \e{otherwise} - \row \o Polish \o \c{n == 1} - \o \c{n % 10 >= 2 && n % 10 <= 4 - && (n % 100 < 10 || n % 100 > 20)} - \o \e{otherwise} - \row \o Romanian \o \c{n == 1} - \o \c{n == 0|| (n % 100 >= 1 && n % 100 <= 20)} - \o \e{otherwise} - \row \o Russian \o \c{n % 10 == 1&& n % 100 != 11} - \o \c{n % 10 >= 2 && n % 10 <= 4 - && (n % 100 < 10 || n % 100 > 20)} - \o \e{otherwise} - \row \o Slovak \o \c{n == 1} \o \c{n >= 2 && n <= 4} - \o \e{otherwise} - \row \o Japanese \o \e{otherwise} \o N/A \o N/A - \endtable - - The rules themselves are not documented and are internal to Qt Linguist and \c lrelease. + \l{Qt Linguist Manual}, \l{Hello tr() Example} */ diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index ab88083..7337732 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -508,6 +508,9 @@ int main(int argc, char **argv) || arg == QLatin1String("-h")) { printUsage(); return 0; + } else if (arg == QLatin1String("-list-languages")) { + printOut(getNumerusInfoString()); + return 0; } else if (arg == QLatin1String("-pluralonly")) { options |= PluralOnly; continue; diff --git a/tools/linguist/shared/numerus.cpp b/tools/linguist/shared/numerus.cpp index 87f3aee..1ab300c 100644 --- a/tools/linguist/shared/numerus.cpp +++ b/tools/linguist/shared/numerus.cpp @@ -394,4 +394,27 @@ bool getNumerusInfo(QLocale::Language language, QLocale::Country country, return false; } +QString getNumerusInfoString() +{ + QStringList langs; + + for (int i = 0; i < NumerusTableSize; ++i) { + const NumerusTableEntry &entry = numerusTable[i]; + for (int j = 0; entry.languages[j] != EOL; ++j) { + QLocale loc(entry.languages[j], entry.countries ? entry.countries[j] : QLocale::AnyCountry); + QString lang = QLocale::languageToString(entry.languages[j]); + if (loc.language() == QLocale::C) + lang += QLatin1String(" (!!!)"); + else if (entry.countries && entry.countries[j] != QLocale::AnyCountry) + lang += QLatin1String(" (") + QLocale::countryToString(loc.country()) + QLatin1Char(')'); + else + lang += QLatin1String(" [") + QLocale::countryToString(loc.country()) + QLatin1Char(']'); + langs << QString::fromLatin1("%1 %2 %3\n").arg(lang, -40).arg(loc.name(), -8) + .arg(QString::fromLatin1(entry.gettextRules)); + } + } + langs.sort(); + return langs.join(QString()); +} + QT_END_NAMESPACE diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 3b7bd64..d0da527 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -254,6 +254,8 @@ private: bool getNumerusInfo(QLocale::Language language, QLocale::Country country, QByteArray *rules, QStringList *forms, const char **gettextRules); +QString getNumerusInfoString(); + bool saveQM(const Translator &translator, QIODevice &dev, ConversionData &cd); /* |