Use actual full en_US translation for English and drop en_plurals file

This commit is contained in:
Janek Bevendorff 2018-01-20 14:16:02 +01:00
parent 3c98ce43c6
commit bbc5ff5103
3 changed files with 11 additions and 46 deletions

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US">
<context>
<name>DatabaseWidget</name>
<message numerus="yes">
<source>Do you really want to move %n entry(s) to the recycle bin?</source>
<translation>
<numerusform>Do you really want to move %n entry to the recycle bin?</numerusform>
<numerusform>Do you really want to move %n entries to the recycle bin?</numerusform>
</translation>
</message>
</context>
<context>
<name>EditEntryWidget</name>
<message numerus="yes">
<source>%n week(s)</source>
<translation>
<numerusform>%n week</numerusform>
<numerusform>%n weeks</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%n month(s)</source>
<translation>
<numerusform>%n month</numerusform>
<numerusform>%n months</numerusform>
</translation>
</message>
</context>
<context>
<name>EditWidgetIcons</name>
<message numerus="yes">
<source>Can&apos;t delete icon. Still used by %n item(s).</source>
<translation type="vanished">
<numerusform>Can&apos;t delete icon. Still used by %n item.</numerusform>
<numerusform>Can&apos;t delete icon. Still used by %n items.</numerusform>
</translation>
</message>
</context>
</TS>

View File

@ -49,7 +49,6 @@ if $UPDATE; then
LUPDATE=lupdate LUPDATE=lupdate
fi fi
$LUPDATE -no-ui-lines -disable-heuristic similartext -locations none -no-obsolete src -ts share/translations/keepassx_en.ts $LUPDATE -no-ui-lines -disable-heuristic similartext -locations none -no-obsolete src -ts share/translations/keepassx_en.ts
$LUPDATE -no-ui-lines -disable-heuristic similartext -locations none -pluralonly src -ts share/translations/keepassx_en_plurals.ts
echo echo
fi fi

View File

@ -38,6 +38,10 @@ void Translator::installTranslators()
if (language == "system" || language.isEmpty()) { if (language == "system" || language.isEmpty()) {
language = QLocale::system().name(); language = QLocale::system().name();
} }
if (language == "en") {
// use actual English translation instead of the English locale source language
language = "en_US";
}
const QStringList paths = { const QStringList paths = {
#ifdef QT_DEBUG #ifdef QT_DEBUG
@ -48,8 +52,7 @@ void Translator::installTranslators()
bool translationsLoaded = false; bool translationsLoaded = false;
for (const QString& path : paths) { for (const QString& path : paths) {
translationsLoaded |= installTranslator(language, path) || installTranslator("en_plurals", path); translationsLoaded |= installTranslator(language, path) || installTranslator("en_US", path);
installQtTranslator(language, path);
} }
if (!translationsLoaded) { if (!translationsLoaded) {
// couldn't load configured language or fallback // couldn't load configured language or fallback
@ -79,12 +82,16 @@ QList<QPair<QString, QString>> Translator::availableLanguages()
QRegularExpressionMatch match = regExp.match(filename); QRegularExpressionMatch match = regExp.match(filename);
if (match.hasMatch()) { if (match.hasMatch()) {
QString langcode = match.captured(1); QString langcode = match.captured(1);
if (langcode == "en_plurals") { if (langcode == "en") {
langcode = "en"; continue;
} }
QLocale locale(langcode); QLocale locale(langcode);
QString languageStr = QLocale::languageToString(locale.language()); QString languageStr = QLocale::languageToString(locale.language());
if (langcode == "la") {
// langcode "la" (Latin) is translated into "C" by QLocale::languageToString()
languageStr = "Latin";
}
QString countryStr; QString countryStr;
if (langcode.contains("_")) { if (langcode.contains("_")) {
countryStr = QString(" (%1)").arg(QLocale::countryToString(locale.country())); countryStr = QString(" (%1)").arg(QLocale::countryToString(locale.country()));