Skip to content

Commit

Permalink
allow to translate property names
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 29, 2016
1 parent f252f54 commit d2677d4
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
Binary file modified src/Gui/Language/FreeCAD_de.qm
Binary file not shown.
16 changes: 16 additions & 0 deletions src/Gui/Language/FreeCAD_de.ts
Expand Up @@ -66,6 +66,22 @@
<source>Visual size of the feature</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Base</source>
<translation>Basis</translation>
</message>
<message>
<source>Angle</source>
<translation>Winkel</translation>
</message>
<message>
<source>Axis</source>
<translation>Achse</translation>
</message>
<message>
<source>Position</source>
<translation>Position</translation>
</message>
</context>
<context>
<name>CmdTestConsoleOutput</name>
Expand Down
18 changes: 13 additions & 5 deletions src/Gui/propertyeditor/PropertyItem.cpp
Expand Up @@ -259,6 +259,11 @@ int PropertyItem::decimals() const
return precision;
}

QVariant PropertyItem::displayName() const
{
return QVariant(displayText);
}

QVariant PropertyItem::toolTip(const App::Property* prop) const
{
QString str = QApplication::translate("App::Property",
Expand Down Expand Up @@ -333,7 +338,7 @@ QVariant PropertyItem::editorData(QWidget * /*editor*/) const
QString PropertyItem::propertyName() const
{
if (propName.isEmpty())
return QLatin1String("<empty>");
return QLatin1String(QT_TRANSLATE_NOOP("App::Property", "<empty>"));
return propName;
}

Expand All @@ -353,6 +358,9 @@ void PropertyItem::setPropertyName(const QString& name)
}

propName = display;

QString str = QApplication::translate("App::Property", propName.toLatin1());
displayText = str;
}

void PropertyItem::setPropertyValue(const QString& value)
Expand Down Expand Up @@ -384,7 +392,7 @@ QVariant PropertyItem::data(int column, int role) const
// property name
if (column == 0) {
if (role == Qt::DisplayRole)
return propertyName();
return displayName();
// no properties set
if (propertyItems.empty())
return QVariant();
Expand Down Expand Up @@ -1754,16 +1762,16 @@ PropertyPlacementItem::PropertyPlacementItem() : init_axis(false), changed_value
{
m_a = static_cast<PropertyUnitItem*>(PropertyUnitItem::create());
m_a->setParent(this);
m_a->setPropertyName(QLatin1String("Angle"));
m_a->setPropertyName(QLatin1String(QT_TRANSLATE_NOOP("App::Property", "Angle")));
this->appendChild(m_a);
m_d = static_cast<PropertyVectorItem*>(PropertyVectorItem::create());
m_d->setParent(this);
m_d->setPropertyName(QLatin1String("Axis"));
m_d->setPropertyName(QLatin1String(QT_TRANSLATE_NOOP("App::Property", "Axis")));
m_d->setReadOnly(true);
this->appendChild(m_d);
m_p = static_cast<PropertyVectorDistanceItem*>(PropertyVectorDistanceItem::create());
m_p->setParent(this);
m_p->setPropertyName(QLatin1String("Position"));
m_p->setPropertyName(QLatin1String(QT_TRANSLATE_NOOP("App::Property", "Position")));
m_p->setReadOnly(true);
this->appendChild(m_p);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/propertyeditor/PropertyItem.h
Expand Up @@ -158,6 +158,7 @@ class GuiExport PropertyItem : public QObject, public ExpressionBinding
protected:
PropertyItem();

virtual QVariant displayName() const;
virtual QVariant decoration(const QVariant&) const;
virtual QVariant toolTip(const App::Property*) const;
virtual QVariant toString(const QVariant&) const;
Expand All @@ -168,6 +169,7 @@ class GuiExport PropertyItem : public QObject, public ExpressionBinding

private:
QString propName;
QString displayText;
QVariant propData;
std::vector<App::Property*> propertyItems;
PropertyItem *parentItem;
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/propertyeditor/PropertyModel.cpp
Expand Up @@ -220,7 +220,7 @@ void PropertyModel::buildUp(const PropertyModel::PropertyList& props)
App::Property* prop = jt->second.front();
const char* group = prop->getGroup();
bool isEmpty = (group == 0 || group[0] == '\0');
std::string grp = isEmpty ? "Base" : group;
std::string grp = isEmpty ? QT_TRANSLATE_NOOP("App::Property", "Base") : group;
propGroup[grp].push_back(jt->second);
}

Expand Down

0 comments on commit d2677d4

Please sign in to comment.