mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix the way we handle translated event names
Here is what Linus reported: I think you have made a mistake in trying to translate some of libdivecomputer.c Translating some of those things based on locale is *wrong*, because they are saved in the XML file. That covers at least the warnings: they'll get translated when you import them, and then saved to the XML file as that translation, but now if you start subsurface in another locale, they will not get translated back. So translating XML file contents is fundamentally buggy. It just shouldn't be done. So all the "translations" for the event handling are buggy, and generate crap. Please don't do that. Leave them as English. And of course he is absolutely right. However, instead of not translating them at all, this commit fixes things a better way - we now mark the strings for translation but store the original English strings everywhere (in the in-memory data structure as well as in the XML file). Only when we actually display something on the screen (in a tooltip or in the filter dialog) do we actually translate the strings into the native language. This should address both Linus' issue and the desire to have localized event texts. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e47b52ecdb
commit
016365c5f1
3 changed files with 31 additions and 22 deletions
|
@ -74,6 +74,8 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
|||
static void handle_event(struct dive *dive, struct sample *sample, dc_sample_value_t value)
|
||||
{
|
||||
int type, time;
|
||||
/* we mark these for translation here, but we store the untranslated strings
|
||||
* and only translate them when they are displayed on screen */
|
||||
static const char *events[] = {
|
||||
N_("none"), N_("deco"), N_("rbt"), N_("ascent"), N_("ceiling"), N_("workload"),
|
||||
N_("transmitter"), N_("violation"), N_("bookmark"), N_("surface"), N_("safety stop"),
|
||||
|
@ -98,9 +100,9 @@ static void handle_event(struct dive *dive, struct sample *sample, dc_sample_val
|
|||
* Other evens might be more interesting, but for now we just print them out.
|
||||
*/
|
||||
type = value.event.type;
|
||||
name = _("invalid event number");
|
||||
name = N_("invalid event number");
|
||||
if (type < nr_events)
|
||||
name = _(events[type]);
|
||||
name = events[type];
|
||||
|
||||
time = value.event.time;
|
||||
if (sample)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue