desktop: fix translation implementation

We need to always call the tr() function of the base class. This will have
consequences for our translations.

See: #3068

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-11-08 14:38:59 -08:00
parent 51d0cb7aba
commit 8e3f7f9565
2 changed files with 11 additions and 11 deletions

View file

@ -1030,9 +1030,9 @@ AddCylinder::AddCylinder(bool currentDiveOnly) :
if (dives.empty()) if (dives.empty())
return; return;
else if (dives.size() == 1) else if (dives.size() == 1)
setText(tr("Add cylinder")); setText(Command::Base::tr("Add cylinder"));
else else
setText(tr("Add cylinder (%n dive(s))", "", dives.size())); setText(Command::Base::tr("Add cylinder (%n dive(s))", "", dives.size()));
cyl = create_new_cylinder(dives[0]); cyl = create_new_cylinder(dives[0]);
} }
@ -1151,9 +1151,9 @@ RemoveCylinder::RemoveCylinder(int index, bool currentDiveOnly) :
EditCylinderBase(index, currentDiveOnly, true, SAME_TYPE | SAME_PRESS | SAME_GAS) EditCylinderBase(index, currentDiveOnly, true, SAME_TYPE | SAME_PRESS | SAME_GAS)
{ {
if (dives.size() == 1) if (dives.size() == 1)
setText(tr("Remove cylinder")); setText(Command::Base::tr("Remove cylinder"));
else else
setText(tr("Remove cylinder (%n dive(s))", "", dives.size())); setText(Command::Base::tr("Remove cylinder (%n dive(s))", "", dives.size()));
} }
void RemoveCylinder::undo() void RemoveCylinder::undo()
@ -1201,9 +1201,9 @@ EditCylinder::EditCylinder(int index, cylinder_t cylIn, EditCylinderType typeIn,
return; return;
if (dives.size() == 1) if (dives.size() == 1)
setText(tr("Edit cylinder")); setText(Command::Base::tr("Edit cylinder"));
else else
setText(tr("Edit cylinder (%n dive(s))", "", dives.size())); setText(Command::Base::tr("Edit cylinder (%n dive(s))", "", dives.size()));
// Try to untranslate the cylinder type // Try to untranslate the cylinder type
QString description = cylIn.type.description; QString description = cylIn.type.description;

View file

@ -64,26 +64,26 @@ void AddEventBase::undoit()
AddEventBookmark::AddEventBookmark(struct dive *d, int dcNr, int seconds) : AddEventBookmark::AddEventBookmark(struct dive *d, int dcNr, int seconds) :
AddEventBase(d, dcNr, create_event(seconds, SAMPLE_EVENT_BOOKMARK, 0, 0, "bookmark")) AddEventBase(d, dcNr, create_event(seconds, SAMPLE_EVENT_BOOKMARK, 0, 0, "bookmark"))
{ {
setText(tr("Add bookmark")); setText(Command::Base::tr("Add bookmark"));
} }
AddEventDivemodeSwitch::AddEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode) : AddEventDivemodeSwitch::AddEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode) :
AddEventBase(d, dcNr, create_event(seconds, SAMPLE_EVENT_BOOKMARK, 0, divemode, QT_TRANSLATE_NOOP("gettextFromC", "modechange"))) AddEventBase(d, dcNr, create_event(seconds, SAMPLE_EVENT_BOOKMARK, 0, divemode, QT_TRANSLATE_NOOP("gettextFromC", "modechange")))
{ {
setText(tr("Add dive mode switch to %1").arg(gettextFromC::tr(divemode_text_ui[divemode]))); setText(Command::Base::tr("Add dive mode switch to %1").arg(gettextFromC::tr(divemode_text_ui[divemode])));
} }
AddEventSetpointChange::AddEventSetpointChange(struct dive *d, int dcNr, int seconds, pressure_t pO2) : AddEventSetpointChange::AddEventSetpointChange(struct dive *d, int dcNr, int seconds, pressure_t pO2) :
AddEventBase(d, dcNr, create_event(seconds, SAMPLE_EVENT_PO2, 0, pO2.mbar, QT_TRANSLATE_NOOP("gettextFromC", "SP change"))) AddEventBase(d, dcNr, create_event(seconds, SAMPLE_EVENT_PO2, 0, pO2.mbar, QT_TRANSLATE_NOOP("gettextFromC", "SP change")))
{ {
setText(tr("Add set point change")); // TODO: format pO2 value in bar or psi. setText(Command::Base::tr("Add set point change")); // TODO: format pO2 value in bar or psi.
} }
RenameEvent::RenameEvent(struct dive *d, int dcNr, struct event *ev, const char *name) : EventBase(d, dcNr), RenameEvent::RenameEvent(struct dive *d, int dcNr, struct event *ev, const char *name) : EventBase(d, dcNr),
eventToAdd(clone_event_rename(ev, name)), eventToAdd(clone_event_rename(ev, name)),
eventToRemove(ev) eventToRemove(ev)
{ {
setText(tr("Rename bookmark to %1").arg(name)); setText(Command::Base::tr("Rename bookmark to %1").arg(name));
} }
bool RenameEvent::workToBeDone() bool RenameEvent::workToBeDone()
@ -111,7 +111,7 @@ RemoveEvent::RemoveEvent(struct dive *d, int dcNr, struct event *ev) : EventBase
cylinder(ev->type == SAMPLE_EVENT_GASCHANGE2 || ev->type == SAMPLE_EVENT_GASCHANGE ? cylinder(ev->type == SAMPLE_EVENT_GASCHANGE2 || ev->type == SAMPLE_EVENT_GASCHANGE ?
ev->gas.index : -1) ev->gas.index : -1)
{ {
setText(tr("Remove %1 event").arg(ev->name)); setText(Command::Base::tr("Remove %1 event").arg(ev->name));
} }
bool RemoveEvent::workToBeDone() bool RemoveEvent::workToBeDone()