diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-03-21 16:46:36 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-03-22 12:02:48 -0700 |
commit | a109a283672e8e57c1dd85eb681e71a32d4c97bf (patch) | |
tree | f7f3fc5a9f2d65e7e02f76a83d34a901aba511b4 /commands | |
parent | e6cbb28a9fbac6b58b60d1715e86948869e62607 (diff) | |
download | subsurface-a109a283672e8e57c1dd85eb681e71a32d4c97bf.tar.gz |
translations: qualify tr function to get correct context
The way inheritance is implemented for the undo commands confuses the Qt
translation tooling - with the result that the context assumed by the
tools used to extract the strings doesn't match the context calculated
at runtime - so all the translations for the strings in undo commands
fail (including creating proper numerus forms).
This change forces a consistant context tag, at the price of creating a
significant delta for the source strings (the strings themselves stay
the same, but the context for a lot of them changes). I am hoping that
Transifex is smart enough to automagically add the correct translations
for these, but I guess I won't know until I try.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/command_divelist.cpp | 30 | ||||
-rw-r--r-- | commands/command_divesite.cpp | 24 | ||||
-rw-r--r-- | commands/command_edit.cpp | 66 | ||||
-rw-r--r-- | commands/command_edit_trip.cpp | 6 |
4 files changed, 63 insertions, 63 deletions
diff --git a/commands/command_divelist.cpp b/commands/command_divelist.cpp index 93689d44a..8f6189c1e 100644 --- a/commands/command_divelist.cpp +++ b/commands/command_divelist.cpp @@ -396,7 +396,7 @@ void DiveListBase::redo() AddDive::AddDive(dive *d, bool autogroup, bool newNumber) { - setText(tr("add dive")); + setText(Command::Base::tr("add dive")); // By convention, d is a pointer to "displayed dive" or a temporary variable and can be overwritten. d->maxdepth.mm = 0; d->dc.maxdepth.mm = 0; @@ -465,7 +465,7 @@ void AddDive::undoit() ImportDives::ImportDives(struct dive_table *dives, struct trip_table *trips, struct dive_site_table *sites, int flags, const QString &source) { - setText(tr("import %n dive(s) from %1", "", dives->nr).arg(source)); + setText(Command::Base::tr("import %n dive(s) from %1", "", dives->nr).arg(source)); // this only matters if undoit were called before redoit currentDive = nullptr; @@ -546,7 +546,7 @@ void ImportDives::undoit() DeleteDive::DeleteDive(const QVector<struct dive*> &divesToDeleteIn) { divesToDelete.dives = std::vector<dive *>(divesToDeleteIn.begin(), divesToDeleteIn.end()); - setText(QStringLiteral("%1 [%2]").arg(tr("delete %n dive(s)", "", divesToDelete.dives.size())).arg(getListOfDives(divesToDelete.dives))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("delete %n dive(s)", "", divesToDelete.dives.size())).arg(getListOfDives(divesToDelete.dives))); } bool DeleteDive::workToBeDone() @@ -582,7 +582,7 @@ void DeleteDive::redoit() ShiftTime::ShiftTime(std::vector<dive *> changedDives, int amount) : diveList(changedDives), timeChanged(amount) { - setText(QStringLiteral("%1 [%2]").arg(tr("shift time of %n dives", "", changedDives.size())).arg(getListOfDives(changedDives))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("shift time of %n dives", "", changedDives.size())).arg(getListOfDives(changedDives))); } void ShiftTime::redoit() @@ -630,7 +630,7 @@ RenumberDives::RenumberDives(const QVector<QPair<dive *, int>> &divesToRenumberI dives.reserve(divesToRenumber.length()); for (QPair<dive *, int>divePlusNumber: divesToRenumber) dives.push_back(divePlusNumber.first); - setText(QStringLiteral("%1 [%2]").arg(tr("renumber %n dive(s)", "", divesToRenumber.count())).arg(getListOfDives(dives))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("renumber %n dive(s)", "", divesToRenumber.count())).arg(getListOfDives(dives))); } void RenumberDives::undoit() @@ -682,7 +682,7 @@ void TripBase::undoit() RemoveDivesFromTrip::RemoveDivesFromTrip(const QVector<dive *> &divesToRemove) { - setText(QStringLiteral("%1 [%2]").arg(tr("remove %n dive(s) from trip", "", divesToRemove.size())).arg(getListOfDives(divesToRemove))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("remove %n dive(s) from trip", "", divesToRemove.size())).arg(getListOfDives(divesToRemove))); divesToMove.divesToMove.reserve(divesToRemove.size()); for (dive *d: divesToRemove) { // If a user manually removes a dive from a trip, don't autogroup this dive. @@ -694,7 +694,7 @@ RemoveDivesFromTrip::RemoveDivesFromTrip(const QVector<dive *> &divesToRemove) RemoveAutogenTrips::RemoveAutogenTrips() { - setText(tr("remove autogenerated trips")); + setText(Command::Base::tr("remove autogenerated trips")); // TODO: don't touch core-innards directly int i; struct dive *dive; @@ -706,14 +706,14 @@ RemoveAutogenTrips::RemoveAutogenTrips() AddDivesToTrip::AddDivesToTrip(const QVector<dive *> &divesToAddIn, dive_trip *trip) { - setText(QStringLiteral("%1 [%2]").arg(tr("add %n dives to trip", "", divesToAddIn.size())).arg(getListOfDives(divesToAddIn))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("add %n dives to trip", "", divesToAddIn.size())).arg(getListOfDives(divesToAddIn))); for (dive *d: divesToAddIn) divesToMove.divesToMove.push_back( {d, trip} ); } CreateTrip::CreateTrip(const QVector<dive *> &divesToAddIn) { - setText(tr("create trip")); + setText(Command::Base::tr("create trip")); if (divesToAddIn.isEmpty()) return; @@ -726,7 +726,7 @@ CreateTrip::CreateTrip(const QVector<dive *> &divesToAddIn) AutogroupDives::AutogroupDives() { - setText(tr("autogroup dives")); + setText(Command::Base::tr("autogroup dives")); dive_trip *trip; bool alloc; @@ -821,7 +821,7 @@ static std::array<dive *, 2> doSplitDives(const dive *d, duration_t time) SplitDives::SplitDives(dive *d, duration_t time) : SplitDivesBase(d, doSplitDives(d, time)) { - setText(tr("split dive")); + setText(Command::Base::tr("split dive")); } static std::array<dive *, 2> splitDiveComputer(const dive *d, int dc_num) @@ -839,7 +839,7 @@ static std::array<dive *, 2> splitDiveComputer(const dive *d, int dc_num) SplitDiveComputer::SplitDiveComputer(dive *d, int dc_num) : SplitDivesBase(d, splitDiveComputer(d, dc_num)) { - setText(tr("split dive computer")); + setText(Command::Base::tr("split dive computer")); } DiveComputerBase::DiveComputerBase(dive *old_dive, dive *new_dive, int dc_nr_after_in) : dc_nr_before(dc_number), @@ -895,18 +895,18 @@ void DiveComputerBase::undoit() MoveDiveComputerToFront::MoveDiveComputerToFront(dive *d, int dc_num) : DiveComputerBase(d, make_first_dc(d, dc_num), 0) { - setText(tr("move dive computer to front")); + setText(Command::Base::tr("move dive computer to front")); } DeleteDiveComputer::DeleteDiveComputer(dive *d, int dc_num) : DiveComputerBase(d, clone_delete_divecomputer(d, dc_num), std::min(count_divecomputers(d) - 1, dc_num)) { - setText(tr("delete dive computer")); + setText(Command::Base::tr("delete dive computer")); } MergeDives::MergeDives(const QVector <dive *> &dives) { - setText(tr("merge dive")); + setText(Command::Base::tr("merge dive")); // Just a safety check - if there's not two or more dives - do nothing // The caller should have made sure that this doesn't happen. diff --git a/commands/command_divesite.cpp b/commands/command_divesite.cpp index 8c61f224b..6f558d408 100644 --- a/commands/command_divesite.cpp +++ b/commands/command_divesite.cpp @@ -75,7 +75,7 @@ static std::vector<OwningDiveSitePtr> removeDiveSites(std::vector<dive_site *> & AddDiveSite::AddDiveSite(const QString &name) { - setText(tr("add dive site")); + setText(Command::Base::tr("add dive site")); sitesToAdd.emplace_back(alloc_dive_site()); sitesToAdd.back()->name = copy_qstring(name); } @@ -97,7 +97,7 @@ void AddDiveSite::undo() ImportDiveSites::ImportDiveSites(struct dive_site_table *sites, const QString &source) { - setText(tr("import dive sites from %1").arg(source)); + setText(Command::Base::tr("import dive sites from %1").arg(source)); for (int i = 0; i < sites->nr; ++i) { struct dive_site *new_ds = sites->dive_sites[i]; @@ -133,7 +133,7 @@ void ImportDiveSites::undo() DeleteDiveSites::DeleteDiveSites(const QVector<dive_site *> &sites) : sitesToRemove(std::vector<dive_site *>(sites.begin(),sites.end())) { - setText(tr("delete %n dive site(s)", "", sites.size())); + setText(Command::Base::tr("delete %n dive site(s)", "", sites.size())); } bool DeleteDiveSites::workToBeDone() @@ -153,7 +153,7 @@ void DeleteDiveSites::undo() PurgeUnusedDiveSites::PurgeUnusedDiveSites() { - setText(tr("purge unused dive sites")); + setText(Command::Base::tr("purge unused dive sites")); for (int i = 0; i < dive_site_table.nr; ++i) { dive_site *ds = dive_site_table.dive_sites[i]; if (ds->dives.nr == 0) @@ -188,7 +188,7 @@ static void swap(char *&c, QString &q) EditDiveSiteName::EditDiveSiteName(dive_site *dsIn, const QString &name) : ds(dsIn), value(name) { - setText(tr("Edit dive site name")); + setText(Command::Base::tr("Edit dive site name")); } bool EditDiveSiteName::workToBeDone() @@ -211,7 +211,7 @@ void EditDiveSiteName::undo() EditDiveSiteDescription::EditDiveSiteDescription(dive_site *dsIn, const QString &description) : ds(dsIn), value(description) { - setText(tr("Edit dive site description")); + setText(Command::Base::tr("Edit dive site description")); } bool EditDiveSiteDescription::workToBeDone() @@ -234,7 +234,7 @@ void EditDiveSiteDescription::undo() EditDiveSiteNotes::EditDiveSiteNotes(dive_site *dsIn, const QString ¬es) : ds(dsIn), value(notes) { - setText(tr("Edit dive site notes")); + setText(Command::Base::tr("Edit dive site notes")); } bool EditDiveSiteNotes::workToBeDone() @@ -257,7 +257,7 @@ void EditDiveSiteNotes::undo() EditDiveSiteCountry::EditDiveSiteCountry(dive_site *dsIn, const QString &country) : ds(dsIn), value(country) { - setText(tr("Edit dive site country")); + setText(Command::Base::tr("Edit dive site country")); } bool EditDiveSiteCountry::workToBeDone() @@ -282,7 +282,7 @@ void EditDiveSiteCountry::undo() EditDiveSiteLocation::EditDiveSiteLocation(dive_site *dsIn, const location_t location) : ds(dsIn), value(location) { - setText(tr("Edit dive site location")); + setText(Command::Base::tr("Edit dive site location")); } bool EditDiveSiteLocation::workToBeDone() @@ -311,7 +311,7 @@ EditDiveSiteTaxonomy::EditDiveSiteTaxonomy(dive_site *dsIn, taxonomy_data &taxon { // We did a dumb copy. Erase the source to remove double references to strings. memset(&taxonomy, 0, sizeof(taxonomy)); - setText(tr("Edit dive site taxonomy")); + setText(Command::Base::tr("Edit dive site taxonomy")); } EditDiveSiteTaxonomy::~EditDiveSiteTaxonomy() @@ -339,7 +339,7 @@ void EditDiveSiteTaxonomy::undo() MergeDiveSites::MergeDiveSites(dive_site *dsIn, const QVector<dive_site *> &sites) : ds(dsIn) { - setText(tr("merge dive sites")); + setText(Command::Base::tr("merge dive sites")); sitesToRemove.reserve(sites.size()); for (dive_site *site: sites) { if (site != ds) @@ -393,7 +393,7 @@ void MergeDiveSites::undo() ApplyGPSFixes::ApplyGPSFixes(const std::vector<DiveAndLocation> &fixes) { - setText(tr("apply GPS fixes")); + setText(Command::Base::tr("apply GPS fixes")); for (const DiveAndLocation &dl: fixes) { struct dive_site *ds = dl.d->dive_site; diff --git a/commands/command_edit.cpp b/commands/command_edit.cpp index a880f9f2f..218f3a2b8 100644 --- a/commands/command_edit.cpp +++ b/commands/command_edit.cpp @@ -92,9 +92,9 @@ bool EditBase<T>::workToBeDone() // Create a text for the menu entry. In the case of multiple dives add the number size_t num_dives = dives.size(); if (num_dives == 1) - setText(QStringLiteral("%1 [%2]").arg(tr("Edit %1").arg(fieldName())).arg(diveNumberOrDate(dives[0]))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("Edit %1").arg(fieldName())).arg(diveNumberOrDate(dives[0]))); else if (num_dives > 0) - setText(QStringLiteral("%1 [%2]").arg(tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())).arg(getListOfDives(dives))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())).arg(getListOfDives(dives))); return num_dives > 0; } @@ -163,7 +163,7 @@ QString EditNotes::data(struct dive *d) const QString EditNotes::fieldName() const { - return tr("notes"); + return Command::Base::tr("notes"); } DiveField EditNotes::fieldId() const @@ -185,7 +185,7 @@ QString EditSuit::data(struct dive *d) const QString EditSuit::fieldName() const { - return tr("suit"); + return Command::Base::tr("suit"); } DiveField EditSuit::fieldId() const @@ -206,7 +206,7 @@ int EditRating::data(struct dive *d) const QString EditRating::fieldName() const { - return tr("rating"); + return Command::Base::tr("rating"); } DiveField EditRating::fieldId() const @@ -227,7 +227,7 @@ int EditVisibility::data(struct dive *d) const QString EditVisibility::fieldName() const { - return tr("visibility"); + return Command::Base::tr("visibility"); } DiveField EditVisibility::fieldId() const @@ -248,7 +248,7 @@ int EditWaveSize::data(struct dive *d) const QString EditWaveSize::fieldName() const { - return tr("wavesize"); + return Command::Base::tr("wavesize"); } DiveField EditWaveSize::fieldId() const @@ -269,7 +269,7 @@ int EditCurrent::data(struct dive *d) const QString EditCurrent::fieldName() const { - return tr("current"); + return Command::Base::tr("current"); } DiveField EditCurrent::fieldId() const @@ -290,7 +290,7 @@ int EditSurge::data(struct dive *d) const QString EditSurge::fieldName() const { - return tr("surge"); + return Command::Base::tr("surge"); } DiveField EditSurge::fieldId() const @@ -311,7 +311,7 @@ int EditChill::data(struct dive *d) const QString EditChill::fieldName() const { - return tr("chill"); + return Command::Base::tr("chill"); } DiveField EditChill::fieldId() const @@ -332,7 +332,7 @@ int EditAirTemp::data(struct dive *d) const QString EditAirTemp::fieldName() const { - return tr("air temperature"); + return Command::Base::tr("air temperature"); } DiveField EditAirTemp::fieldId() const @@ -356,7 +356,7 @@ int EditWaterTemp::data(struct dive *d) const QString EditWaterTemp::fieldName() const { - return tr("water temperature"); + return Command::Base::tr("water temperature"); } DiveField EditWaterTemp::fieldId() const @@ -377,7 +377,7 @@ int EditWaterTypeUser::data(struct dive *d) const QString EditWaterTypeUser::fieldName() const { - return tr("salinity"); + return Command::Base::tr("salinity"); } DiveField EditWaterTypeUser::fieldId() const @@ -398,7 +398,7 @@ int EditAtmPress::data(struct dive *d) const QString EditAtmPress::fieldName() const { - return tr("Atm. pressure"); + return Command::Base::tr("Atm. pressure"); } DiveField EditAtmPress::fieldId() const @@ -422,7 +422,7 @@ int EditDuration::data(struct dive *d) const QString EditDuration::fieldName() const { - return tr("duration"); + return Command::Base::tr("duration"); } DiveField EditDuration::fieldId() const @@ -446,7 +446,7 @@ int EditDepth::data(struct dive *d) const QString EditDepth::fieldName() const { - return tr("depth"); + return Command::Base::tr("depth"); } DiveField EditDepth::fieldId() const @@ -468,7 +468,7 @@ struct dive_site *EditDiveSite::data(struct dive *d) const QString EditDiveSite::fieldName() const { - return tr("dive site"); + return Command::Base::tr("dive site"); } DiveField EditDiveSite::fieldId() const @@ -566,7 +566,7 @@ int EditMode::data(struct dive *d) const QString EditMode::fieldName() const { - return tr("dive mode"); + return Command::Base::tr("dive mode"); } DiveField EditMode::fieldId() const @@ -587,7 +587,7 @@ int EditInvalid::data(struct dive *d) const QString EditInvalid::fieldName() const { - return tr("invalid"); + return Command::Base::tr("invalid"); } DiveField EditInvalid::fieldId() const @@ -657,9 +657,9 @@ bool EditTagsBase::workToBeDone() // Create a text for the menu entry. In the case of multiple dives add the number size_t num_dives = dives.size(); if (num_dives == 1) - setText(QStringLiteral("%1 [%2]").arg(tr("Edit %1").arg(fieldName())).arg(diveNumberOrDate(dives[0]))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("Edit %1").arg(fieldName())).arg(diveNumberOrDate(dives[0]))); else if (num_dives > 0) - setText(QStringLiteral("%1 [%2]").arg(tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())).arg(getListOfDives(dives))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())).arg(getListOfDives(dives))); return num_dives != 0; } @@ -722,7 +722,7 @@ void EditTags::set(struct dive *d, const QStringList &v) const QString EditTags::fieldName() const { - return tr("tags"); + return Command::Base::tr("tags"); } DiveField EditTags::fieldId() const @@ -745,7 +745,7 @@ void EditBuddies::set(struct dive *d, const QStringList &v) const QString EditBuddies::fieldName() const { - return tr("buddies"); + return Command::Base::tr("buddies"); } DiveField EditBuddies::fieldId() const @@ -768,7 +768,7 @@ void EditDiveMaster::set(struct dive *d, const QStringList &v) const QString EditDiveMaster::fieldName() const { - return tr("dive master"); + return Command::Base::tr("dive master"); } DiveField EditDiveMaster::fieldId() const @@ -867,7 +867,7 @@ PasteDives::PasteDives(const dive *data, dive_components whatIn) : what(whatIn) for (dive *d: selection) dives.emplace_back(d, data, what); - setText(QStringLiteral("%1 [%2]").arg(tr("Paste onto %n dive(s)", "", dives.size())).arg(getListOfDives(selection))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("Paste onto %n dive(s)", "", dives.size())).arg(getListOfDives(selection))); } bool PasteDives::workToBeDone() @@ -943,7 +943,7 @@ ReplanDive::ReplanDive(dive *source, bool edit_profile) : d(current_dive), std::swap(source->cylinders, cylinders); std::swap(source->dc, dc); - setText((edit_profile ? tr("Replan dive") : tr("Edit profile")) + diveNumberOrDate(d)); + setText((edit_profile ? Command::Base::tr("Replan dive") : Command::Base::tr("Edit profile")) + diveNumberOrDate(d)); } ReplanDive::~ReplanDive() @@ -990,9 +990,9 @@ AddWeight::AddWeight(bool currentDiveOnly) : EditDivesBase(currentDiveOnly) { if (dives.size() == 1) - setText(QStringLiteral("%1 [%2]").arg(tr("Add weight")).arg(diveNumberOrDate(dives[0]))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("Add weight")).arg(diveNumberOrDate(dives[0]))); else - setText(QStringLiteral("%1 [%2]").arg(tr("Add weight (%n dive(s))", "", dives.size())).arg(getListOfDives(dives))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("Add weight (%n dive(s))", "", dives.size())).arg(getListOfDives(dives))); } bool AddWeight::workToBeDone() @@ -1075,9 +1075,9 @@ RemoveWeight::RemoveWeight(int index, bool currentDiveOnly) : { size_t num_dives = dives.size(); if (num_dives == 1) - setText(QStringLiteral("%1 [%2]").arg(tr("Remove weight")).arg(diveNumberOrDate(dives[0]))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("Remove weight")).arg(diveNumberOrDate(dives[0]))); else - setText(QStringLiteral("%1 [%2]").arg(tr("Remove weight (%n dive(s))", "", num_dives)).arg(getListOfDives(dives))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("Remove weight (%n dive(s))", "", num_dives)).arg(getListOfDives(dives))); } void RemoveWeight::undo() @@ -1105,9 +1105,9 @@ EditWeight::EditWeight(int index, weightsystem_t wsIn, bool currentDiveOnly) : size_t num_dives = dives.size(); if (num_dives == 1) - setText(QStringLiteral("%1 [%2]").arg(tr("Edit weight")).arg(diveNumberOrDate(dives[0]))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("Edit weight")).arg(diveNumberOrDate(dives[0]))); else - setText(QStringLiteral("%1 [%2]").arg(tr("Edit weight (%n dive(s))", "", num_dives)).arg(getListOfDives(dives))); + setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("Edit weight (%n dive(s))", "", num_dives)).arg(getListOfDives(dives))); // Try to untranslate the weightsystem name new_ws = clone_weightsystem(wsIn); @@ -1166,7 +1166,7 @@ EditDive::EditDive(dive *oldDiveIn, dive *newDiveIn, dive_site *createDs, dive_s if (!oldDive || ! newDive) return; - setText(tr("Edit dive [%1]").arg(diveNumberOrDate(oldDive))); + setText(Command::Base::tr("Edit dive [%1]").arg(diveNumberOrDate(oldDive))); // Calculate the fields that changed. // Note: Probably not needed, as on mobile we don't have that granularity. diff --git a/commands/command_edit_trip.cpp b/commands/command_edit_trip.cpp index c0f512907..f6d7251ea 100644 --- a/commands/command_edit_trip.cpp +++ b/commands/command_edit_trip.cpp @@ -15,7 +15,7 @@ EditTripBase::EditTripBase(dive_trip *tripIn, const QString &newValue) : trip(tr // Therefore, setting of the title is done here. bool EditTripBase::workToBeDone() { - setText(tr("Edit %1").arg(fieldName())); + setText(Command::Base::tr("Edit %1").arg(fieldName())); return data(trip) != value; } @@ -50,7 +50,7 @@ QString EditTripLocation::data(dive_trip *t) const QString EditTripLocation::fieldName() const { - return tr("trip location"); + return Command::Base::tr("trip location"); } TripField EditTripLocation::fieldId() const @@ -72,7 +72,7 @@ QString EditTripNotes::data(dive_trip *t) const QString EditTripNotes::fieldName() const { - return tr("trip notes"); + return Command::Base::tr("trip notes"); } TripField EditTripNotes::fieldId() const |