summaryrefslogtreecommitdiffstats
path: root/uemis-downloader.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-10-11 09:42:59 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-10-11 10:03:03 +0900
commit99846da77f960a72d615c82bf5c5881a2df83616 (patch)
tree1c55ef332daff3b69690bec6be7bd7d0a0a10387 /uemis-downloader.c
parenta2afe4128082b603add2b2be83f97ff78e0d0169 (diff)
downloadsubsurface-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 'uemis-downloader.c')
-rw-r--r--uemis-downloader.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/uemis-downloader.c b/uemis-downloader.c
index 1fec353a8..5d7881291 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -17,15 +17,17 @@
#include <pthread.h>
#include <unistd.h>
#include <string.h>
+#include <glib/gi18n.h>
+
#include "uemis.h"
#include "dive.h"
#include "divelist.h"
#include "display.h"
#include "display-gtk.h"
-#define ERR_FS_ALMOST_FULL "Uemis Zurich: File System is almost full\nDisconnect/reconnect the dive computer\nand try again"
-#define ERR_FS_FULL "Uemis Zurich: File System is full\nDisconnect/reconnect the dive computer\nand try again"
-#define ERR_FS_SHORT_WRITE "Short write to req.txt file\nIs the Uemis Zurich plugged in correctly?"
+#define ERR_FS_ALMOST_FULL N_("Uemis Zurich: File System is almost full\nDisconnect/reconnect the dive computer\nand try again")
+#define ERR_FS_FULL N_("Uemis Zurich: File System is full\nDisconnect/reconnect the dive computer\nand try again")
+#define ERR_FS_SHORT_WRITE N_("Short write to req.txt file\nIs the Uemis Zurich plugged in correctly?")
#define BUFLEN 2048
#define NUM_PARAM_BUFS 6
#define UEMIS_TIMEOUT 100000
@@ -262,7 +264,7 @@ static void show_progress(char *buf)
while (*p != '{' && t < tmp + 9)
*t++ = *p++;
*t = '\0';
- uemis_info("Reading dive %s", tmp);
+ uemis_info(_("Reading dive %s"), tmp);
}
}
}
@@ -301,11 +303,11 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
fprintf(debugfile,"::w req.txt \"%s\"\n", sb);
#endif
if (write(reqtxt_file, sb, strlen(sb)) != strlen(sb)) {
- *error_text = ERR_FS_SHORT_WRITE;
+ *error_text = _(ERR_FS_SHORT_WRITE);
return FALSE;
}
if (! next_file(number_of_files)) {
- *error_text = ERR_FS_FULL;
+ *error_text = _(ERR_FS_FULL);
more_files = FALSE;
}
trigger_response(reqtxt_file, "n", filenr, file_length);
@@ -334,7 +336,7 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
assembling_mbuf = FALSE;
if (assembling_mbuf) {
if (! next_file(number_of_files)) {
- *error_text = ERR_FS_FULL;
+ *error_text = _(ERR_FS_FULL);
more_files = FALSE;
assembling_mbuf = FALSE;
}
@@ -343,7 +345,7 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
}
} else {
if (! next_file(number_of_files - 1)) {
- *error_text = ERR_FS_FULL;
+ *error_text = _(ERR_FS_FULL);
more_files = FALSE;
assembling_mbuf = FALSE;
searching = FALSE;
@@ -554,7 +556,7 @@ static char *do_uemis_download(struct argument_block *args)
buffer_add(xml_buffer, &xml_buffer_size, "<dives type='uemis'><string></string>\n<list>\n");
uemis_info("Init Communication");
if (! uemis_init(mountpath))
- return "Uemis init failed";
+ return _("Uemis init failed");
if (! uemis_get_answer(mountpath, "getDeviceId", 0, 1, &result))
goto bail;
deviceid = strdup(param_buff[0]);
@@ -587,7 +589,7 @@ static char *do_uemis_download(struct argument_block *args)
break;
/* finally, if the memory is getting too full, maybe we better stop, too */
if (progress_bar_fraction > 0.85) {
- result = ERR_FS_ALMOST_FULL;
+ result = _(ERR_FS_ALMOST_FULL);
break;
}
/* clean up mbuf */
@@ -601,7 +603,7 @@ static char *do_uemis_download(struct argument_block *args)
goto bail;
if (! strcmp(param_buff[0], "error")) {
if (! strcmp(param_buff[2],"Out of Memory"))
- result = ERR_FS_FULL;
+ result = _(ERR_FS_FULL);
else
result = param_buff[2];
}