diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-10-11 09:42:59 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-10-11 10:03:03 +0900 |
commit | 99846da77f960a72d615c82bf5c5881a2df83616 (patch) | |
tree | 1c55ef332daff3b69690bec6be7bd7d0a0a10387 /file.c | |
parent | a2afe4128082b603add2b2be83f97ff78e0d0169 (diff) | |
download | subsurface-99846da77f960a72d615c82bf5c5881a2df83616.tar.gz |
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>
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -4,6 +4,7 @@ #include <stdlib.h> #include <string.h> #include <errno.h> +#include <glib/gi18n.h> #include "dive.h" #include "file.h" @@ -71,7 +72,7 @@ static void suunto_read(struct zip_file *file, GError **error) size = read * 3 / 2; mem = realloc(mem, size); } - parse_xml_buffer("SDE file", mem, read, error, FALSE); + parse_xml_buffer(_("SDE file"), mem, read, error, FALSE); free(mem); } #endif @@ -258,11 +259,11 @@ void parse_file(const char *filename, GError **error, gboolean possible_default_ if (default_filename && ! strcmp(filename, default_filename)) return; - g_warning("Failed to read '%s'.\n", filename); + g_warning(_("Failed to read '%s'.\n"), filename); if (error) { *error = g_error_new(g_quark_from_string("subsurface"), DIVE_ERROR_PARSE, - "Failed to read '%s'", + _("Failed to read '%s'"), filename); } return; |