Commit graph

69 commits

Author SHA1 Message Date
Dirk Hohndel
07a2514d9f Uemis downloader: don't try to download divespots that weren't set
This should cut down on redundant calls to download divespot #0.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-18 13:16:57 -07:00
Dirk Hohndel
f7eb6f6b58 Uemis downloader: minor coding style updates
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-18 13:16:57 -07:00
glerch
682e23775c Uemis downloader: bug fix in uemis set dive location
Assuring that ds isn't NULL, had a few cases
that made SubSurface crash. Have not investigated
the root cause but it's likely that it is related to
the Uemis specific code. Nevertheless, checking ds
non NULL is certainly not a bad thing to do.

Signed-off-by: glerch <guido.lerch@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10 12:44:12 -07:00
glerch
c0cbafdc93 Uemis downloader: new find divespot by diveid
New routine to support finding a dive spot based on the dive id,
this is needed due to the weird way Uemis is providing data.
This function will be used in the uemis-downloader.c within
do_uemis_import.

Signed-off-by: glerch <guido.lerch@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10 12:28:02 -07:00
Robert C. Helling
22bfc4936f Add explicit casts to silence compiler warnings
clang complais when converting (char *) to (unsigned char *), so tell
it it's fine.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-28 08:16:37 -07:00
Dirk Hohndel
31b8dffbb1 Uemis downloader: don't use bogus sensor data from Uemis
Sometimes we get a sensor number of 255 - which gets turned into a tank
index and then causes all kinds of havoc. Simply refuse to use a tank
number larger than the maximum Subsurface has been compiled for.

Oh, and use consistent variables to handle these unsigned 8 bit integers.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-21 23:31:03 -07:00
Dirk Hohndel
3953800fe6 Uemis downloader: don't discard samples too early
We do a good job in the fixup_dive() code to make sure we don't add long
surface tails to the dives, so don't try too hard to guess the correct
last sample in the Uemis specific code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-20 21:37:16 -07:00
Dirk Hohndel
d032c2a5c5 Change UEMIS infrastructure to use dive sites
Which is actually much more natural to the way the UEMIS stores things...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 22:45:47 -08:00
Tim Wootton
93d59c22d7 Match agreed captalisation style
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-25 07:57:33 -08:00
Dirk Hohndel
48a8c98913 Correct Uemis extra data
When dropping the pointless surface samples at the end of the dive we
stopped going through all the samples - for that reason the offset at the
end to find the data in the footer was wrong.

Now the extra data all seems to match what I can see on my screen after
the dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-21 21:43:36 -08:00
Dirk Hohndel
74dd93c6a4 Improve Uemis debug output for short data blocks
It's useful to know just how short the read was when trying to figure out
what went wrong.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-21 21:42:55 -08:00
Dirk Hohndel
df0057d262 Extract some useful extra data from Uemis SDA
This is just a proof of concept for this patch series, mainly designed to
show how the extra data would be used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 13:01:58 -08:00
Henrik Brautaset Aronsen
630ec88dd4 Be more consistent in partial pressure naming
Lets just use pO₂ instead of PO2, ppO2, ppO₂, PO₂.
They all mean the same, but it's better to be
consistent

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-23 06:48:54 +08:00
Dirk Hohndel
eef3d63de6 Uemis GPS location tracking seems backwards
I can't figure out how this ever worked...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-08 16:55:25 -08:00
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 20:09:57 -08:00
Linus Torvalds
23baf20f56 Use "rint()" instead of rounding manually with "+ 0.5"
rint() is "round to nearest integer", and does a better job than +0.5
(followed by the implicit truncation inherent in integer casting).  We
already used 'rint()' for values that could be negative (where +0.5 is
actively wrong), let's just make it consistent.

Of course, as is usual for the messy C math functions, it depends on the
current rounding mode.  But the default round-to-nearest is what we want
and use, and the functions that explicitly always round to nearest
aren't standard enough to worry about.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 17:41:49 -08:00
Anton Lundin
33391a77e9 Convert the C code to using stdbool and true/false
Earlier we converted the C++ code to using true/false, and this converts
the C code to using the same style.

We already depended on stdbool.h in subsurfacestartup.[ch], and we build
with -std=gnu99 so nobody could build subsurface without a c99 compiler.

[Dirk Hohndel: small change suggested by Thiago Macieira: don't include
               stdbool.h for C++]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 09:34:50 +07:00
Dirk Hohndel
04aa563cca Fix Uemis temperature conversion
In commit 3fd39a7a87 ("Remove some constants and use helpers instead")
Anton missed the fact that the Uemis gives temperatures in the handy unit
of "centi degree C". Now things work again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 16:00:28 -08:00
Anton Lundin
3fd39a7a87 Remove some constants and use helpers instead
We have allot of helpers, use them instead of local variants.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-27 08:30:12 -08:00
Dirk Hohndel
193d20c479 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>
2013-10-09 22:51:59 -07:00
Dirk Hohndel
2627ea927d Next round of code removal and header cleanup
None of this is used anywhere

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-07 16:55:43 -07:00
Dirk Hohndel
4d3e74a236 Trying to switch to Qt translation
This compiles and looks about right, but it doesn't appear to work, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:42:32 -07:00
Dirk Hohndel
4b12f28ca4 First steps towards removing glib dependencies
- remove the build flags and libraries from the Makefile / Configure.mk
- remove the glib types (gboolean, gchar, gint64, gint)
- comment out / hack around gettext
- replace the glib file helper functions
- replace g_ascii_strtod
- replace g_build_filename
- use environment variables instead of g_get_home_dir() & g_get_user_name()
- comment out GPS string parsing (uses glib utf8 macros)

This needs massive cleanup, but it's a snapshot of what I have right now, in
case people want to look at it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:41:44 -07:00
Dirk Hohndel
a70a889872 Fix some of the gcc-4.8 warnings
Most of the warnings are IMHO false positives:
e.g.: an enum variable is initialized in a switch statement that has a case for
      each possible enum value - yet gcc 4.8 warns that it could be used
      uninitialized;
or:   two variables are initialized together in the code - second one of them
      is previously initialized to -1 at declaration time, both are initialized
      in an if (second one == -1) clause - so they are guaranteed to both be
      initialized...
I did not "fix" those as the code is actually correct.

But there are three spots where it catches things that could indeed go wrong
(with odd input data in one of them).

This commit also adds a check to only call g_type_init() for older versions of
glib as in newer ones it is deprecated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-07 20:31:49 -07:00
Linus Torvalds
926fcef2a1 Do more dive fixup for each dive computer
In commit b6c9301e58 ("Move more dive computer filled data to the
divecomputer structure") we moved the fields that get filled in by the
dive computers to be per-divecomputer data structures.

This patch re-creates some of those fields back in the "struct dive",
but now the fields are initialized to be a reasonable average from the
dive computer data.  We already did some of this for the temperature
min/max fields for the statistics, so this just continues that trend.

The goal is to make it easy to look at "dive values" without having to
iterate over dive computers every time you do.  Just do it once in
"fixup_dive()" instead.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 18:22:30 -08:00
Dirk Hohndel
e3a8ed5183 Massive cleanup
Mostly coding style and whitespace changes plus making lots of functions
static that have no need to be extern. This also helped find a bit of code
that is actually no longer used.

This should have absolutely no functional impact - all changes should be
purely cosmetic. But it removes a bunch of lines of code and makes the
rest easier to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-30 08:31:53 +11:00
Jan Schubert
50d0391dfb Centralization for Kelvin and Standardization to milliKelvin
This centralizes all occurrences of Kelvin to dive.h and standardizes all
usages to milliKelvin.

[Dirk Hohndel: renamed the constant plus minor white space cleanup]

Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 15:00:52 -08:00
Linus Torvalds
b6c9301e58 Move more dive computer filled data to the divecomputer structure
This moves the fields 'duration', 'surfacetime', 'maxdepth',
'meandepth', 'airtemp', 'watertemp', 'salinity' and 'surface_pressure'
to the per-divecomputer data structure.  They are filled in by the dive
computer, and normally not edited.

NOTE! All actual *use* of this data was then changed from dive->field to
dive->dc.field programmatically with a shell-script and sed, and the
result then edited for details.  So while the XML save and restore code
has been updated, all the displaying etc will currently always just show
the first dive computer entry.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 12:55:33 -08:00
Dirk Hohndel
3e5a508b15 Ensure each dive has its own copy of the location text (UEMIS importer)
Since multiple dives can reference the same divesite we need to do the
strdup when the value gets assigned, not when it gets passed into the
helper function.

This also validates the location string as on my divecomputer there is an
invalid divespot 0 that has a corrupted UTF8 string as location name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 11:57:00 -08:00
Linus Torvalds
d720e133d8 First step in cleaning up cylinder pressure sensor logic
This clarifies/changes the meaning of our "cylinderindex" entry in our
samples. It has been rather confused, because different dive computers
have done things differently, and the naming really hasn't helped.

There are two totally different - and independent - cylinder "indexes":

 - the pressure sensor index, which indicates which cylinder the sensor
   data is from.

 - the "active cylinder" index, which indicates which cylinder we actually
   breathe from.

These two values really are totally independent, and have nothing
what-so-ever to do with each other. The sensor index may well be fixed:
many dive computers only support a single pressure sensor (whether
wireless or wired), and the sensor index is thus always zero.

Other dive computers may support multiple pressure sensors, and the gas
switch event may - or may not - indicate that the sensor changed too. A
dive computer might give the sensor data for *all* cylinders it can read,
regardless of which one is the one we're actively breathing. In fact, some
dive computers might give sensor data for not just *your* cylinder, but
your buddies.

This patch renames "cylinderindex" in the samples as "sensor", making it
quite clear that it's about which sensor index the pressure data in the
sample is about.

The way we figure out which is the currently active gas is with an
explicit has change event. If a computer (like the Uemis Zurich) joins the
two concepts together, then a sensor change should also create a gas
switch event. This patch also changes the Uemis importer to do that.

Finally, it should be noted that the plot info works totally separately
from the sample data, and is about what we actually *display*, not about
the sample pressures etc. In the plot info, the "cylinderindex" does in
fact mean the currently active cylinder, and while it is initially set to
match the sensor information from the samples, we then walk the gas change
events and fix it up - and if the active cylinder differs from the sensor
cylinder, we clear the sensor data.

[Dirk Hohndel:  this conflicted with some of my recent changes - I think
		I merged things correctly...]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30 20:44:47 -08:00
Dirk Hohndel
e3ab1c0701 Update deco handling
This commit makes deco handling in Subsurface more compatible with the way
libdivecomputer creates the data. Previously we assumed that having a
stopdepth or stoptime and no ndl meant that we were in deco. But
libdivecomputer supports many dive computers that provide the deco state
of the diver but with no information about the next stop or the time
needed there. In order to be able to model this in Subsurface this adds an
in_deco flag to the samples. This is only stored to the XML file when it
changes so it doesn't add much overhead but will allow us to display some
deco information on dive computers like the Atomic Aquatics Cobalt or many
of the Suuntos (among others).

The commit also removes the old event based deco code that was commented
out already. And fixes the code so that the deco / ndl information is
stored for the very last sample as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30 18:17:21 -08:00
Dirk Hohndel
9d80e7bfe4 Add CNS and pO2 tracking in the samples
This adds the new members to the sample structure and fills them from
supported dive computers (Uemis SDA and OSTC / Shearwater Predator,
assuming you have libdivecomputer 0.3).

Save relvant values of this to the XML file and load it back. Handle the
new fields when merging dives.

At this stage we don't DO anything with this, all we do is extract them
from the dive computer, save them to the XML file and load them back.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07 21:03:39 -08:00
Dirk Hohndel
a72597189d Initialize helper structure to 0s
We check the pointers that are part of this structure for NULL before
accessing them - but that means we need to zero out the structure for this
to work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07 20:06:07 -08:00
Linus Torvalds
5e5e3460ac Turn latitude and longitude into integer micro-degree values
This actually makes us internally use 'micro-degrees' for latitude and
longitude, and we never turn them into floating point either at parse
time or save time.

That said, the Uemis downloader internally does still use atof() when
converting things, which is likely a bug (locale issues and all that),
but I'll ask Dirk to check it out.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-05 10:34:02 -08:00
Dirk Hohndel
ebd27b798a Support the new NDL / deco code in the Uemis downloader
This also replaces the old heuristic for when we are in deco with the
(hopefully correct) bits in the sample flags.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-04 21:06:54 -08:00
Dirk Hohndel
79c2b00212 Make more uemis functions static
These are no longer called from other parts of the code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-30 14:30:24 -07:00
Dirk Hohndel
4c4dff7683 Convert Uemis downloader to directly create dives
The initial downloader reused the XML parsing of SDA files that was
implemented early in order to support the information extracted from the
SDA with the java applet. But creating this intermediary XML file and
handing it off to the XML import function always seemed like an ugly way
to do things. This became even more obvious when adding more features to
the Uemis downloader.

This commit completely changes the downloader to instead create dives and
record them directly.

This also adds support for divespots (which are stored in a seperate
database that needs to be queried after the divelog and dive entries have
been combined - the Uemis firmware clearly was written by monkeys on
crack - oh wait: I'm trusting these same people to get the deco right?).

This commit leaves the SDA import capability in the XML parser intact.
I'll remove that later. Because of this it actually adds a few lines of
code, but the overall change will be a substantial code deletion.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-30 13:41:58 -07:00
Dirk Hohndel
a79b74ed36 Track Uemis last dive downloaded on a per data-file basis
Actually, it's even better than that. Thanks to the new divecomputer
datastructure we can now simply look up in the dive_table which dives have
been downloaded from this specific Uemis SDA.

This patch removes the old gconf based code - which leads to one
unfortunate problem: the first time a Uemis SDA owner runs this version of
Subsurface against their data file ALL dives will be downloaded again
(which may not be a bad thing as we have improved a few other details of
Uemis support so now they get their deco information, surface pressure and
other data that we have started to support since 2.1). Still, this is not
ideal. But I didn't want to keep the legacy code around since this new
solution is so much cleaner.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-28 22:02:03 -07:00
Dirk Hohndel
10fac7a6af Updating events for libdivecomputer 0.3 (and tracking uemis support)
I was a little too eager to add the deco feature to Subsurface. Jef and I
went back and forth a few more times and the definition of those events
changed. I guess I shouldn't have commited that code until the
corresponding libdivecomputer code had been pushed.

This commit now brings us in sync with the current master of
libdivecomputer (but should compile with 0.2 as well - only deco events
won't work then).

One issue that I see is that deco / ndl aren't really a good fit for the
event model. I actually disabled the drawing of the little yellow
triangles for ndl events as for example on the Uemis those events are
created whenever the remaining non stop time changes - and that can be
every few seconds.

The correct solution may be to treat this as a function of the samples,
but for now this works and is tested with both OSTC and Uemis SDA.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-28 21:13:21 -07:00
Linus Torvalds
1ca1fe7994 Improve on divecomputer data handling
This simplifies the vendor/product fields into just a single "model"
string for the dive computer, since we can't really validly ever use it
any other way anyway.

Also, add 'deviceid' and 'diveid' fields: they are just 32-bit hex
values that are unique for that particular dive computer model.  For
libdivecomputer, they are basically the first word of the SHA1 of the
data that libdivecomputer gives us.

(Trying to expose it in some other way is insane - different dive
computers use different models for the ID, so don't try to do some kind
of serial number or something like that)

For the Uemis Zurich, which doesn't use the libdivecomputer import, we
currently only set the model name.  The computer does have some kind of
device ID string, and we could/should just do the same "SHA1 over the
ID" to give it a unique ID, but the pseudo-xml parsing confuses me, so
I'll let Dirk fix that up.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-25 13:05:11 -08:00
Linus Torvalds
25b4fee655 Move events and samples into a 'struct divecomputer'
For now we only have one fixed divecomputer associated with each dive,
so this doesn't really change any current semantics.  But it will make
it easier for us to associate a dive with multiple dive computers.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-23 19:36:27 -08:00
Linus Torvalds
a9786564c2 Allocate dive samples separately from 'struct dive'
We used to avoid some extra allocations by just allocating the dive
samples as part of the 'struct dive' allocation itself, but that ends up
complicating things, and will make it impossible to have multiple
different sets of samples (for multiple dive computers).

So stop doing it. Just allocate the dive samples array separately.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-23 19:33:39 -08:00
Dirk Hohndel
05b55542c8 Extract salinity for Uemis SDA and improve depth calculation
THe Uemis SDA allows the user to set it up for salt water and fresh water
use. We should take this into consideration for the water pressure to
depth conversion.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-12 21:17:52 +01:00
Dirk Hohndel
e07531dd10 Convert Uemis deco stop hold time to seconds
This is actually stored in minutes (which seems odd, given they allocate
16 bits for it... how much deco do these people want to be prepared for??)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10 11:54:15 +01:00
Dirk Hohndel
cc53a0cf5c Use correct surface pressure to detect ceiling with Uemis Zurich
The dive data contains the surface pressure prior to the dive, and that is
what we need to compare p_amb_tol to, not the standard 1013mbar.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10 11:54:14 +01:00
Dirk Hohndel
4da3168768 Create the correct ceiling events for Uemis Zurich
The hold_depth field is rather misleading as it normally gives the safety
stop depth and only when the p_amb_tol goes "below the surface" does it
switch to showing the first deco stop depth.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10 11:54:14 +01:00
Dirk Hohndel
601ac0c362 Display air temperature in the info notebook page
So far we don't parse air temperature data via libdivecomputer. Nor are we
set up to allow the user to manually enter it. We can parse it when
downloading from a Uemis Zurich, though.

This feature was suggested via trac.hohndel.org; this commit implements
only part of what is requested there, so I simply reference the ticket
here without closing it.

References ticket #7

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-28 13:17:12 -07:00
Dirk Hohndel
b8a4730661 Expand Uemis Zurich download support
With this commit we not only use the getDivelogs command but also the
getDive command for each of the dives that was downloaded. Oddly, that
makes quite a bit of redundant (and at times slightly contradictory) data
available, but also many new things.

We now get weight, suit and notes that were stored with a dive in the
logbook on the divecomputer. There are a ton more data available that we
don't use, yet. For example information about altitude, a decoindex, dive
type and dive activity, other equipment information, etc.

I still need to decide how much of this I want to make available in
Subsurface (and how I want to present this - after all most of this is not
available from other dive computers).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-25 20:15:39 -07:00
Dirk Hohndel
016365c5f1 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>
2012-10-21 11:40:30 -07:00
Dirk Hohndel
99846da77f Conversion to gettext to allow localization
This is just the first step - convert the string literals, try to catch
all the places where this isn't possible and the program needs to convert
string constants at runtime (those are the N_ macros).

Add a very rough first German localization so I can at least test what I
have done. Seriously, I have never used a localized OS, so I am certain
that I have many of the 'standard' translations wrong. Someone please take
over :-)

Major issues with this:

- right now it hardcodes the search path for the message catalog to be
  ./locale - that's of course bogus, but it works well while doing initial
  testing. Once the tooling support is there we just should use the OS
  default.

- even though de_DE defaults to ISO-8859-15 (or ISO-8859-1 - the internets
  can't seem to agree) I went with UTF-8 as that is what Gtk appears to
  want to use internally. ISO-8859-15 encoded .mo files create funny
  looking artefacts instead of Umlaute.

- no support at all in the Makefile - I was hoping someone with more
  experience in how to best set this up would contribute a good set of
  Makefile rules - likely this will help fix the first issue in that it
  will also install the .mo file(s) in the correct place(s)

  For now simply run

  msgfmt -c -o subsurface.mo deutsch.po

  to create the subsurface.mo file and then move it to
  ./locale/de_DE.UTF-8/LC_MESSAGES/subsurface.mo

  If you make changes to the sources and need to add new strings to be
  translated, this is what seems to work (again, should be tooled through
  the Makefile):

  xgettext -o subsurface-new.pot -s -k_ -kN_ --add-comments="++GETTEXT" *.c
  msgmerge -s -U po/deutsch.po subsurface-new.pot

  If you do this PLEASE do one commit that just has the new msgid as
  changes in line numbers create a TON of diff-noise. Do changes to
  translations in a SEPARATE commit.

- no testing at all on Windows or Mac
  It builds on Windows :-)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11 10:03:03 +09:00