mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Next step towards working translations
This may seem like a really odd change - but with this change the Qt tools can correctly parse the C files (and qt-gui.cpp) and get the context for the translatable strings right. It's not super-pretty (I'll admit that _("string literal") is much easier on the eye than translate("gettextFromC", "string literal") ) but I think this will be the price of success. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2d69d4a5ef
commit
193d20c479
14 changed files with 184 additions and 182 deletions
30
planner.c
30
planner.c
|
@ -91,9 +91,9 @@ static int get_gasidx(struct dive *dive, int o2, int he)
|
|||
void get_gas_string(int o2, int he, char *text, int len)
|
||||
{
|
||||
if (is_air(o2, he))
|
||||
snprintf(text, len, tr("air"));
|
||||
snprintf(text, len, translate("gettextFromC","air"));
|
||||
else if (he == 0)
|
||||
snprintf(text, len, tr("EAN%d"), (o2 + 5) / 10);
|
||||
snprintf(text, len, translate("gettextFromC","EAN%d"), (o2 + 5) / 10);
|
||||
else
|
||||
snprintf(text, len, "(%d/%d)", (o2 + 5) / 10, (he + 5) / 10);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ double tissue_at_end(struct dive *dive, char **cached_datap, const char **error_
|
|||
t1 = sample->time.seconds;
|
||||
get_gas_from_events(&dive->dc, t0, &o2, &he);
|
||||
if ((gasidx = get_gasidx(dive, o2, he)) == -1) {
|
||||
snprintf(buf, sizeof(buf),tr("Can't find gas %d/%d"), (o2 + 5) / 10, (he + 5) / 10);
|
||||
snprintf(buf, sizeof(buf),translate("gettextFromC","Can't find gas %d/%d"), (o2 + 5) / 10, (he + 5) / 10);
|
||||
*error_string_p = buf;
|
||||
gasidx = 0;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ int add_gas(struct dive *dive, int o2, int he)
|
|||
mix->he.permille = he;
|
||||
/* since air is stored as 0/0 we need to set a name or an air cylinder
|
||||
* would be seen as unset (by cylinder_nodata()) */
|
||||
cyl->type.description = strdup(tr("Cylinder for planning"));
|
||||
cyl->type.description = strdup(translate("gettextFromC","Cylinder for planning"));
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan, const char **error
|
|||
dive->when = diveplan->when;
|
||||
dive->dc.surface_pressure.mbar = diveplan->surface_pressure;
|
||||
dc = &dive->dc;
|
||||
dc->model = strdup(tr("Simulated Dive"));
|
||||
dc->model = strdup(translate("gettextFromC","Simulated Dive"));
|
||||
dp = diveplan->dp;
|
||||
|
||||
/* let's start with the gas given on the first segment */
|
||||
|
@ -291,7 +291,7 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan, const char **error
|
|||
|
||||
gas_error_exit:
|
||||
free(dive);
|
||||
*error_string = tr("Too many gas mixes");
|
||||
*error_string = translate("gettextFromC","Too many gas mixes");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
if (!dp)
|
||||
return;
|
||||
|
||||
snprintf(buffer, sizeof(buffer), tr("%s\nSubsurface dive plan\nbased on GFlow = %.0f and GFhigh = %.0f\n\n"),
|
||||
snprintf(buffer, sizeof(buffer), translate("gettextFromC","%s\nSubsurface dive plan\nbased on GFlow = %.0f and GFhigh = %.0f\n\n"),
|
||||
disclaimer, plangflow * 100, plangfhigh * 100);
|
||||
/* we start with gas 0, then check if that was changed */
|
||||
o2 = dive->cylinder[0].gasmix.o2.permille;
|
||||
|
@ -510,7 +510,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
if (dp->depth != lastdepth) {
|
||||
used = diveplan->bottomsac / 1000.0 * depth_to_mbar((dp->depth + lastdepth) / 2, dive) *
|
||||
(dp->time - lasttime) / 60;
|
||||
snprintf(buffer + len, sizeof(buffer) - len, tr("Transition to %.*f %s in %d:%02d min - runtime %d:%02u on %s\n"),
|
||||
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC","Transition to %.*f %s in %d:%02d min - runtime %d:%02u on %s\n"),
|
||||
decimals, depthvalue, depth_unit,
|
||||
FRACTION(dp->time - lasttime, 60),
|
||||
FRACTION(dp->time, 60),
|
||||
|
@ -519,7 +519,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
/* we use deco SAC rate during the calculated deco stops, bottom SAC rate everywhere else */
|
||||
int sac = dp->entered ? diveplan->bottomsac : diveplan->decosac;
|
||||
used = sac / 1000.0 * depth_to_mbar(dp->depth, dive) * (dp->time - lasttime) / 60;
|
||||
snprintf(buffer + len, sizeof(buffer) - len, tr("Stay at %.*f %s for %d:%02d min - runtime %d:%02u on %s\n"),
|
||||
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC","Stay at %.*f %s for %d:%02d min - runtime %d:%02u on %s\n"),
|
||||
decimals, depthvalue, depth_unit,
|
||||
FRACTION(dp->time - lasttime, 60),
|
||||
FRACTION(dp->time, 60),
|
||||
|
@ -530,7 +530,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
get_gas_string(newo2, newhe, gas, sizeof(gas));
|
||||
if (o2 != newo2 || he != newhe) {
|
||||
len = strlen(buffer);
|
||||
snprintf(buffer + len, sizeof(buffer) - len, tr("Switch gas to %s\n"), gas);
|
||||
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC","Switch gas to %s\n"), gas);
|
||||
}
|
||||
o2 = newo2;
|
||||
he = newhe;
|
||||
|
@ -538,7 +538,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
lastdepth = dp->depth;
|
||||
} while ((dp = dp->next) != NULL);
|
||||
len = strlen(buffer);
|
||||
snprintf(buffer + len, sizeof(buffer) - len, tr("Gas consumption:\n"));
|
||||
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC","Gas consumption:\n"));
|
||||
for (gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) {
|
||||
double volume;
|
||||
const char *unit;
|
||||
|
@ -549,7 +549,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
volume = get_volume_units(consumption[gasidx], NULL, &unit);
|
||||
get_gas_string(dive->cylinder[gasidx].gasmix.o2.permille,
|
||||
dive->cylinder[gasidx].gasmix.he.permille, gas, sizeof(gas));
|
||||
snprintf(buffer + len, sizeof(buffer) - len, tr("%.0f%s of %s\n"), volume, unit, gas);
|
||||
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC","%.0f%s of %s\n"), volume, unit, gas);
|
||||
}
|
||||
dive->notes = strdup(buffer);
|
||||
}
|
||||
|
@ -745,9 +745,9 @@ int validate_gas(const char *text, int *o2_p, int *he_p)
|
|||
if (!*text)
|
||||
return 0;
|
||||
|
||||
if (!strcasecmp(text, tr("air"))) {
|
||||
o2 = O2_IN_AIR; he = 0; text += strlen(tr("air"));
|
||||
} else if (!strncasecmp(text, tr("ean"), 3)) {
|
||||
if (!strcasecmp(text, translate("gettextFromC","air"))) {
|
||||
o2 = O2_IN_AIR; he = 0; text += strlen(translate("gettextFromC","air"));
|
||||
} else if (!strncasecmp(text, translate("gettextFromC","ean"), 3)) {
|
||||
o2 = get_permille(text+3, &text); he = 0;
|
||||
} else {
|
||||
o2 = get_permille(text, &text); he = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue