Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that render names in the layer list show up w/ i18n #992

Merged
merged 1 commit into from
Jul 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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