mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Translations: unify gettextFromC::tr() and QObject::tr()
There were two catch-all classes for translations outside of class context. gettextFromC was used exclusively from C, but C++ used both, gettextFromC and QObject. Some of the string were even present in both. Therefore, unify to gettextFromC throughout the code base. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
2f95141330
commit
57c01f7a66
11 changed files with 41 additions and 39 deletions
|
@ -53,7 +53,7 @@ static void exportHTMLstatisticsTotal(QTextStream &out, stats_t *total_stats)
|
|||
out << "\"YEAR\":\"Total\",";
|
||||
out << "\"DIVES\":\"" << total_stats->selection_size << "\",";
|
||||
out << "\"TOTAL_TIME\":\"" << get_dive_duration_string(total_stats->total_time.seconds,
|
||||
QObject::tr("h"), QObject::tr("min"), QObject::tr("sec"), " ") << "\",";
|
||||
gettextFromC::tr("h"), gettextFromC::tr("min"), gettextFromC::tr("sec"), " ") << "\",";
|
||||
out << "\"AVERAGE_TIME\":\"--\",";
|
||||
out << "\"SHORTEST_TIME\":\"--\",";
|
||||
out << "\"LONGEST_TIME\":\"--\",";
|
||||
|
@ -89,7 +89,7 @@ static void exportHTMLstatistics(const QString filename, struct htmlExportSettin
|
|||
out << "\"YEAR\":\"" << stats_yearly[i].period << "\",";
|
||||
out << "\"DIVES\":\"" << stats_yearly[i].selection_size << "\",";
|
||||
out << "\"TOTAL_TIME\":\"" << get_dive_duration_string(stats_yearly[i].total_time.seconds,
|
||||
QObject::tr("h"), QObject::tr("min"), QObject::tr("sec"), " ") << "\",";
|
||||
gettextFromC::tr("h"), gettextFromC::tr("min"), gettextFromC::tr("sec"), " ") << "\",";
|
||||
out << "\"AVERAGE_TIME\":\"" << get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size) << "\",";
|
||||
out << "\"SHORTEST_TIME\":\"" << get_minutes(stats_yearly[i].shortest_time.seconds) << "\",";
|
||||
out << "\"LONGEST_TIME\":\"" << get_minutes(stats_yearly[i].longest_time.seconds) << "\",";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "divesite.h"
|
||||
#include "pref.h"
|
||||
#include "gettextfromc.h"
|
||||
|
||||
QString constructLocationTags(struct dive_site *ds, bool for_maintab)
|
||||
{
|
||||
|
@ -17,7 +18,7 @@ QString constructLocationTags(struct dive_site *ds, bool for_maintab)
|
|||
}
|
||||
|
||||
if (!prefs_set && !for_maintab) {
|
||||
locationTag = QString("<small><small>") + QObject::tr("No dive site layout categories set in preferences!") +
|
||||
locationTag = QString("<small><small>") + gettextFromC::tr("No dive site layout categories set in preferences!") +
|
||||
QString("</small></small>");
|
||||
return locationTag;
|
||||
}
|
||||
|
@ -25,7 +26,7 @@ QString constructLocationTags(struct dive_site *ds, bool for_maintab)
|
|||
return locationTag;
|
||||
|
||||
if (for_maintab)
|
||||
locationTag = QString("<small><small>(") + QObject::tr("Tags") + QString(": ");
|
||||
locationTag = QString("<small><small>(") + gettextFromC::tr("Tags") + QString(": ");
|
||||
else
|
||||
locationTag = QString("<small><small>");
|
||||
QString connector;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <QNetworkReply>
|
||||
#include <QMap>
|
||||
|
||||
#define GPS_CURRENT_POS QObject::tr("Waiting to aquire GPS location")
|
||||
#define GPS_CURRENT_POS gettextFromC::tr("Waiting to aquire GPS location")
|
||||
|
||||
struct gpsTracker {
|
||||
degrees_t latitude;
|
||||
|
|
|
@ -762,9 +762,9 @@ int parseLengthToMm(const QString &text)
|
|||
if (numOnly.isEmpty())
|
||||
return 0;
|
||||
double number = numOnly.toDouble();
|
||||
if (text.contains(QObject::tr("m"), Qt::CaseInsensitive)) {
|
||||
if (text.contains(gettextFromC::tr("m"), Qt::CaseInsensitive)) {
|
||||
mm = lrint(number * 1000);
|
||||
} else if (text.contains(QObject::tr("ft"), Qt::CaseInsensitive)) {
|
||||
} else if (text.contains(gettextFromC::tr("ft"), Qt::CaseInsensitive)) {
|
||||
mm = feet_to_mm(number);
|
||||
} else {
|
||||
switch (prefs.units.length) {
|
||||
|
@ -790,9 +790,9 @@ int parseTemperatureToMkelvin(const QString &text)
|
|||
if (numOnly.isEmpty())
|
||||
return 0;
|
||||
double number = numOnly.toDouble();
|
||||
if (text.contains(QObject::tr("C"), Qt::CaseInsensitive)) {
|
||||
if (text.contains(gettextFromC::tr("C"), Qt::CaseInsensitive)) {
|
||||
mkelvin = C_to_mkelvin(number);
|
||||
} else if (text.contains(QObject::tr("F"), Qt::CaseInsensitive)) {
|
||||
} else if (text.contains(gettextFromC::tr("F"), Qt::CaseInsensitive)) {
|
||||
mkelvin = F_to_mkelvin(number);
|
||||
} else {
|
||||
switch (prefs.units.temperature) {
|
||||
|
@ -817,9 +817,9 @@ int parseWeightToGrams(const QString &text)
|
|||
if (numOnly.isEmpty())
|
||||
return 0;
|
||||
double number = numOnly.toDouble();
|
||||
if (text.contains(QObject::tr("kg"), Qt::CaseInsensitive)) {
|
||||
if (text.contains(gettextFromC::tr("kg"), Qt::CaseInsensitive)) {
|
||||
grams = lrint(number * 1000);
|
||||
} else if (text.contains(QObject::tr("lbs"), Qt::CaseInsensitive)) {
|
||||
} else if (text.contains(gettextFromC::tr("lbs"), Qt::CaseInsensitive)) {
|
||||
grams = lbs_to_grams(number);
|
||||
} else {
|
||||
switch (prefs.units.weight) {
|
||||
|
@ -844,9 +844,9 @@ int parsePressureToMbar(const QString &text)
|
|||
if (numOnly.isEmpty())
|
||||
return 0;
|
||||
double number = numOnly.toDouble();
|
||||
if (text.contains(QObject::tr("bar"), Qt::CaseInsensitive)) {
|
||||
if (text.contains(gettextFromC::tr("bar"), Qt::CaseInsensitive)) {
|
||||
mbar = lrint(number * 1000);
|
||||
} else if (text.contains(QObject::tr("psi"), Qt::CaseInsensitive)) {
|
||||
} else if (text.contains(gettextFromC::tr("psi"), Qt::CaseInsensitive)) {
|
||||
mbar = psi_to_mbar(number);
|
||||
} else {
|
||||
switch (prefs.units.pressure) {
|
||||
|
@ -867,9 +867,9 @@ int parseGasMixO2(const QString &text)
|
|||
{
|
||||
QString gasString = text;
|
||||
int o2, number;
|
||||
if (gasString.contains(QObject::tr("AIR"), Qt::CaseInsensitive)) {
|
||||
if (gasString.contains(gettextFromC::tr("AIR"), Qt::CaseInsensitive)) {
|
||||
o2 = O2_IN_AIR;
|
||||
} else if (gasString.contains(QObject::tr("EAN"), Qt::CaseInsensitive)) {
|
||||
} else if (gasString.contains(gettextFromC::tr("EAN"), Qt::CaseInsensitive)) {
|
||||
gasString.remove(QRegExp("[^0-9]"));
|
||||
number = gasString.toInt();
|
||||
o2 = number * 10;
|
||||
|
@ -1007,7 +1007,7 @@ QString get_trip_date_string(timestamp_t when, int nr, bool getday)
|
|||
localTime.setTimeSpec(Qt::UTC);
|
||||
QString ret ;
|
||||
|
||||
QString suffix = " " + QObject::tr("(%n dive(s))", "", nr);
|
||||
QString suffix = " " + gettextFromC::tr("(%n dive(s))", "", nr);
|
||||
if (getday) {
|
||||
ret = localTime.date().toString(prefs.date_format) + suffix;
|
||||
} else {
|
||||
|
@ -1235,7 +1235,7 @@ extern "C" char *picturedir_string()
|
|||
QString get_gas_string(struct gasmix gas)
|
||||
{
|
||||
uint o2 = (get_o2(&gas) + 5) / 10, he = (get_he(&gas) + 5) / 10;
|
||||
QString result = gasmix_is_air(&gas) ? QObject::tr("AIR") : he == 0 ? (o2 == 100 ? QObject::tr("OXYGEN") : QString("EAN%1").arg(o2, 2, 10, QChar('0'))) : QString("%1/%2").arg(o2).arg(he);
|
||||
QString result = gasmix_is_air(&gas) ? gettextFromC::tr("AIR") : he == 0 ? (o2 == 100 ? gettextFromC::tr("OXYGEN") : QString("EAN%1").arg(o2, 2, 10, QChar('0'))) : QString("%1/%2").arg(o2).arg(he);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1258,8 +1258,8 @@ weight_t string_to_weight(const char *str)
|
|||
const char *end;
|
||||
double value = strtod_flags(str, &end, 0);
|
||||
QString rest = QString(end).trimmed();
|
||||
QString local_kg = QObject::tr("kg");
|
||||
QString local_lbs = QObject::tr("lbs");
|
||||
QString local_kg = gettextFromC::tr("kg");
|
||||
QString local_lbs = gettextFromC::tr("lbs");
|
||||
weight_t weight;
|
||||
|
||||
if (rest.startsWith("kg") || rest.startsWith(local_kg))
|
||||
|
@ -1282,8 +1282,8 @@ depth_t string_to_depth(const char *str)
|
|||
const char *end;
|
||||
double value = strtod_flags(str, &end, 0);
|
||||
QString rest = QString(end).trimmed();
|
||||
QString local_ft = QObject::tr("ft");
|
||||
QString local_m = QObject::tr("m");
|
||||
QString local_ft = gettextFromC::tr("ft");
|
||||
QString local_m = gettextFromC::tr("m");
|
||||
depth_t depth;
|
||||
|
||||
if (value < 0)
|
||||
|
@ -1307,8 +1307,8 @@ pressure_t string_to_pressure(const char *str)
|
|||
const char *end;
|
||||
double value = strtod_flags(str, &end, 0);
|
||||
QString rest = QString(end).trimmed();
|
||||
QString local_psi = QObject::tr("psi");
|
||||
QString local_bar = QObject::tr("bar");
|
||||
QString local_psi = gettextFromC::tr("psi");
|
||||
QString local_bar = gettextFromC::tr("bar");
|
||||
pressure_t pressure;
|
||||
|
||||
if (rest.startsWith("bar") || rest.startsWith(local_bar))
|
||||
|
@ -1330,8 +1330,8 @@ volume_t string_to_volume(const char *str, pressure_t workp)
|
|||
const char *end;
|
||||
double value = strtod_flags(str, &end, 0);
|
||||
QString rest = QString(end).trimmed();
|
||||
QString local_l = QObject::tr("l");
|
||||
QString local_cuft = QObject::tr("cuft");
|
||||
QString local_l = gettextFromC::tr("l");
|
||||
QString local_cuft = gettextFromC::tr("cuft");
|
||||
volume_t volume;
|
||||
|
||||
if (rest.startsWith("l") || rest.startsWith("ℓ") || rest.startsWith(local_l))
|
||||
|
|
|
@ -18,6 +18,7 @@ enum inertgas {N2, HE};
|
|||
#include <QString>
|
||||
#include <QTranslator>
|
||||
#include <QDir>
|
||||
#include "core/gettextfromc.h"
|
||||
QString weight_string(int weight_in_grams);
|
||||
QString distance_string(int distanceInMeters);
|
||||
bool gpsHasChanged(struct dive *dive, struct dive *master, const QString &gps_text, bool *parsed_out = 0);
|
||||
|
@ -69,7 +70,7 @@ int parsePressureToMbar(const QString &text);
|
|||
int parseGasMixO2(const QString &text);
|
||||
int parseGasMixHE(const QString &text);
|
||||
QString render_seconds_to_string(int seconds);
|
||||
QString get_dive_duration_string(timestamp_t when, QString hoursText, QString minutesText, QString secondsText = QObject::tr("sec"), QString separator = ":", bool isFreeDive = false);
|
||||
QString get_dive_duration_string(timestamp_t when, QString hoursText, QString minutesText, QString secondsText = gettextFromC::tr("sec"), QString separator = ":", bool isFreeDive = false);
|
||||
QString get_dive_surfint_string(timestamp_t when, QString daysText, QString hoursText, QString minutesText, QString separator = " ", int maxdays = 4);
|
||||
QString get_dive_date_string(timestamp_t when);
|
||||
QString get_short_dive_date_string(timestamp_t when);
|
||||
|
|
|
@ -27,7 +27,7 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx)
|
|||
const char *desc = cyl->type.description;
|
||||
if (!desc && idx > 0)
|
||||
return QString(EMPTY_DIVE_STRING);
|
||||
QString fmt = desc ? QString(desc) : QObject::tr("unknown");
|
||||
QString fmt = desc ? QString(desc) : gettextFromC::tr("unknown");
|
||||
fmt += ", " + get_volume_string(cyl->type.size, true);
|
||||
fmt += ", " + get_pressure_string(cyl->type.workingpressure, true);
|
||||
fmt += ", " + get_pressure_string(cyl->start, false) + " - " + get_pressure_string(cyl->end, true);
|
||||
|
@ -129,7 +129,7 @@ QVariant DiveObjectHelper::dive_site_uuid() const
|
|||
|
||||
QString DiveObjectHelper::duration() const
|
||||
{
|
||||
return get_dive_duration_string(m_dive->duration.seconds, QObject::tr("h"), QObject::tr("min"));
|
||||
return get_dive_duration_string(m_dive->duration.seconds, gettextFromC::tr("h"), gettextFromC::tr("min"));
|
||||
}
|
||||
|
||||
bool DiveObjectHelper::noDive() const
|
||||
|
|
|
@ -62,7 +62,7 @@ void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
// don't allow removing the last point
|
||||
if (plannerModel->rowCount() > 1) {
|
||||
m.addSeparator();
|
||||
m.addAction(QObject::tr("Remove this point"), this, SLOT(selfRemove()));
|
||||
m.addAction(gettextFromC::tr("Remove this point"), this, SLOT(selfRemove()));
|
||||
m.exec(event->screenPos());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -635,7 +635,7 @@ void MainWindow::on_actionCloudstorageopen_triggered()
|
|||
static bool saveToCloudOK()
|
||||
{
|
||||
if (!dive_table.nr) {
|
||||
report_error(qPrintable(QObject::tr("Don't save an empty log to the cloud")));
|
||||
report_error(qPrintable(gettextFromC::tr("Don't save an empty log to the cloud")));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -31,13 +31,13 @@ public:
|
|||
{
|
||||
avgIco = new QLabel(owner);
|
||||
avgIco->setPixmap(QIcon(":value-average-icon").pixmap(16, 16));
|
||||
avgIco->setToolTip(QObject::tr("Average"));
|
||||
avgIco->setToolTip(gettextFromC::tr("Average"));
|
||||
minIco = new QLabel(owner);
|
||||
minIco->setPixmap(QIcon(":value-minimum-icon").pixmap(16, 16));
|
||||
minIco->setToolTip(QObject::tr("Minimum"));
|
||||
minIco->setToolTip(gettextFromC::tr("Minimum"));
|
||||
maxIco = new QLabel(owner);
|
||||
maxIco->setPixmap(QIcon(":value-maximum-icon").pixmap(16, 16));
|
||||
maxIco->setToolTip(QObject::tr("Maximum"));
|
||||
maxIco->setToolTip(gettextFromC::tr("Maximum"));
|
||||
avgValue = new QLabel(owner);
|
||||
minValue = new QLabel(owner);
|
||||
maxValue = new QLabel(owner);
|
||||
|
|
|
@ -620,7 +620,7 @@ static DiveListResult parseDiveLogsDeDiveList(const QByteArray &xmlData)
|
|||
* </DiveDateReader>
|
||||
*/
|
||||
QXmlStreamReader reader(xmlData);
|
||||
const QString invalidXmlError = QObject::tr("Invalid response from server");
|
||||
const QString invalidXmlError = gettextFromC::tr("Invalid response from server");
|
||||
bool seenDiveDates = false;
|
||||
DiveListResult result;
|
||||
result.idCount = 0;
|
||||
|
@ -628,7 +628,7 @@ static DiveListResult parseDiveLogsDeDiveList(const QByteArray &xmlData)
|
|||
if (reader.readNextStartElement() && reader.name() != "DiveDateReader") {
|
||||
result.errorCondition = invalidXmlError;
|
||||
result.errorDetails =
|
||||
QObject::tr("Expected XML tag 'DiveDateReader', got instead '%1")
|
||||
gettextFromC::tr("Expected XML tag 'DiveDateReader', got instead '%1")
|
||||
.arg(reader.name().toString());
|
||||
goto out;
|
||||
}
|
||||
|
@ -674,14 +674,14 @@ static DiveListResult parseDiveLogsDeDiveList(const QByteArray &xmlData)
|
|||
|
||||
if (!seenDiveDates) {
|
||||
result.errorCondition = invalidXmlError;
|
||||
result.errorDetails = QObject::tr("Expected XML tag 'DiveDates' not found");
|
||||
result.errorDetails = gettextFromC::tr("Expected XML tag 'DiveDates' not found");
|
||||
}
|
||||
|
||||
out:
|
||||
if (reader.hasError()) {
|
||||
// if there was an XML error, overwrite the result or other error conditions
|
||||
result.errorCondition = invalidXmlError;
|
||||
result.errorDetails = QObject::tr("Malformed XML response. Line %1: %2")
|
||||
result.errorDetails = gettextFromC::tr("Malformed XML response. Line %1: %2")
|
||||
.arg(reader.lineNumber())
|
||||
.arg(reader.errorString());
|
||||
}
|
||||
|
|
|
@ -107,8 +107,8 @@ if (property == "year") {
|
|||
} else if (property == "max_temp") {
|
||||
return object.year->max_temp.mkelvin == 0 ? "0" : get_temperature_string(object.year->max_temp, true);
|
||||
} else if (property == "total_time") {
|
||||
return get_dive_duration_string(object.year->total_time.seconds, QObject::tr("h"),
|
||||
QObject::tr("min"), QObject::tr("sec"), " ");
|
||||
return get_dive_duration_string(object.year->total_time.seconds, gettextFromC::tr("h"),
|
||||
gettextFromC::tr("min"), gettextFromC::tr("sec"), " ");
|
||||
} else if (property == "avg_time") {
|
||||
return get_minutes(object.year->total_time.seconds / object.year->selection_size);
|
||||
} else if (property == "shortest_time") {
|
||||
|
|
Loading…
Reference in a new issue