Fixed issue #853. Valentina doesn't translate user material placeholder.
--HG-- branch : develop
This commit is contained in:
parent
4109848349
commit
6869eab05a
|
@ -141,7 +141,7 @@ DialogPatternMaterials::~DialogPatternMaterials()
|
||||||
void DialogPatternMaterials::SetPatternMaterials(const QMap<int, QString> &list)
|
void DialogPatternMaterials::SetPatternMaterials(const QMap<int, QString> &list)
|
||||||
{
|
{
|
||||||
ui->tableWidget->setRowCount(userMaterialPlaceholdersQuantity);
|
ui->tableWidget->setRowCount(userMaterialPlaceholdersQuantity);
|
||||||
QLatin1String per("%");
|
QChar per('%');
|
||||||
|
|
||||||
for (int i = 0; i < userMaterialPlaceholdersQuantity; ++i)
|
for (int i = 0; i < userMaterialPlaceholdersQuantity; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -698,6 +698,8 @@ QString VTranslateVars::PlaceholderToUserText(QString text) const
|
||||||
QChar per('%');
|
QChar per('%');
|
||||||
auto i = placeholders.constBegin();
|
auto i = placeholders.constBegin();
|
||||||
while (i != placeholders.constEnd())
|
while (i != placeholders.constEnd())
|
||||||
|
{
|
||||||
|
if (i.key() != pl_userMaterial)
|
||||||
{
|
{
|
||||||
const QString translated = per + i.value().translate(qApp->Settings()->GetLocale()) + per;
|
const QString translated = per + i.value().translate(qApp->Settings()->GetLocale()) + per;
|
||||||
const QString original = per + i.key() + per;
|
const QString original = per + i.key() + per;
|
||||||
|
@ -706,6 +708,24 @@ QString VTranslateVars::PlaceholderToUserText(QString text) const
|
||||||
{
|
{
|
||||||
text.replace(original, translated);
|
text.replace(original, translated);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QString material_translated = i.value().translate(qApp->Settings()->GetLocale());
|
||||||
|
if (text.indexOf(i.key()) != -1)
|
||||||
|
{
|
||||||
|
for (int n = 0; n < userMaterialPlaceholdersQuantity; ++n)
|
||||||
|
{
|
||||||
|
const QString number = QString::number(n + 1);
|
||||||
|
const QString original = per + i.key() + number + per;
|
||||||
|
const QString translated = per + material_translated + number + per;
|
||||||
|
if (translated != original)
|
||||||
|
{
|
||||||
|
text.replace(original, translated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
|
@ -718,13 +738,32 @@ QString VTranslateVars::PlaceholderFromUserText(QString text) const
|
||||||
auto i = placeholders.constBegin();
|
auto i = placeholders.constBegin();
|
||||||
while (i != placeholders.constEnd())
|
while (i != placeholders.constEnd())
|
||||||
{
|
{
|
||||||
const QString translated = per + i.value().translate(qApp->Settings()->GetLocale()) + per;
|
if (i.key() != pl_userMaterial)
|
||||||
|
{
|
||||||
const QString original = per + i.key() + per;
|
const QString original = per + i.key() + per;
|
||||||
|
const QString translated = per + i.value().translate(qApp->Settings()->GetLocale()) + per;
|
||||||
if (translated != original)
|
if (translated != original)
|
||||||
{
|
{
|
||||||
text.replace(translated, original);
|
text.replace(translated, original);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QString material_translated = i.value().translate(qApp->Settings()->GetLocale());
|
||||||
|
if (text.indexOf(material_translated) != -1)
|
||||||
|
{
|
||||||
|
for (int n = 0; n < userMaterialPlaceholdersQuantity; ++n)
|
||||||
|
{
|
||||||
|
const QString number = QString::number(n + 1);
|
||||||
|
const QString original = per + i.key() + number + per;
|
||||||
|
const QString translated = per + material_translated + number + per;
|
||||||
|
if (translated != original)
|
||||||
|
{
|
||||||
|
text.replace(translated, original);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user