Fixed issue #931. Variable translation for Greek and Chinese are broken.
(grafted from d24d4570fc861a487cb6a1e76d2d828f1e1d7386) --HG-- branch : develop
This commit is contained in:
parent
5410b01753
commit
1a44f7968a
|
@ -20,6 +20,8 @@
|
||||||
- [#915] Valentina produces wrong seam allowance for acute angle.
|
- [#915] Valentina produces wrong seam allowance for acute angle.
|
||||||
- [#923] Valentina produces wrong seam allowance for rollback case.
|
- [#923] Valentina produces wrong seam allowance for rollback case.
|
||||||
- [#924] Valentina produces wrong passmark for rollback case.
|
- [#924] Valentina produces wrong passmark for rollback case.
|
||||||
|
- [#930] Valentina doesn't update translation for variables after dynamic language switch.
|
||||||
|
- [#931] Variable translation for Greek and Chinese are broken.
|
||||||
|
|
||||||
# Version 0.6.1 October 23, 2018
|
# Version 0.6.1 October 23, 2018
|
||||||
- [#885] Regression. Broken support for multi size measurements.
|
- [#885] Regression. Broken support for multi size measurements.
|
||||||
|
|
|
@ -30,7 +30,7 @@ VIETNAMESE_ALPHABET = set(u'aăâbcdđeêghiklmnoôơpqrstuưvxyAĂÂBCDĐEÊGH
|
||||||
HAITIAN_ALPHABET = set(u'aanbchdeèenfghijklmnngoòonouounprstuivwyzAAnBChDEèEnFGHIJKLMNNgOòOnOuOunPRSTUiVWYZ') #HAITIAN ALPHABET
|
HAITIAN_ALPHABET = set(u'aanbchdeèenfghijklmnngoòonouounprstuivwyzAAnBChDEèEnFGHIJKLMNNgOòOnOuOunPRSTUiVWYZ') #HAITIAN ALPHABET
|
||||||
GALICIAN_ALPHABET = set(u'abcdefghilmnñopqrstuvxzABCDEFGHILMNÑOPQRSTUVXZ') #GALICIAN ALPHABET
|
GALICIAN_ALPHABET = set(u'abcdefghilmnñopqrstuvxzABCDEFGHILMNÑOPQRSTUVXZ') #GALICIAN ALPHABET
|
||||||
DUTCH_ALPHABET = set(u'abcdefghijklmnopqrstuvwxijyzABCDEFGHIJKLMNOPQRSTUVWXIJYZ') #DUTCH ALPHABET
|
DUTCH_ALPHABET = set(u'abcdefghijklmnopqrstuvwxijyzABCDEFGHIJKLMNOPQRSTUVWXIJYZ') #DUTCH ALPHABET
|
||||||
GREEK_ALPHABET = set(u'αβγδεζηθικλμνξοπρσςτυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ') #GREEK ALPHABET
|
GREEK_ALPHABET = set(u'αβγδεζηθικλμνξοπρσςτυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΆΈΉΊΌΎΏΐΪΫάέήίΰϊϋόύώ') #GREEK ALPHABET
|
||||||
DANISH_ALPHABET = set(u'аbcdefghijklmnopqrstuvwxyzæøåАBCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ') #DANISH ALPHABET
|
DANISH_ALPHABET = set(u'аbcdefghijklmnopqrstuvwxyzæøåАBCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ') #DANISH ALPHABET
|
||||||
INDONESIAN_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #INDONESIAN ALPHABET
|
INDONESIAN_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #INDONESIAN ALPHABET
|
||||||
IRISH_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #IRISH ALPHABET
|
IRISH_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #IRISH ALPHABET
|
||||||
|
|
|
@ -62,12 +62,13 @@ void QmuFormulaBase::InitCharSets()
|
||||||
//case.
|
//case.
|
||||||
const QStringList symbols
|
const QStringList symbols
|
||||||
{
|
{
|
||||||
QStringLiteral("ցЀĆЈVӧĎАғΕĖӅИқΝĞơРңњΥҔĦШҫ̆جگĮаҳѕεشԶиһνԾрÃυلՆӝшËՎїPÓՖXӛӟŞãզhëծpóӞնxßվāŁЃֆĉЋCŬđҐГΒęҘЛΚŘġҠУGاհ"),
|
QStringLiteral("ցЀĆЈVӧĎАғΕĖӅИқΝĞơРңњΥĦШҫ̆έجگĮаҳѕεشԶиһνԾрÃυلՆӝшËύՎїPÓՖXӛӟŞãզhëҔծpóӞնxßվāŁЃֆĉЋΊCŬđҐГΒęҘЛΚŘġҠУGا"),
|
||||||
QStringLiteral("ЫدԱҰгβطԹõлκKՁÀуςهՉÈыvیՑÐSOřӘћաőcӐթèkàѓżűðsķչøӥӔĀփӣІĈЎґĐΗЖҙĘȚΟОҡĠآΧЦتЮұİزηжԸغẽοоÁՀقχцÉՈيюÑՐђӋі"),
|
QStringLiteral("հЫΪŪدԱҰгβطԹõлκKՁÀуςهՉÈыvیՑÐSOřӘћաőcӐթèkàѓżűðsķչøӥӔĀփӣІĈΏЎґĐΗЖҙĘȚΟОҡĠآΧЦتίЮұİزηжԸغẽοоÁՀقχц"),
|
||||||
QStringLiteral("әťӆўáŠĺѐfөըnñŰӤӨӹոľЁրăЉŭċБӸēłΔҖЙŤěΜӜDСձģΤӰЩīņحҮбưԳصδHйԻŇμӲӴсՃمτƠщՋєLQŹՓŕÖYśÞaգĽæiŽիӓîqճöyջþĂ"),
|
QStringLiteral("ÉՈيюÑՐђӋіәťӆўáŠĺѐfөըnñŰӤӨӹոľЁրăЉŭċΌБӸēłΔҖЙŤěΜӜDСձģΤӰЩīņحάҮбưԳصδHйԻŇμӴсՃمτƠщՋόєLQŹՓŕÖYśÞaգĽ"),
|
||||||
QStringLiteral("օЄӦĊЌΑĒДҗјΙȘĚМΡéĵĢФūӚΩبĪЬүќαذԲдҷιظԺмρՂфÇωوՊьÏՒTŚĻJբdçժlïӪղtպӫAւąЇčŃЏĕӯЗΖEțŮĝПΞأĥĹЧΦثÆӳЯI"),
|
QStringLiteral("æiŽիӓîqճöyջþĂօЄӦΉĊЌΑĒДҗјΙȘĚМΡéĵĢФūӚΩبĪЬүќαذԲдҷιظԺмρՂфÇωوՊьÏՒTŚĻJբdçժlïӪղtպӫAւąЇΆčŃЏΎĕӯЗΖEțŮ"),
|
||||||
QStringLiteral("سŲԵзζԽпξكՅÄчφNMՍӌяӢՕÔWÎŝÜџёźեägխoӒյôwĶBžսüЂĄև̈ЊČƏљΓВҕĔӮΛКĜΣТҥĤکЪƯخγвŅԴŪضλкԼĴσтÅՄنъÍՌRӕՔZÝŜ"),
|
QStringLiteral("ĝПΞأĥĹЧΦثÆӳЯήIسŲԵзζԽпξكՅÄчφNMՍӌяώӢӲՕÔWÎŝÜџёźեägխoӒյôwĶBžսüЂĄև̈ЊČƏљΓВҕĔӮΛКĜΣТҥĤکΫЪƯخγвŅԴϊضλкԼ"),
|
||||||
QStringLiteral("båդﻩjíլļrӵմzýռپêЅքćچЍďӱҒЕůėژșΘØҚНğńءΠFҢХħΨҪЭųįҶرҲеԷňعθҺнԿفπÂхՇψÊэšՏÒUəÚѝŻşҤӑâeէŐımկòuշÕúտŔ")
|
QStringLiteral("ĴσтÅՄنϋъÍՌRӕՔZÝŜbåդﻩjíլļrӵմӱzýռپêЅքćچΈЍďΐҒЕůėژșΘØҚНğńءΠFҢХħΨҪЭųįҶرΰҲеԷňعθҺнԿفπÂхՇψÊэšՏÒUəÚѝ"),
|
||||||
|
QStringLiteral("ŻşҤӑâeէŐımկòuշÕúտŔ")
|
||||||
};
|
};
|
||||||
|
|
||||||
symbolsStr = symbols.join(QString());
|
symbolsStr = symbols.join(QString());
|
||||||
|
|
|
@ -43,11 +43,12 @@ public:
|
||||||
|
|
||||||
virtual void InitCharSets() override;
|
virtual void InitCharSets() override;
|
||||||
|
|
||||||
|
void SetSepForTr(bool osSeparator, bool fromUser);
|
||||||
|
|
||||||
static void RemoveAll(QMap<int, QString> &map, const QString &val);
|
static void RemoveAll(QMap<int, QString> &map, const QString &val);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static qreal* AddVariable(const QString &a_szName, void *a_pUserData);
|
static qreal* AddVariable(const QString &a_szName, void *a_pUserData);
|
||||||
void SetSepForTr(bool osSeparator, bool fromUser);
|
|
||||||
void SetSepForEval();
|
void SetSepForEval();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QmuFormulaBase)
|
Q_DISABLE_COPY(QmuFormulaBase)
|
||||||
|
|
|
@ -772,6 +772,11 @@ QString VTranslateVars::PlaceholderFromUserText(QString text) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VTranslateVars::VarToUser(const QString &var) const
|
QString VTranslateVars::VarToUser(const QString &var) const
|
||||||
{
|
{
|
||||||
|
if (qApp->Settings()->GetLocale() == QStringLiteral("zh_CN"))
|
||||||
|
{
|
||||||
|
return var; // We do not support translation of variables for Chinese
|
||||||
|
}
|
||||||
|
|
||||||
if (measurements.contains(var))
|
if (measurements.contains(var))
|
||||||
{
|
{
|
||||||
return measurements.value(var).translate(qApp->Settings()->GetLocale());
|
return measurements.value(var).translate(qApp->Settings()->GetLocale());
|
||||||
|
@ -788,6 +793,11 @@ QString VTranslateVars::VarToUser(const QString &var) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VTranslateVars::VarFromUser(const QString &var) const
|
QString VTranslateVars::VarFromUser(const QString &var) const
|
||||||
{
|
{
|
||||||
|
if (qApp->Settings()->GetLocale() == QStringLiteral("zh_CN"))
|
||||||
|
{
|
||||||
|
return var; // We do not support translation of variables for Chinese
|
||||||
|
}
|
||||||
|
|
||||||
QString newVar = var;
|
QString newVar = var;
|
||||||
int bias = 0;
|
int bias = 0;
|
||||||
if (MeasurementsFromUser(newVar, 0, var, bias))
|
if (MeasurementsFromUser(newVar, 0, var, bias))
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "tst_abstractregexp.h"
|
#include "tst_abstractregexp.h"
|
||||||
#include "../qmuparser/qmudef.h"
|
#include "../qmuparser/qmudef.h"
|
||||||
|
#include "../qmuparser/qmuformulabase.h"
|
||||||
|
|
||||||
#include "../vmisc/logging.h"
|
#include "../vmisc/logging.h"
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
@ -36,6 +37,17 @@
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
QString PrepareValidNameChars()
|
||||||
|
{
|
||||||
|
qmu::QmuFormulaBase parser;
|
||||||
|
parser.InitCharSets();
|
||||||
|
parser.SetSepForTr(false, true);
|
||||||
|
return parser.ValidNameChars();
|
||||||
|
}
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
TST_AbstractRegExp::TST_AbstractRegExp(const QString &locale, QObject *parent)
|
TST_AbstractRegExp::TST_AbstractRegExp(const QString &locale, QObject *parent)
|
||||||
: AbstractTest(parent),
|
: AbstractTest(parent),
|
||||||
|
@ -190,3 +202,25 @@ void TST_AbstractRegExp::CallTestCheckNoOriginalNamesInTranslation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TST_AbstractRegExp::CallTestForValidCharacters()
|
||||||
|
{
|
||||||
|
QFETCH(QString, originalName);
|
||||||
|
|
||||||
|
static const QString validNameChars = PrepareValidNameChars();
|
||||||
|
|
||||||
|
if (QLocale() == QLocale(QStringLiteral("zh_CN")))
|
||||||
|
{
|
||||||
|
const QString message = QStringLiteral("We do not support translation of variables for locale zh_CN");
|
||||||
|
QSKIP(qUtf8Printable(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString translated = m_trMs->VarToUser(originalName);
|
||||||
|
const int pos = FindFirstNotOf(translated, validNameChars);
|
||||||
|
if (pos != -1)
|
||||||
|
{
|
||||||
|
const QString message = QStringLiteral("Translated string '%1' contains invalid character '%2' at position '%3'.")
|
||||||
|
.arg(translated).arg(translated.at(pos)).arg(pos);
|
||||||
|
QFAIL(qUtf8Printable(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ protected:
|
||||||
void CallTestCheckRegExpNames();
|
void CallTestCheckRegExpNames();
|
||||||
void CallTestCheckIsNamesUnique();
|
void CallTestCheckIsNamesUnique();
|
||||||
void CallTestCheckNoOriginalNamesInTranslation();
|
void CallTestCheckNoOriginalNamesInTranslation();
|
||||||
|
void CallTestForValidCharacters();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(TST_AbstractRegExp)
|
Q_DISABLE_COPY(TST_AbstractRegExp)
|
||||||
|
|
|
@ -63,6 +63,8 @@ void TST_BuitInRegExp::initTestCase()
|
||||||
QSKIP(qUtf8Printable(message));
|
QSKIP(qUtf8Printable(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QLocale::setDefault(QLocale(m_locale));
|
||||||
|
|
||||||
InitTrMs();//Very important do this after loading QM files.
|
InitTrMs();//Very important do this after loading QM files.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,6 +264,18 @@ void TST_BuitInRegExp::TestTemplatePlaceholders()
|
||||||
QCOMPARE(translations.size(), labelTemplatePlaceholders.size()); // All translated tags are unique
|
QCOMPARE(translations.size(), labelTemplatePlaceholders.size()); // All translated tags are unique
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TST_BuitInRegExp::TestForValidChars_data()
|
||||||
|
{
|
||||||
|
PrepareData();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TST_BuitInRegExp::TestForValidChars()
|
||||||
|
{
|
||||||
|
CallTestForValidCharacters();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TST_BuitInRegExp::cleanupTestCase()
|
void TST_BuitInRegExp::cleanupTestCase()
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,6 +62,8 @@ private slots:
|
||||||
void TestCheckInternalVaribleRegExp_data();
|
void TestCheckInternalVaribleRegExp_data();
|
||||||
void TestCheckInternalVaribleRegExp();
|
void TestCheckInternalVaribleRegExp();
|
||||||
void TestTemplatePlaceholders();
|
void TestTemplatePlaceholders();
|
||||||
|
void TestForValidChars_data();
|
||||||
|
void TestForValidChars();
|
||||||
void cleanupTestCase();
|
void cleanupTestCase();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -92,6 +92,8 @@ void TST_MeasurementRegExp::initTestCase()
|
||||||
QSKIP(qUtf8Printable(message));
|
QSKIP(qUtf8Printable(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QLocale::setDefault(QLocale(m_locale));
|
||||||
|
|
||||||
InitTrMs();//Very important do this after loading QM files.
|
InitTrMs();//Very important do this after loading QM files.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +145,18 @@ void TST_MeasurementRegExp::TestCheckNoOriginalNamesInTranslation()
|
||||||
CallTestCheckNoOriginalNamesInTranslation();
|
CallTestCheckNoOriginalNamesInTranslation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TST_MeasurementRegExp::TestForValidChars_data()
|
||||||
|
{
|
||||||
|
PrepareData();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TST_MeasurementRegExp::TestForValidChars()
|
||||||
|
{
|
||||||
|
CallTestForValidCharacters();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TST_MeasurementRegExp::cleanupTestCase()
|
void TST_MeasurementRegExp::cleanupTestCase()
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,6 +59,8 @@ private slots:
|
||||||
void TestCheckIsNamesUnique();
|
void TestCheckIsNamesUnique();
|
||||||
void TestCheckNoOriginalNamesInTranslation_data();
|
void TestCheckNoOriginalNamesInTranslation_data();
|
||||||
void TestCheckNoOriginalNamesInTranslation();
|
void TestCheckNoOriginalNamesInTranslation();
|
||||||
|
void TestForValidChars_data();
|
||||||
|
void TestForValidChars();
|
||||||
void cleanupTestCase();
|
void cleanupTestCase();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user