English language is internal and doesn't require separate *.qm file.

This commit is contained in:
Roman Telezhynskyi 2024-02-27 18:12:16 +02:00
parent f32da16dd8
commit eb22f19fea
9 changed files with 12 additions and 27664 deletions

View File

@ -10,7 +10,6 @@ Module {
"id_ID",
"es_ES",
"fi_FI",
"en_US",
"ro_RO",
"zh_CN",
"pt_BR",

View File

@ -10,7 +10,7 @@ start=$(date +%s)
# Empty means unstable branch
VALENTINA_BRANCH='' # for example 05x
LANGUAGES="uk,de_DE,cs,he_IL,fr_FR,it_IT,nl,id,es,fi,en_US,ro_RO,zh_CN,pt_BR,el_GR,pl_PL"
LANGUAGES="uk,de_DE,cs,he_IL,fr_FR,it_IT,nl,id,es,fi,ro_RO,zh_CN,pt_BR,el_GR,pl_PL"
# Certant languages like he_IL and zh_CN are not supported by math parser
tx pull -r valentina-project.valentina_${VALENTINA_BRANCH}ts --mode=default -f --skip -l "${LANGUAGES}" &

View File

@ -9,7 +9,7 @@ start=$(date +%s)
# Empty means unstable branch
VALENTINA_BRANCH='' # for example 05x
LANGUAGES="uk,de_DE,cs,he_IL,fr_FR,it_IT,nl,id,es,fi,en_US,ro_RO,zh_CN,pt_BR,el_GR,pl_PL"
LANGUAGES="uk,de_DE,cs,he_IL,fr_FR,it_IT,nl,id,es,fi,ro_RO,zh_CN,pt_BR,el_GR,pl_PL"
# Certant languages like he_IL and zh_CN are not supported by math parser
tx pull -r valentina-project.valentina_${VALENTINA_BRANCH}ts --mode=default -f --skip -l "${LANGUAGES}" &

View File

@ -60,7 +60,6 @@ LANGUAGES += \
id_ID \
es_ES \
fi_FI \
en_US \
ro_RO \
zh_CN \
pt_BR \

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,6 @@ isEmpty(LOCALES){
id_ID \
es_ES \
fi_FI \
en_US \
ro_RO \
zh_CN \
pt_BR \
@ -168,17 +167,6 @@ macx{
QMAKE_BUNDLE_DATA += TRANSLATION_fi_FI
}
exists($${TRANSLATIONS_PATH}/valentina_en_US.qm){
TRANSLATION_en_US.files += \
$$files($${TRANSLATIONS_PATH}/*_en_US.qm) \
$$[QT_INSTALL_TRANSLATIONS]/qtbase_en.qm \
$$[QT_INSTALL_TRANSLATIONS]/qt_en.qm \
$$[QT_INSTALL_TRANSLATIONS]/qtxmlpatterns_en.qm \
$${TRANSLATIONS_PATH}/Localizable.strings
TRANSLATION_en_US.path = "$$RESOURCES_DIR/translations/en_US.lproj"
QMAKE_BUNDLE_DATA += TRANSLATION_en_US
}
exists($${TRANSLATIONS_PATH}/valentina_ro_RO.qm){
TRANSLATION_ro_RO.files += \
$$files($${TRANSLATIONS_PATH}/*_ro_RO.qm) \

View File

@ -91,8 +91,7 @@ void InitLanguageList(QComboBox *combobox)
combobox->clear();
const QStringList fileNames = LocalList();
bool englishUS = false;
const QString en_US = QStringLiteral("en_US");
const QStringList supportedLocales = SupportedLocales();
for (auto locale : fileNames)
{
@ -100,16 +99,11 @@ void InitLanguageList(QComboBox *combobox)
locale.truncate(locale.lastIndexOf('.'_L1)); // "valentina_de_De"
locale.remove(0, locale.indexOf('_'_L1) + 1); // "de_De"
if (locale.startsWith("ru"_L1))
if (locale.startsWith("ru"_L1) || !supportedLocales.contains(locale))
{
continue;
}
if (not englishUS)
{
englishUS = (en_US == locale);
}
QLocale const loc = QLocale(locale);
QString const lang = loc.nativeLanguageName();
QString country = TerritoryToString(loc);
@ -122,16 +116,12 @@ void InitLanguageList(QComboBox *combobox)
combobox->addItem(ico, lang, locale);
}
if (combobox->count() == 0 || not englishUS)
{
// English language is internal and doens't have own *.qm file.
// English language is internal and doesn't have own *.qm file.
// Since Qt 5.12 country names have spaces
QIcon const ico(u"://flags/%1.png"_s.arg(TerritoryToString(QLocale::UnitedStates))
);
QIcon const ico(u"://flags/%1.png"_s.arg(TerritoryToString(QLocale::UnitedStates)));
const QString en_US = QStringLiteral("en_US");
QString const lang = QLocale(en_US).nativeLanguageName();
combobox->addItem(ico, lang, en_US);
}
}
} // namespace
@ -166,7 +156,7 @@ void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int h
auto SupportedLocales() -> QStringList
{
return QStringList{"uk_UA", "de_DE", "cs_CZ", "he_IL", "fr_FR", "it_IT", "nl_NL", "id_ID",
"es_ES", "fi_FI", "en_US", "ro_RO", "zh_CN", "pt_BR", "el_GR", "pl_PL"};
"es_ES", "fi_FI", "ro_RO", "zh_CN", "pt_BR", "el_GR", "pl_PL"};
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -45,86 +45,6 @@ TST_TSTranslation::TST_TSTranslation(QObject *parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
void TST_TSTranslation::CheckEnglishLocalization_data()
{
QTest::addColumn<QString>("source");
QTest::addColumn<QString>("translation");
const QString fileName = QStringLiteral("valentina_en_US.ts");
const QDomNodeList messages = LoadTSFile(fileName);
if (messages.isEmpty())
{
QFAIL("Can't begin test.");
}
for (qint32 i = 0, num = messages.size(); i < num; ++i)
{
const QDomElement message = messages.at(i).toElement();
if (not message.isNull())
{
const QString source = message.firstChildElement(TagSource).text();
if (source.isEmpty())
{
continue;
}
const QDomElement translationTag = message.firstChildElement(TagTranslation);
if (translationTag.hasAttribute(AttrType))
{
const QString attrVal = translationTag.attribute(AttrType);
if (attrVal == AttrValVanished || attrVal == AttrValUnfinished || attrVal == AttrValObsolete)
{
continue;
}
}
auto PluralForm = [translationTag]()
{
QDomNodeList const children = translationTag.childNodes();
for (int i = 0; i < children.size(); ++i)
{
QDomNode const child = children.item(i);
if (child.isElement())
{
return true;
}
}
return false;
};
if (PluralForm())
{
continue; // do not check plural forms
}
const QString translation = translationTag.text();
if (translation.isEmpty())
{
continue;
}
const QString caseName =
QStringLiteral("File '%1'. Check modification source message '%2'.").arg(fileName, source);
QTest::newRow(qUtf8Printable(caseName)) << source << translation;
}
else
{
const QString caseName = QStringLiteral("Message %1 is null.").arg(i);
QFAIL(qUtf8Printable(caseName));
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void TST_TSTranslation::CheckEnglishLocalization()
{
QFETCH(QString, source);
QFETCH(QString, translation);
QCOMPARE(source, translation);
}
//---------------------------------------------------------------------------------------------------------------------
void TST_TSTranslation::CheckEmptyToolButton_data()
{

View File

@ -34,12 +34,11 @@
class TST_TSTranslation : public TST_AbstractTranslation
{
Q_OBJECT // NOLINT
public:
explicit TST_TSTranslation(QObject *parent = nullptr);
private slots:
void CheckEnglishLocalization_data();
void CheckEnglishLocalization();
void CheckEmptyToolButton_data();
void CheckEmptyToolButton();
void CheckEllipsis_data();