Changeset e1ee577 in subsurface


Ignore:
Timestamp:
Jan 17, 2017, 9:15:50 AM (5 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
2226776
Parents:
fe5f15b
git-author:
Linus Torvalds <torvalds@…> (09/20/16 21:30:18)
git-committer:
Dirk Hohndel <dirk@…> (01/17/17 09:15:50)
Message:

Make event string translation when downloading from libdivecomputer more obvious

We had hardcoded the exact translation of the event numbers. They
haven't changed (although we did have what appears to be a spurious
entry for "non stop time" at the end that libdivecomputer doesn't have
an enum for).

Instead, use an explicit array index initializer array, so that it's
obvious that the two match up (and if the sample event numbers ever
change, we should cope with it gracefully).

Signed-off-by: Linus Torvalds <torvalds@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/libdivecomputer.c

    rfe5f15b re1ee577  
    221221         * and only translate them when they are displayed on screen */
    222222        static const char *events[] = {
    223                 QT_TRANSLATE_NOOP("gettextFromC", "none"), QT_TRANSLATE_NOOP("gettextFromC", "deco stop"), QT_TRANSLATE_NOOP("gettextFromC", "rbt"), QT_TRANSLATE_NOOP("gettextFromC", "ascent"), QT_TRANSLATE_NOOP("gettextFromC", "ceiling"), QT_TRANSLATE_NOOP("gettextFromC", "workload"),
    224                 QT_TRANSLATE_NOOP("gettextFromC", "transmitter"), QT_TRANSLATE_NOOP("gettextFromC", "violation"), QT_TRANSLATE_NOOP("gettextFromC", "bookmark"), QT_TRANSLATE_NOOP("gettextFromC", "surface"), QT_TRANSLATE_NOOP("gettextFromC", "safety stop"),
    225                 QT_TRANSLATE_NOOP("gettextFromC", "gaschange"), QT_TRANSLATE_NOOP("gettextFromC", "safety stop (voluntary)"), QT_TRANSLATE_NOOP("gettextFromC", "safety stop (mandatory)"),
    226                 QT_TRANSLATE_NOOP("gettextFromC", "deepstop"), QT_TRANSLATE_NOOP("gettextFromC", "ceiling (safety stop)"), QT_TRANSLATE_NOOP3("gettextFromC", "below floor", "event showing dive is below deco floor and adding deco time"), QT_TRANSLATE_NOOP("gettextFromC", "divetime"),
    227                 QT_TRANSLATE_NOOP("gettextFromC", "maxdepth"), QT_TRANSLATE_NOOP("gettextFromC", "OLF"), QT_TRANSLATE_NOOP("gettextFromC", "pO₂"), QT_TRANSLATE_NOOP("gettextFromC", "airtime"), QT_TRANSLATE_NOOP("gettextFromC", "rgbm"), QT_TRANSLATE_NOOP("gettextFromC", "heading"),
    228                 QT_TRANSLATE_NOOP("gettextFromC", "tissue level warning"), QT_TRANSLATE_NOOP("gettextFromC", "gaschange"), QT_TRANSLATE_NOOP("gettextFromC", "non stop time")
     223                [SAMPLE_EVENT_NONE]                     = QT_TRANSLATE_NOOP("gettextFromC", "none"),
     224                [SAMPLE_EVENT_DECOSTOP]                 = QT_TRANSLATE_NOOP("gettextFromC", "deco stop"),
     225                [SAMPLE_EVENT_RBT]                      = QT_TRANSLATE_NOOP("gettextFromC", "rbt"),
     226                [SAMPLE_EVENT_ASCENT]                   = QT_TRANSLATE_NOOP("gettextFromC", "ascent"),
     227                [SAMPLE_EVENT_CEILING]                  = QT_TRANSLATE_NOOP("gettextFromC", "ceiling"),
     228                [SAMPLE_EVENT_WORKLOAD]                 = QT_TRANSLATE_NOOP("gettextFromC", "workload"),
     229                [SAMPLE_EVENT_TRANSMITTER]              = QT_TRANSLATE_NOOP("gettextFromC", "transmitter"),
     230                [SAMPLE_EVENT_VIOLATION]                = QT_TRANSLATE_NOOP("gettextFromC", "violation"),
     231                [SAMPLE_EVENT_BOOKMARK]                 = QT_TRANSLATE_NOOP("gettextFromC", "bookmark"),
     232                [SAMPLE_EVENT_SURFACE]                  = QT_TRANSLATE_NOOP("gettextFromC", "surface"),
     233                [SAMPLE_EVENT_SAFETYSTOP]               = QT_TRANSLATE_NOOP("gettextFromC", "safety stop"),
     234                [SAMPLE_EVENT_GASCHANGE]                = QT_TRANSLATE_NOOP("gettextFromC", "gaschange"),
     235                [SAMPLE_EVENT_SAFETYSTOP_VOLUNTARY]     = QT_TRANSLATE_NOOP("gettextFromC", "safety stop (voluntary)"),
     236                [SAMPLE_EVENT_SAFETYSTOP_MANDATORY]     = QT_TRANSLATE_NOOP("gettextFromC", "safety stop (mandatory)"),
     237                [SAMPLE_EVENT_DEEPSTOP]                 = QT_TRANSLATE_NOOP("gettextFromC", "deepstop"),
     238                [SAMPLE_EVENT_CEILING_SAFETYSTOP]       = QT_TRANSLATE_NOOP("gettextFromC", "ceiling (safety stop)"),
     239                [SAMPLE_EVENT_FLOOR]                    = QT_TRANSLATE_NOOP3("gettextFromC", "below floor", "event showing dive is below deco floor and adding deco time"),
     240                [SAMPLE_EVENT_DIVETIME]                 = QT_TRANSLATE_NOOP("gettextFromC", "divetime"),
     241                [SAMPLE_EVENT_MAXDEPTH]                 = QT_TRANSLATE_NOOP("gettextFromC", "maxdepth"),
     242                [SAMPLE_EVENT_OLF]                      = QT_TRANSLATE_NOOP("gettextFromC", "OLF"),
     243                [SAMPLE_EVENT_PO2]                      = QT_TRANSLATE_NOOP("gettextFromC", "pO₂"),
     244                [SAMPLE_EVENT_AIRTIME]                  = QT_TRANSLATE_NOOP("gettextFromC", "airtime"),
     245                [SAMPLE_EVENT_RGBM]                     = QT_TRANSLATE_NOOP("gettextFromC", "rgbm"),
     246                [SAMPLE_EVENT_HEADING]                  = QT_TRANSLATE_NOOP("gettextFromC", "heading"),
     247                [SAMPLE_EVENT_TISSUELEVEL]              = QT_TRANSLATE_NOOP("gettextFromC", "tissue level warning"),
     248                [SAMPLE_EVENT_GASCHANGE2]               = QT_TRANSLATE_NOOP("gettextFromC", "gaschange"),
    229249        };
    230250        const int nr_events = sizeof(events) / sizeof(const char *);
     
    236256        type = value.event.type;
    237257        name = QT_TRANSLATE_NOOP("gettextFromC", "invalid event number");
    238         if (type < nr_events)
     258        if (type < nr_events && events[type])
    239259                name = events[type];
    240260#ifdef SAMPLE_EVENT_STRING
Note: See TracChangeset for help on using the changeset viewer.