Browse Source

feat(i18n): Handle English plural forms in translations

Special case that only needs plurals translated.
reviewable/pr6490/r8
Anthony Bilinski 3 years ago
parent
commit
0cb222c056
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 32
      src/widget/translator.cpp
  2. 5
      tools/update-translation-files.sh
  3. 1
      translations/CMakeLists.txt
  4. 1
      translations/README.md
  5. 57
      translations/en.ts
  6. 1
      translations/i18n.pri
  7. 1
      translations/translations.qrc

32
src/widget/translator.cpp

@ -53,25 +53,23 @@ void Translator::translate(const QString& localeName) @@ -53,25 +53,23 @@ void Translator::translate(const QString& localeName)
// Load translations
QString locale = localeName.isEmpty() ? QLocale::system().name().section('_', 0, 0) : localeName;
if (locale != "en") {
if (core_translator->load(locale, ":translations/")) {
qDebug() << "Loaded translation" << locale;
// System menu translation
QString s_locale = "qt_" + locale;
QString location = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
if (app_translator->load(s_locale, location)) {
QApplication::installTranslator(app_translator);
qDebug() << "System translation loaded" << locale;
} else {
qDebug() << "System translation not loaded" << locale;
}
// Application translation
QCoreApplication::installTranslator(core_translator);
if (core_translator->load(locale, ":translations/")) {
qDebug() << "Loaded translation" << locale;
// System menu translation
QString s_locale = "qt_" + locale;
QString location = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
if (app_translator->load(s_locale, location)) {
QApplication::installTranslator(app_translator);
qDebug() << "System translation loaded" << locale;
} else {
qDebug() << "Error loading translation" << locale;
qDebug() << "System translation not loaded" << locale;
}
// Application translation
QCoreApplication::installTranslator(core_translator);
} else {
qDebug() << "Error loading translation" << locale;
}
// After the language is changed from RTL to LTR, the layout direction isn't

5
tools/update-translation-files.sh

@ -27,14 +27,15 @@ @@ -27,14 +27,15 @@
set -eu -o pipefail
readonly LUPDATE_CMD="lupdate src -no-obsolete -locations none -ts"
readonly LUPDATE_CMD="lupdate src -no-obsolete -locations none"
if [[ "$@" = "ALL" ]]
then
for translation in translations/*.ts
do
$LUPDATE_CMD "$translation"
$LUPDATE_CMD -ts "$translation"
done
$LUPDATE_CMD -pluralonly -ts translations/en.ts
else
$LUPDATE_CMD "$@"
fi

1
translations/CMakeLists.txt vendored

@ -24,6 +24,7 @@ qt5_add_translation(translations_FILES @@ -24,6 +24,7 @@ qt5_add_translation(translations_FILES
da.ts
de.ts
el.ts
en.ts
eo.ts
es.ts
et.ts

1
translations/README.md vendored

@ -16,6 +16,7 @@ Language | Status @@ -16,6 +16,7 @@ Language | Status
[Deutsch](https://hosted.weblate.org/engage/tox/de/) | [![Translation status](https://hosted.weblate.org/widgets/tox/de/svg-badge.svg)](https://hosted.weblate.org/engage/tox/de/?utm_source=widget)
[Eesti](https://hosted.weblate.org/engage/tox/et/) | [![Translation status](https://hosted.weblate.org/widgets/tox/et/svg-badge.svg)](https://hosted.weblate.org/engage/tox/et/?utm_source=widget)
[Ελληνικά](https://hosted.weblate.org/engage/tox/el/) | [![Translation status](https://hosted.weblate.org/widgets/tox/el/svg-badge.svg)](https://hosted.weblate.org/engage/tox/el/?utm_source=widget)
[English](https://hosted.weblate.org/engage/tox/en/) | [![Translation status](https://hosted.weblate.org/widgets/tox/en/svg-badge.svg)](https://hosted.weblate.org/engage/tox/en/?utm_source=widget)
[Español](https://hosted.weblate.org/engage/tox/es/) | [![Translation status](https://hosted.weblate.org/widgets/tox/es/svg-badge.svg)](https://hosted.weblate.org/engage/tox/es/?utm_source=widget)
[Esperanto](https://hosted.weblate.org/engage/tox/eo/) | [![Translation status](https://hosted.weblate.org/widgets/tox/eo/svg-badge.svg)](https://hosted.weblate.org/engage/tox/eo/?utm_source=widget)
[فارسی](https://hosted.weblate.org/engage/tox/fa/) | [![Translation status](https://hosted.weblate.org/widgets/tox/fa/svg-badge.svg)](https://hosted.weblate.org/engage/tox/fa/?utm_source=widget)

57
translations/en.ts vendored

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>AddFriendForm</name>
<message numerus="yes">
<source>Ready to import %n contact(s), click send to confirm</source>
<translation type="unfinished">
<numerusform></numerusform>
</translation>
</message>
</context>
<context>
<name>GroupChatForm</name>
<message numerus="yes">
<source>%n user(s) in chat</source>
<comment>Number of users in chat</comment>
<translation type="unfinished">
<numerusform></numerusform>
</translation>
</message>
</context>
<context>
<name>GroupWidget</name>
<message numerus="yes">
<source>%n user(s) in chat</source>
<comment>Number of users in chat</comment>
<translation type="unfinished">
<numerusform></numerusform>
</translation>
</message>
</context>
<context>
<name>NotificationEdgeWidget</name>
<message numerus="yes">
<source>Unread message(s)</source>
<translation type="unfinished">
<numerusform></numerusform>
</translation>
</message>
</context>
<context>
<name>Widget</name>
<message numerus="yes">
<source>%n new friend request(s)</source>
<translation type="unfinished">
<numerusform></numerusform>
</translation>
</message>
<message numerus="yes">
<source>%n new group invite(s)</source>
<translation type="unfinished">
<numerusform></numerusform>
</translation>
</message>
</context>
</TS>

1
translations/i18n.pri vendored

@ -9,6 +9,7 @@ TRANSLATIONS = \ @@ -9,6 +9,7 @@ TRANSLATIONS = \
translations/da.ts \
translations/de.ts \
translations/el.ts \
translations/en.ts \
translations/eo.ts \
translations/es.ts \
translations/et.ts \

1
translations/translations.qrc vendored

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
<file>da.qm</file>
<file>de.qm</file>
<file>el.qm</file>
<file>en.qm</file>
<file>eo.qm</file>
<file>es.qm</file>
<file>et.qm</file>

Loading…
Cancel
Save