Rewrite describing placeholders %size% and %height%. New way will help avoid
translation mistake. --HG-- branch : develop
This commit is contained in:
parent
872fcc5217
commit
6281f46a8e
|
@ -173,6 +173,11 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
|
|||
ui->lineEditCustomerName->setText(doc->GetCustomerName());
|
||||
ui->labelCreationDate->setText(QDate::currentDate().toString(Qt::SystemLocaleLongDate));
|
||||
ui->lineEditSize->setText(doc->GetPatternSize());
|
||||
|
||||
const QString plSize = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_size) + QLatin1String("%");
|
||||
const QString plHeight = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_height) + QLatin1String("%");
|
||||
ui->lineEditSize->setToolTip(tr("Use %1 and %2 to insert pattern size and height").arg(plSize, plHeight));
|
||||
|
||||
ui->checkBoxShowDate->setChecked(doc->IsDateVisible());
|
||||
if (doc->MPath().isEmpty() == true)
|
||||
{
|
||||
|
@ -184,7 +189,6 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
|
|||
ui->checkBoxShowMeasurements->setChecked(doc->IsMeasurementsVisible());
|
||||
}
|
||||
|
||||
|
||||
connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
|
||||
connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
|
||||
connect(ui->lineEditCompanyName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
|
||||
|
|
|
@ -1053,7 +1053,7 @@
|
|||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>401</width>
|
||||
<height>241</height>
|
||||
<height>252</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
|
@ -1139,9 +1139,6 @@
|
|||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="lineEditSize">
|
||||
<property name="toolTip">
|
||||
<string>Use %size% and %height% to insert pattern size and height</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>40</number>
|
||||
</property>
|
||||
|
@ -1189,8 +1186,8 @@
|
|||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
<x>257</x>
|
||||
<y>682</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
|
@ -1205,8 +1202,8 @@
|
|||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
<x>325</x>
|
||||
<y>682</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../vpatterndb/vpatternpiecedata.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "vtextmanager.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -324,8 +325,14 @@ void VTextManager::Update(const VAbstractPattern *pDoc, qreal dSize, qreal dHeig
|
|||
tl.m_qsText = pDoc->GetPatternSize();
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_qsText.replace(QApplication::translate("Detail", "%size%", 0), QString::number(dSize));
|
||||
tl.m_qsText.replace(QApplication::translate("Detail", "%height%", 0), QString::number(dHeight));
|
||||
// Such describing placeholders will help avoid mistake of localization.
|
||||
// Translators very often remove '%'.
|
||||
QString placeholder = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_size) + QLatin1String("%");
|
||||
tl.m_qsText.replace(placeholder, QString::number(dSize));
|
||||
|
||||
placeholder = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_height) + QLatin1String("%");
|
||||
tl.m_qsText.replace(placeholder, QString::number(dHeight));
|
||||
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
|
|
|
@ -423,6 +423,9 @@ const QStringList builInPostfixOperators = QStringList() << cm_Oprt
|
|||
<< mm_Oprt
|
||||
<< in_Oprt;
|
||||
|
||||
const QString pl_size = QStringLiteral("size");
|
||||
const QString pl_height = QStringLiteral("height");
|
||||
|
||||
const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png");
|
||||
const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png");
|
||||
|
||||
|
|
|
@ -592,6 +592,10 @@ extern const QString in_Oprt;
|
|||
|
||||
extern const QStringList builInPostfixOperators;
|
||||
|
||||
// Placeholders
|
||||
extern const QString pl_size;
|
||||
extern const QString pl_height;
|
||||
|
||||
extern const QString cursorArrowOpenHand;
|
||||
extern const QString cursorArrowCloseHand;
|
||||
|
||||
|
|
|
@ -55,12 +55,14 @@ VTranslateVars::VTranslateVars()
|
|||
variables(QMap<QString, QmuTranslation>()),
|
||||
functions(QMap<QString, QmuTranslation>()),
|
||||
postfixOperators(QMap<QString, QmuTranslation>()),
|
||||
placeholders(QMap<QString, QmuTranslation>()),
|
||||
stDescriptions(QMap<QString, QmuTranslation>())
|
||||
{
|
||||
InitPatternMakingSystems();
|
||||
InitVariables();
|
||||
InitFunctions();
|
||||
InitPostfixOperators();
|
||||
InitPlaceholder();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -430,6 +432,13 @@ void VTranslateVars::InitPostfixOperators()
|
|||
postfixOperators.insert(in_Oprt, translate("VTranslateVars", "in", "inch"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VTranslateVars::InitPlaceholder()
|
||||
{
|
||||
placeholders.insert(pl_size, translate("VTranslateVars", "size", "placeholder"));
|
||||
placeholders.insert(pl_height, translate("VTranslateVars", "height", "placeholder"));
|
||||
}
|
||||
|
||||
#undef translate
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -614,6 +623,17 @@ QString VTranslateVars::InternalVarToUser(const QString &var) const
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VTranslateVars::PlaceholderToUser(const QString &var) const
|
||||
{
|
||||
if (placeholders.contains(var))
|
||||
{
|
||||
return placeholders.value(var).translate();
|
||||
}
|
||||
|
||||
return var;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VTranslateVars::VarToUser(const QString &var) const
|
||||
{
|
||||
|
@ -945,6 +965,7 @@ void VTranslateVars::Retranslate()
|
|||
InitVariables();
|
||||
InitFunctions();
|
||||
InitPostfixOperators();
|
||||
InitPlaceholder();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
bool VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
||||
|
||||
QString InternalVarToUser(const QString &var) const;
|
||||
QString PlaceholderToUser(const QString &var) const;
|
||||
|
||||
QString VarToUser(const QString &var) const;
|
||||
QString VarFromUser(const QString &var) const;
|
||||
|
@ -61,6 +62,7 @@ public:
|
|||
QString FormulaToUser(const QString &formula, bool osSeparator) const;
|
||||
|
||||
virtual void Retranslate() Q_DECL_OVERRIDE;
|
||||
|
||||
QMap<QString, qmu::QmuTranslation> GetFunctions() const;
|
||||
|
||||
private:
|
||||
|
@ -71,12 +73,14 @@ private:
|
|||
QMap<QString, qmu::QmuTranslation> variables;
|
||||
QMap<QString, qmu::QmuTranslation> functions;
|
||||
QMap<QString, qmu::QmuTranslation> postfixOperators;
|
||||
QMap<QString, qmu::QmuTranslation> placeholders;
|
||||
QMap<QString, qmu::QmuTranslation> stDescriptions;
|
||||
|
||||
void InitPatternMakingSystems();
|
||||
void InitVariables();
|
||||
void InitFunctions();
|
||||
void InitPostfixOperators();
|
||||
void InitPlaceholder();
|
||||
|
||||
void InitSystem(const QString &code, const qmu::QmuTranslation &name, const qmu::QmuTranslation &author,
|
||||
const qmu::QmuTranslation &book);
|
||||
|
|
Loading…
Reference in New Issue
Block a user