Hallo Robert, Am 21.02.2017 um 11:44 schrieb Robert Helling: > >> >>> And as I said: I think it’s cleaner to add an event to the dive >>> rather than plot directly to the profile. Simply use >>> >>> structevent*add_event(structdivecomputer*dc,unsignedinttime,inttype,intflags,intvalue,constchar*name) >>> >> Yes, clear. For a test I created a dummy event @25min in this way: >> add_event(&dive->dc, 60*25, SAMPLE_EVENT_AIRTIME, 0, 0, "Minimum gas >> exceeded"); >> >> >> When looking for add_event I stumbled across s.th <http://s.th/>.: >> I know that one has to be careful where and when it is ok to >> translate the name of an event. But my guess is that for this event >> (line 195, diveprofileitem.cpp) we would be allowed to translate it: >> add_event(&displayed_dive.dc, entry->sec, SAMPLE_EVENT_CEILING, -1, >> max / 1000, "planned waypoint above ceiling"); >> >> What do you think? Ok to change this to: >> add_event(&displayed_dive.dc, entry->sec, SAMPLE_EVENT_CEILING, -1, >> max / 1000, translate("gettextFromC", "Planned waypoint above ceiling")); >> >> And then there is another one in planner.c where I'm not sure: >> add_event(dc, lasttime, SAMPLE_EVENT_PO2, 0, po2, "SP change"); >> > > Hmm. I guess, there is no easy answer. There are uses of the name > string like in dive.c: > > structevent*get_next_event(structevent*event,constchar*name) > where we search for events by name (“gaschange” being a prominent > example). This would break if we started translating event names. We > would have at least then to search for translated strings (and that I > would consider quite ugly). > > [Here is a break where I started actually looking into the source > about event names] > > From what I see, I would say, translating event names is wrong. At > least for the internal storage. They should only be translated when > displayed to the user. For that I see for example: > > voidDiveEventItem::setupToolTipString() > { > //wedisplaytheeventonscreen-sotranslate > QStringname=gettextFromC::instance()->tr(internalEvent->name); > in diveeventiteM.cpp > > Maybe my understanding of how the translation works is wrong but I > thought, we can only translate strings that are already known at > compile time (but the actual translation happens at runtime). Please > somebody correct me if I am wrong! > > So, I guess, we actually need to teach all possible event names to the > translation splanned waypointystem. I have no idea how too do that. > Maybe you could look into this? And then make sure, the names only get > translated when displaying them to the user (i.e. event.name always > holds untranslated strings). I think I have it:
QT_TRANSLATE_NOOP is the answer. E.g: add_event(dc, lasttime, SAMPLE_EVENT_PO2, 0, po2, QT_TRANSLATE_NOOP("gettextFromC", "SP change")); I will do a pull request for Dirk for this... Best regards Stefan -- Stefan Fuchs E-Mail: sfu...@gmx.de <mailto:sfu...@gmx.de>
_______________________________________________ subsurface mailing list subsurface@subsurface-divelog.org http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface