feat(i18n): Handle English plural forms in translations

Special case that only needs plurals translated.
reviewable/pr6490/r8
Anthony Bilinski 2022-02-21 04:37:55 -08:00
parent b05c069dfe
commit 0cb222c056
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
7 changed files with 78 additions and 18 deletions

View File

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

View File

@ -27,14 +27,15 @@
set -eu -o pipefail 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" ]] if [[ "$@" = "ALL" ]]
then then
for translation in translations/*.ts for translation in translations/*.ts
do do
$LUPDATE_CMD "$translation" $LUPDATE_CMD -ts "$translation"
done done
$LUPDATE_CMD -pluralonly -ts translations/en.ts
else else
$LUPDATE_CMD "$@" $LUPDATE_CMD "$@"
fi fi

View File

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

View File

@ -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) [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) [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) [Ελληνικά](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) [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) [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) [فارسی](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 Normal file
View File

@ -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>

View File

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

View File

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