Skip to content

Commit

Permalink
Make sure that render names in the layer list show up w/ i18n (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghutchis authored Jul 2, 2022
1 parent 367c438 commit 91cbfa7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
28 changes: 27 additions & 1 deletion avogadro/qtgui/layermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ QVariant LayerModel::data(const QModelIndex& idx, int role) const
if (idx.column() == ColumnType::Name) {
switch (role) {
case Qt::DisplayRole: {
return " " + tr(name.c_str()); // should already be translated
return " " + getTranslatedName(name); // should already be translated
}
}
}
Expand All @@ -119,6 +119,32 @@ QVariant LayerModel::data(const QModelIndex& idx, int role) const
return QVariant();
}

const QString LayerModel::getTranslatedName(const std::string& name) const
{
// This is a bad hack, but whatever..
// Put all the strings that show up as layer options
if (name == "Ball and Stick")
return tr("Ball and Stick");
else if (name == "Cartoons")
return tr("Cartoons", "protein ribbon / cartoon rendering");
else if (name == "Close Contacts")
return tr("Close Contacts", "rendering of non-covalent close contacts");
else if (name == "Labels")
return tr("Labels");
else if (name == "Licorice")
return tr("Licorice", "stick / licorice rendering");
else if (name == "Non-Covalent")
return tr("Non-Covalent");
else if (name == "Van der Waals")
return tr("Van der Waals");
else if (name == "Van der Waals (AO)")
return tr("Van der Waals (AO)", "ambient occlusion");
else if (name == "Wireframe")
return tr("Wireframe");

return QString();
}

QModelIndex LayerModel::index(int row, int column, const QModelIndex& p) const
{
if (!p.isValid())
Expand Down
1 change: 1 addition & 0 deletions avogadro/qtgui/layermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public slots:
void updateRows();

private:
const QString getTranslatedName(const std::string& name) const;
size_t m_item;
};

Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtplugins/vanderwaals/vanderwaals.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class VanDerWaals : public QtGui::ScenePlugin
void process(const QtGui::Molecule& molecule,
Rendering::GroupNode& node) override;

QString name() const override { return tr(m_name.c_str()); }
QString name() const override { return tr("Van der Waals"); }

QString description() const override
{
Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtplugins/vanderwaalsao/vanderwaalsao.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class VanDerWaalsAO : public QtGui::ScenePlugin
void process(const QtGui::Molecule& molecule,
Rendering::GroupNode& node) override;

QString name() const override { return tr(m_name.c_str()); }
QString name() const override { return tr("Van der Waals (AO)", "ambient occlusion"); }

QString description() const override
{
Expand Down

0 comments on commit 91cbfa7

Please sign in to comment.