summaryrefslogtreecommitdiffstats
path: root/equipment.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 /equipment.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 'equipment.c')
-rw-r--r--equipment.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/equipment.c b/equipment.c
index e30f40d1e..1a6de41d7 100644
--- a/equipment.c
+++ b/equipment.c
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>
+#include <glib/gi18n.h>
#include "dive.h"
#include "display.h"
@@ -540,7 +541,7 @@ static void set_one_weightsystem(void *_data, GtkListStore *model, GtkTreeIter *
weightsystem_t *ws = _data;
gtk_list_store_set(model, iter,
- WS_DESC, ws->description ? : "unspecified",
+ WS_DESC, ws->description ? : _("unspecified"),
WS_WEIGHT, ws->weight.grams,
-1);
}
@@ -818,11 +819,11 @@ static struct ws_info {
const char *name;
int grams;
} ws_info[100] = {
- { "integrated", 0 },
- { "belt", 0 },
- { "ankle", 0 },
- { "bar", 0 },
- { "clip-on", 0 },
+ { N_("integrated"), 0 },
+ { N_("belt"), 0 },
+ { N_("ankle"), 0 },
+ { N_("bar"), 0 },
+ { N_("clip-on"), 0 },
};
static void fill_ws_list(GtkListStore *store)
@@ -833,7 +834,7 @@ static void fill_ws_list(GtkListStore *store)
while (info->name) {
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
- 0, info->name,
+ 0, _(info->name),
1, info->grams,
-1);
info++;
@@ -922,7 +923,7 @@ static void cylinder_widget(GtkWidget *vbox, struct cylinder_widget *cylinder, G
* Cylinder type: description, size and
* working pressure
*/
- frame = gtk_frame_new("Cylinder");
+ frame = gtk_frame_new(_("Cylinder"));
hbox = gtk_hbox_new(FALSE, 3);
gtk_container_add(GTK_CONTAINER(frame), hbox);
@@ -956,12 +957,12 @@ static void cylinder_widget(GtkWidget *vbox, struct cylinder_widget *cylinder, G
/*
* Cylinder start/end pressures
*/
- hbox = frame_box("Pressure", vbox);
+ hbox = frame_box(_("Pressure"), vbox);
- widget = labeled_spinbutton(hbox, "Start", 0, 5000, 1);
+ widget = labeled_spinbutton(hbox, _("Start"), 0, 5000, 1);
cylinder->start = widget;
- widget = labeled_spinbutton(hbox, "End", 0, 5000, 1);
+ widget = labeled_spinbutton(hbox, _("End"), 0, 5000, 1);
cylinder->end = widget;
cylinder->pressure_button = gtk_check_button_new();
@@ -971,7 +972,7 @@ static void cylinder_widget(GtkWidget *vbox, struct cylinder_widget *cylinder, G
/*
* Cylinder gas mix: Air, Nitrox or Trimix
*/
- hbox = frame_box("Gasmix", vbox);
+ hbox = frame_box(_("Gasmix"), vbox);
widget = labeled_spinbutton(hbox, "O"UTF8_SUBSCRIPT_2 "%", 1, 100, 0.1);
cylinder->o2 = widget;
@@ -1008,7 +1009,7 @@ static void ws_widget(GtkWidget *vbox, struct ws_widget *ws_widget, GtkListStore
/*
* weight_system: description and weight
*/
- frame = gtk_frame_new("Weight");
+ frame = gtk_frame_new(_("Weight"));
hbox = gtk_hbox_new(FALSE, 3);
gtk_container_add(GTK_CONTAINER(frame), hbox);
@@ -1058,7 +1059,7 @@ static int edit_cylinder_dialog(GtkWidget *w, int index, cylinder_t *cyl, int w_
return 0;
*cyl = dive->cylinder[index];
- dialog = gtk_dialog_new_with_buttons("Cylinder",
+ dialog = gtk_dialog_new_with_buttons(_("Cylinder"),
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
@@ -1113,7 +1114,7 @@ static int edit_weightsystem_dialog(GtkWidget *w, int index, weightsystem_t *ws,
return 0;
*ws = dive->weightsystem[index];
- dialog = gtk_dialog_new_with_buttons("Weight System",
+ dialog = gtk_dialog_new_with_buttons(_("Weight System"),
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
@@ -1374,7 +1375,7 @@ static void size_data_func(GtkTreeViewColumn *col,
if (size)
snprintf(buffer, sizeof(buffer), "%.1f", size);
else
- strcpy(buffer, "unkn");
+ strcpy(buffer, _("unkn"));
g_object_set(renderer, "text", buffer, NULL);
}
@@ -1394,7 +1395,7 @@ static void weight_data_func(GtkTreeViewColumn *col,
if (grams)
snprintf(buffer, sizeof(buffer), "%.*f", decimals, value);
else
- strcpy(buffer, "unkn");
+ strcpy(buffer, _("unkn"));
g_object_set(renderer, "text", buffer, NULL);
}
@@ -1481,11 +1482,11 @@ GtkWidget *cylinder_list_widget(int w_idx)
"enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH,
NULL);
- tree_view_column(tree_view, CYL_DESC, "Type", NULL, ALIGN_LEFT | UNSORTABLE);
- tree_view_column(tree_view, CYL_SIZE, "Size", size_data_func, ALIGN_RIGHT | UNSORTABLE);
- tree_view_column(tree_view, CYL_WORKP, "MaxPress", pressure_data_func, ALIGN_RIGHT | UNSORTABLE);
- tree_view_column(tree_view, CYL_STARTP, "Start", pressure_data_func, ALIGN_RIGHT | UNSORTABLE);
- tree_view_column(tree_view, CYL_ENDP, "End", pressure_data_func, ALIGN_RIGHT | UNSORTABLE);
+ tree_view_column(tree_view, CYL_DESC, _("Type"), NULL, ALIGN_LEFT | UNSORTABLE);
+ tree_view_column(tree_view, CYL_SIZE, _("Size"), size_data_func, ALIGN_RIGHT | UNSORTABLE);
+ tree_view_column(tree_view, CYL_WORKP, _("MaxPress"), pressure_data_func, ALIGN_RIGHT | UNSORTABLE);
+ tree_view_column(tree_view, CYL_STARTP, _("Start"), pressure_data_func, ALIGN_RIGHT | UNSORTABLE);
+ tree_view_column(tree_view, CYL_ENDP, _("End"), pressure_data_func, ALIGN_RIGHT | UNSORTABLE);
tree_view_column(tree_view, CYL_O2, "O" UTF8_SUBSCRIPT_2 "%", percentage_data_func, ALIGN_RIGHT | UNSORTABLE);
tree_view_column(tree_view, CYL_HE, "He%", percentage_data_func, ALIGN_RIGHT | UNSORTABLE);
return tree_view;
@@ -1509,8 +1510,8 @@ GtkWidget *weightsystem_list_widget(int w_idx)
"enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH,
NULL);
- tree_view_column(tree_view, WS_DESC, "Type", NULL, ALIGN_LEFT | UNSORTABLE);
- tree_view_column(tree_view, WS_WEIGHT, "weight",
+ tree_view_column(tree_view, WS_DESC, _("Type"), NULL, ALIGN_LEFT | UNSORTABLE);
+ tree_view_column(tree_view, WS_WEIGHT, _("weight"),
weight_data_func, ALIGN_RIGHT | UNSORTABLE);
return tree_view;
@@ -1568,7 +1569,7 @@ GtkWidget *equipment_widget(int w_idx)
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
- frame = gtk_frame_new("Cylinders");
+ frame = gtk_frame_new(_("Cylinders"));
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, FALSE, 3);
framebox = gtk_vbox_new(FALSE, 3);
@@ -1605,7 +1606,7 @@ GtkWidget *equipment_widget(int w_idx)
tree_view = weightsystem_list_create(w_idx);
weightsystem_list[w_idx].tree_view = GTK_TREE_VIEW(tree_view);
- frame = gtk_frame_new("Weight");
+ frame = gtk_frame_new(_("Weight"));
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, FALSE, 3);
framebox = gtk_vbox_new(FALSE, 3);