Merge branch 'gettext'

Bring all the localization changes into master in preparation for
Subsurface 2.1
This commit is contained in:
Dirk Hohndel 2012-10-15 09:37:09 -07:00
commit 4b9a59a154
29 changed files with 9068 additions and 263 deletions

View file

@ -119,11 +119,14 @@ endif
LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) $(EXTRALIBS) $(LIBZIP) -lpthread -lm
MSGLANGS=$(notdir $(wildcard po/*po))
MSGOBJS=$(addprefix locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo))
OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o \
parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \
gtk-gui.o statistics.o file.o cochran.o $(OSSUPPORT).o $(RESFILE)
$(NAME): $(OBJS)
$(NAME): $(OBJS) $(MSGOBJS)
$(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
install: $(NAME)
@ -152,6 +155,10 @@ install-macosx: $(NAME)
$(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/
$(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/
$(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/
$(INSTALL) -d -m 755 $(addprefix $(MACOSXINSTALL)/Contents/Resources/,$(dir $(MSGOBJS)))
for MSG in $(MSGOBJS); do\
install $$MSG $(MACOSXINSTALL)/Contents/Resources/$$MSG;\
done
file.o: file.c dive.h file.h
$(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) $(XSLT) $(ZIP) -c file.c
@ -212,8 +219,13 @@ uemis-downloader.o: uemis-downloader.c dive.h uemis.h
$(OSSUPPORT).o: $(OSSUPPORT).c display-gtk.h
$(CC) $(CFLAGS) $(OSSUPPORT_CFLAGS) -c $(OSSUPPORT).c
locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po
mkdir -p $(dir $@)
msgfmt -c -o $@ po/$*.po
doc:
$(MAKE) -C Documentation doc
clean:
rm -f $(OBJS) *~ $(NAME) $(NAME).exe
rm -rf locale

3
dive.c
View file

@ -2,6 +2,7 @@
/* maintains the internal dive list structure */
#include <string.h>
#include <stdio.h>
#include <glib/gi18n.h>
#include "dive.h"
@ -614,7 +615,7 @@ static char *merge_text(const char *a, const char *b)
res = malloc(strlen(a) + strlen(b) + 9);
if (!res)
return (char *)a;
sprintf(res, "(%s) or (%s)", a, b);
sprintf(res, _("(%s) or (%s)"), a, b);
return res;
}

1
dive.h
View file

@ -440,6 +440,7 @@ extern const char *star_strings[];
extern const char *default_filename;
extern const char *existing_filename;
extern const char *subsurface_default_filename(void);
extern const char *subsurface_gettext_domainpath(void);
extern void subsurface_command_line_init(gint *, gchar ***);
extern void subsurface_command_line_exit(gint *, gchar ***);
#define AIR_PERMILLE 209

View file

@ -15,6 +15,7 @@
#include <string.h>
#include <time.h>
#include <math.h>
#include <glib/gi18n.h>
#include "divelist.h"
#include "dive.h"
@ -1254,25 +1255,25 @@ static struct divelist_column {
int *visible;
} dl_column[] = {
[DIVE_NR] = { "#", nr_data_func, NULL, ALIGN_RIGHT | UNSORTABLE },
[DIVE_DATE] = { "Date", date_data_func, NULL, ALIGN_LEFT },
[DIVE_DATE] = { N_("Date"), date_data_func, NULL, ALIGN_LEFT },
[DIVE_RATING] = { UTF8_BLACKSTAR, star_data_func, NULL, ALIGN_LEFT },
[DIVE_DEPTH] = { "ft", depth_data_func, NULL, ALIGN_RIGHT },
[DIVE_DURATION] = { "min", duration_data_func, NULL, ALIGN_RIGHT },
[DIVE_DEPTH] = { N_("ft"), depth_data_func, NULL, ALIGN_RIGHT },
[DIVE_DURATION] = { N_("min"), duration_data_func, NULL, ALIGN_RIGHT },
[DIVE_TEMPERATURE] = { UTF8_DEGREE "F", temperature_data_func, NULL, ALIGN_RIGHT, &visible_cols.temperature },
[DIVE_TOTALWEIGHT] = { "lbs", weight_data_func, NULL, ALIGN_RIGHT, &visible_cols.totalweight },
[DIVE_SUIT] = { "Suit", NULL, NULL, ALIGN_LEFT, &visible_cols.suit },
[DIVE_CYLINDER] = { "Cyl", NULL, NULL, 0, &visible_cols.cylinder },
[DIVE_TOTALWEIGHT] = { N_("lbs"), weight_data_func, NULL, ALIGN_RIGHT, &visible_cols.totalweight },
[DIVE_SUIT] = { N_("Suit"), NULL, NULL, ALIGN_LEFT, &visible_cols.suit },
[DIVE_CYLINDER] = { N_("Cyl"), NULL, NULL, 0, &visible_cols.cylinder },
[DIVE_NITROX] = { "O" UTF8_SUBSCRIPT_2 "%", nitrox_data_func, nitrox_sort_func, 0, &visible_cols.nitrox },
[DIVE_SAC] = { "SAC", sac_data_func, NULL, 0, &visible_cols.sac },
[DIVE_OTU] = { "OTU", otu_data_func, NULL, 0, &visible_cols.otu },
[DIVE_LOCATION] = { "Location", NULL, NULL, ALIGN_LEFT },
[DIVE_SAC] = { N_("SAC"), sac_data_func, NULL, 0, &visible_cols.sac },
[DIVE_OTU] = { N_("OTU"), otu_data_func, NULL, 0, &visible_cols.otu },
[DIVE_LOCATION] = { N_("Location"), NULL, NULL, ALIGN_LEFT },
};
static GtkTreeViewColumn *divelist_column(struct DiveList *dl, struct divelist_column *col)
{
int index = col - &dl_column[0];
const char *title = col->header;
const char *title = _(col->header);
data_func_t data_func = col->data;
sort_func_t sort_func = col->sort;
unsigned int flags = col->flags;
@ -1998,8 +1999,12 @@ static void delete_dive_cb(GtkWidget *menuitem, GtkTreePath *path)
static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int button, GdkEventButton *event)
{
GtkWidget *menu, *menuitem, *image;
char editlabel[] = "Edit dives";
char deletelabel[] = "Delete dives";
char editplurallabel[] = N_("Edit dives");
char editsinglelabel[] = N_("Edit dive");
char *editlabel;
char deleteplurallabel[] = N_("Delete dives");
char deletesinglelabel[] = N_("Delete dive");
char *deletelabel;
GtkTreePath *path, *prevpath, *nextpath;
GtkTreeIter iter, previter, nextiter;
int idx, previdx, nextidx;
@ -2011,7 +2016,7 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
gtk_tree_model_get(MODEL(dive_list), &iter, DIVE_INDEX, &idx, -1);
menu = gtk_menu_new();
menuitem = gtk_image_menu_item_new_with_label("Add dive");
menuitem = gtk_image_menu_item_new_with_label(_("Add dive"));
image = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
g_signal_connect(menuitem, "activate", G_CALLBACK(add_dive_cb), NULL);
@ -2019,7 +2024,7 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
if (idx < 0) {
/* mouse pointer is on a trip summary entry */
menuitem = gtk_menu_item_new_with_label("Edit Trip Summary");
menuitem = gtk_menu_item_new_with_label(_("Edit Trip Summary"));
g_signal_connect(menuitem, "activate", G_CALLBACK(edit_trip_cb), path);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
prevpath = gtk_tree_path_copy(path);
@ -2027,7 +2032,7 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
gtk_tree_model_get_iter(MODEL(dive_list), &previter, prevpath)) {
gtk_tree_model_get(MODEL(dive_list), &previter, DIVE_INDEX, &previdx, -1);
if (previdx < 0) {
menuitem = gtk_menu_item_new_with_label("Merge trip with trip above");
menuitem = gtk_menu_item_new_with_label(_("Merge trip with trip above"));
g_signal_connect(menuitem, "activate", G_CALLBACK(merge_trips_cb), path);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
}
@ -2037,12 +2042,12 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
if (gtk_tree_model_get_iter(MODEL(dive_list), &nextiter, nextpath)) {
gtk_tree_model_get(MODEL(dive_list), &nextiter, DIVE_INDEX, &nextidx, -1);
if (nextidx < 0) {
menuitem = gtk_menu_item_new_with_label("Merge trip with trip below");
menuitem = gtk_menu_item_new_with_label(_("Merge trip with trip below"));
g_signal_connect(menuitem, "activate", G_CALLBACK(merge_trips_cb), nextpath);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
}
}
menuitem = gtk_menu_item_new_with_label("Remove Trip");
menuitem = gtk_menu_item_new_with_label(_("Remove Trip"));
g_signal_connect(menuitem, "activate", G_CALLBACK(remove_trip_cb), path);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
} else {
@ -2050,8 +2055,11 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
/* if we right click on selected dive(s), edit or delete those */
if (dive->selected) {
if (amount_selected == 1) {
deletelabel[strlen(deletelabel) - 1] = '\0';
editlabel[strlen(editlabel) - 1] = '\0';
deletelabel = _(deletesinglelabel);
editlabel = _(editsinglelabel);
} else {
deletelabel = _(deleteplurallabel);
editlabel = _(editplurallabel);
}
menuitem = gtk_menu_item_new_with_label(deletelabel);
g_signal_connect(menuitem, "activate", G_CALLBACK(delete_selected_dives_cb), path);
@ -2061,12 +2069,12 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
g_signal_connect(menuitem, "activate", G_CALLBACK(edit_selected_dives_cb), NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
} else {
deletelabel[strlen(deletelabel) - 1] = '\0';
deletelabel = _(deletesinglelabel);
menuitem = gtk_menu_item_new_with_label(deletelabel);
g_signal_connect(menuitem, "activate", G_CALLBACK(delete_dive_cb), path);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
editlabel[strlen(editlabel) - 1] = '\0';
editlabel = _(editsinglelabel);
menuitem = gtk_menu_item_new_with_label(editlabel);
g_signal_connect(menuitem, "activate", G_CALLBACK(edit_dive_from_path_cb), path);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
@ -2077,7 +2085,7 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
int *indices = gtk_tree_path_get_indices(path);
/* top level dive or child dive that is not the first child */
if (depth == 1 || indices[1] > 0) {
menuitem = gtk_menu_item_new_with_label("Create new trip above");
menuitem = gtk_menu_item_new_with_label(_("Create new trip above"));
g_signal_connect(menuitem, "activate", G_CALLBACK(insert_trip_before_cb), path);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
}
@ -2087,24 +2095,24 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
gtk_tree_path_prev(prevpath) &&
gtk_tree_model_get_iter(MODEL(dive_list), &previter, prevpath) &&
gtk_tree_model_iter_n_children(model, &previter)) {
menuitem = gtk_menu_item_new_with_label("Add to trip above");
menuitem = gtk_menu_item_new_with_label(_("Add to trip above"));
g_signal_connect(menuitem, "activate", G_CALLBACK(merge_dive_into_trip_above_cb), path);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
}
if (DIVE_IN_TRIP(dive)) {
if (dive->selected && amount_selected > 1)
menuitem = gtk_menu_item_new_with_label("Remove selected dives from trip");
menuitem = gtk_menu_item_new_with_label(_("Remove selected dives from trip"));
else
menuitem = gtk_menu_item_new_with_label("Remove dive from trip");
menuitem = gtk_menu_item_new_with_label(_("Remove dive from trip"));
g_signal_connect(menuitem, "activate", G_CALLBACK(remove_from_trip_cb), path);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
}
}
}
menuitem = gtk_menu_item_new_with_label("Expand all");
menuitem = gtk_menu_item_new_with_label(_("Expand all"));
g_signal_connect(menuitem, "activate", G_CALLBACK(expand_all_cb), tree_view);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_menu_item_new_with_label("Collapse all");
menuitem = gtk_menu_item_new_with_label(_("Collapse all"));
g_signal_connect(menuitem, "activate", G_CALLBACK(collapse_all_cb), tree_view);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show_all(menu);

View file

@ -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);
@ -947,21 +948,21 @@ static void cylinder_widget(GtkWidget *vbox, struct cylinder_widget *cylinder, G
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
widget = create_spinbutton(hbox, "Size", 0, 300, 0.1);
widget = create_spinbutton(hbox, _("Size"), 0, 300, 0.1);
cylinder->size = GTK_SPIN_BUTTON(widget);
widget = create_spinbutton(hbox, "Pressure", 0, 5000, 1);
widget = create_spinbutton(hbox, _("Pressure"), 0, 5000, 1);
cylinder->pressure = GTK_SPIN_BUTTON(widget);
/*
* 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);

7
file.c
View file

@ -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;

159
gtk-gui.c
View file

@ -3,6 +3,8 @@
/* creates the window and overall layout
* divelist, dive info, equipment and printing are handled in their own source files
*/
#include <libintl.h>
#include <glib/gi18n.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -135,7 +137,7 @@ void report_error(GError* error)
{
error_count++;
char buffer[256];
snprintf(buffer, sizeof(buffer), "Failed to open %i files.", error_count);
snprintf(buffer, sizeof(buffer), _("Failed to open %i files."), error_count);
gtk_label_set(GTK_LABEL(error_label), buffer);
}
}
@ -148,7 +150,7 @@ static GtkFileFilter *setup_filter(void)
gtk_file_filter_add_pattern(filter, "*.sda");
gtk_file_filter_add_pattern(filter, "*.SDA");
gtk_file_filter_add_mime_type(filter, "text/xml");
gtk_file_filter_set_name(filter, "XML file");
gtk_file_filter_set_name(filter, _("XML file"));
return filter;
}
@ -160,7 +162,7 @@ static void file_save_as(GtkWidget *w, gpointer data)
char *current_file;
char *current_dir;
dialog = gtk_file_chooser_dialog_new("Save File As",
dialog = gtk_file_chooser_dialog_new(_("Save File As"),
GTK_WINDOW(main_window),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@ -223,7 +225,7 @@ static gboolean ask_save_changes()
{
GtkWidget *dialog, *label, *content;
gboolean quit = TRUE;
dialog = gtk_dialog_new_with_buttons("Save Changes?",
dialog = gtk_dialog_new_with_buttons(_("Save Changes?"),
GTK_WINDOW(main_window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
GTK_STOCK_NO, GTK_RESPONSE_NO,
@ -233,11 +235,11 @@ static gboolean ask_save_changes()
if (!existing_filename){
label = gtk_label_new (
"You have unsaved changes\nWould you like to save those before closing the datafile?");
_("You have unsaved changes\nWould you like to save those before closing the datafile?"));
} else {
char *label_text = (char*) malloc(sizeof(char) * (94 + strlen(existing_filename)));
sprintf(label_text,
"You have unsaved changes to file: %s \nWould you like to save those before closing the datafile?",
_("You have unsaved changes to file: %s \nWould you like to save those before closing the datafile?"),
existing_filename);
label = gtk_label_new (label_text);
free(label_text);
@ -308,7 +310,7 @@ static void file_open(GtkWidget *w, gpointer data)
GtkFileFilter *filter;
const char *current_default;
dialog = gtk_file_chooser_dialog_new("Open File",
dialog = gtk_file_chooser_dialog_new(_("Open File"),
GTK_WINDOW(main_window),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@ -515,7 +517,7 @@ static void pick_default_file(GtkWidget *w, GtkButton *button)
GtkFileFilter *filter;
struct stat sb;
fs_dialog = gtk_file_chooser_dialog_new("Choose Default XML File",
fs_dialog = gtk_file_chooser_dialog_new(_("Choose Default XML File"),
GTK_WINDOW(main_window),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@ -565,57 +567,57 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
menu_units = output_units;
dialog = gtk_dialog_new_with_buttons("Preferences",
dialog = gtk_dialog_new_with_buttons(_("Preferences"),
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
NULL);
frame = gtk_frame_new("Units");
frame = gtk_frame_new(_("Units"));
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
box = gtk_vbox_new(FALSE, 6);
gtk_container_add(GTK_CONTAINER(frame), box);
create_radio(box, "Depth:",
"Meter", set_meter, (output_units.length == METERS),
"Feet", set_feet, (output_units.length == FEET),
create_radio(box, _("Depth:"),
_("Meter"), set_meter, (output_units.length == METERS),
_("Feet"), set_feet, (output_units.length == FEET),
NULL);
create_radio(box, "Pressure:",
"Bar", set_bar, (output_units.pressure == BAR),
"PSI", set_psi, (output_units.pressure == PSI),
create_radio(box, _("Pressure:"),
_("Bar"), set_bar, (output_units.pressure == BAR),
_("PSI"), set_psi, (output_units.pressure == PSI),
NULL);
create_radio(box, "Volume:",
"Liter", set_liter, (output_units.volume == LITER),
"CuFt", set_cuft, (output_units.volume == CUFT),
create_radio(box, _("Volume:"),
_("Liter"), set_liter, (output_units.volume == LITER),
_("CuFt"), set_cuft, (output_units.volume == CUFT),
NULL);
create_radio(box, "Temperature:",
"Celsius", set_celsius, (output_units.temperature == CELSIUS),
"Fahrenheit", set_fahrenheit, (output_units.temperature == FAHRENHEIT),
create_radio(box, _("Temperature:"),
_("Celsius"), set_celsius, (output_units.temperature == CELSIUS),
_("Fahrenheit"), set_fahrenheit, (output_units.temperature == FAHRENHEIT),
NULL);
create_radio(box, "Weight:",
"kg", set_kg, (output_units.weight == KG),
"lbs", set_lbs, (output_units.weight == LBS),
create_radio(box, _("Weight:"),
_("kg"), set_kg, (output_units.weight == KG),
_("lbs"), set_lbs, (output_units.weight == LBS),
NULL);
frame = gtk_frame_new("Show Columns");
frame = gtk_frame_new(_("Show Columns"));
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5);
box = gtk_hbox_new(FALSE, 6);
gtk_container_add(GTK_CONTAINER(frame), box);
button = gtk_check_button_new_with_label("Temp");
button = gtk_check_button_new_with_label(_("Temp"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.temperature);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(temperature_toggle), NULL);
button = gtk_check_button_new_with_label("Cyl");
button = gtk_check_button_new_with_label(_("Cyl"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.cylinder);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(cylinder_toggle), NULL);
@ -625,44 +627,44 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(nitrox_toggle), NULL);
button = gtk_check_button_new_with_label("SAC");
button = gtk_check_button_new_with_label(_("SAC"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.sac);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(sac_toggle), NULL);
button = gtk_check_button_new_with_label("OTU");
button = gtk_check_button_new_with_label(_("OTU"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.otu);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(otu_toggle), NULL);
button = gtk_check_button_new_with_label("Weight");
button = gtk_check_button_new_with_label(_("Weight"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.totalweight);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(totalweight_toggle), NULL);
button = gtk_check_button_new_with_label("Suit");
button = gtk_check_button_new_with_label(_("Suit"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.suit);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(suit_toggle), NULL);
frame = gtk_frame_new("Divelist Font");
frame = gtk_frame_new(_("Divelist Font"));
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5);
font = gtk_font_button_new_with_font(divelist_font);
gtk_container_add(GTK_CONTAINER(frame),font);
frame = gtk_frame_new("Misc. Options");
frame = gtk_frame_new(_("Misc. Options"));
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5);
box = gtk_hbox_new(FALSE, 6);
gtk_container_add(GTK_CONTAINER(frame), box);
button = gtk_check_button_new_with_label("Automatically group dives in trips");
button = gtk_check_button_new_with_label(_("Automatically group dives in trips"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), autogroup);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(autogroup_toggle), NULL);
frame = gtk_frame_new("Default XML Data File");
frame = gtk_frame_new(_("Default XML Data File"));
gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 5);
box = gtk_hbox_new(FALSE, 6);
gtk_container_add(GTK_CONTAINER(frame), box);
@ -757,7 +759,7 @@ static void selectevents_dialog(GtkWidget *w, gpointer data)
int result;
GtkWidget *dialog, *frame, *vbox, *table;
dialog = gtk_dialog_new_with_buttons("SelectEvents",
dialog = gtk_dialog_new_with_buttons(_("SelectEvents"),
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
@ -766,7 +768,7 @@ static void selectevents_dialog(GtkWidget *w, gpointer data)
/* initialize the function that fills the table */
create_toggle(NULL, NULL, NULL);
frame = gtk_frame_new("Enable / Disable Events");
frame = gtk_frame_new(_("Enable / Disable Events"));
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
@ -797,7 +799,7 @@ static void renumber_dialog(GtkWidget *w, gpointer data)
struct dive *dive;
GtkWidget *dialog, *frame, *button, *vbox;
dialog = gtk_dialog_new_with_buttons("Renumber",
dialog = gtk_dialog_new_with_buttons(_("Renumber"),
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
@ -806,7 +808,7 @@ static void renumber_dialog(GtkWidget *w, gpointer data)
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
frame = gtk_frame_new("New starting number");
frame = gtk_frame_new(_("New starting number"));
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
button = gtk_spin_button_new_with_range(1, 50000, 1);
@ -846,10 +848,10 @@ static void about_dialog(GtkWidget *w, gpointer data)
gtk_show_about_dialog(NULL,
"program-name", "Subsurface",
"comments", "Multi-platform divelog software in C",
"comments", _("Multi-platform divelog software in C"),
"license", "GPLv2",
"version", VERSION_STRING,
"copyright", "Linus Torvalds, Dirk Hohndel, and others, 2011, 2012",
"copyright", _("Linus Torvalds, Dirk Hohndel, and others, 2011, 2012"),
"logo-icon-name", "subsurface",
/* Must be last: */
logo_property, logo,
@ -894,36 +896,36 @@ static void toggle_zoom(GtkWidget *w, gpointer data)
}
static GtkActionEntry menu_items[] = {
{ "FileMenuAction", NULL, "File", NULL, NULL, NULL},
{ "LogMenuAction", NULL, "Log", NULL, NULL, NULL},
{ "ViewMenuAction", NULL, "View", NULL, NULL, NULL},
{ "FilterMenuAction", NULL, "Filter", NULL, NULL, NULL},
{ "HelpMenuAction", NULL, "Help", NULL, NULL, NULL},
{ "NewFile", GTK_STOCK_NEW, NULL, CTRLCHAR "N", NULL, G_CALLBACK(file_close) },
{ "OpenFile", GTK_STOCK_OPEN, NULL, CTRLCHAR "O", NULL, G_CALLBACK(file_open) },
{ "SaveFile", GTK_STOCK_SAVE, NULL, CTRLCHAR "S", NULL, G_CALLBACK(file_save) },
{ "SaveAsFile", GTK_STOCK_SAVE_AS, NULL, SHIFTCHAR CTRLCHAR "S", NULL, G_CALLBACK(file_save_as) },
{ "CloseFile", GTK_STOCK_CLOSE, NULL, NULL, NULL, G_CALLBACK(file_close) },
{ "Print", GTK_STOCK_PRINT, NULL, CTRLCHAR "P", NULL, G_CALLBACK(do_print) },
{ "ImportFile", GTK_STOCK_GO_BACK, "Import XML File(s)", CTRLCHAR "I", NULL, G_CALLBACK(import_files) },
{ "DownloadLog", GTK_STOCK_GO_DOWN, "Download From Dive Computer", CTRLCHAR "D", NULL, G_CALLBACK(download_dialog) },
{ "AddDive", GTK_STOCK_ADD, "Add Dive", NULL, NULL, G_CALLBACK(add_dive_cb) },
{ "Preferences", GTK_STOCK_PREFERENCES, "Preferences", PREFERENCE_ACCEL, NULL, G_CALLBACK(preferences_dialog) },
{ "Renumber", NULL, "Renumber", NULL, NULL, G_CALLBACK(renumber_dialog) },
{ "YearlyStats", NULL, "Yearly Statistics", NULL, NULL, G_CALLBACK(show_yearly_stats) },
{ "SelectEvents", NULL, "SelectEvents", NULL, NULL, G_CALLBACK(selectevents_dialog) },
{ "Quit", GTK_STOCK_QUIT, NULL, CTRLCHAR "Q", NULL, G_CALLBACK(quit) },
{ "About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(about_dialog) },
{ "ViewList", NULL, "List", CTRLCHAR "1", NULL, G_CALLBACK(view_list) },
{ "ViewProfile", NULL, "Profile", CTRLCHAR "2", NULL, G_CALLBACK(view_profile) },
{ "ViewInfo", NULL, "Info", CTRLCHAR "3", NULL, G_CALLBACK(view_info) },
{ "ViewThree", NULL, "Three", CTRLCHAR "4", NULL, G_CALLBACK(view_three) },
{ "FileMenuAction", NULL, N_("File"), NULL, NULL, NULL},
{ "LogMenuAction", NULL, N_("Log"), NULL, NULL, NULL},
{ "ViewMenuAction", NULL, N_("View"), NULL, NULL, NULL},
{ "FilterMenuAction", NULL, N_("Filter"), NULL, NULL, NULL},
{ "HelpMenuAction", NULL, N_("Help"), NULL, NULL, NULL},
{ "NewFile", GTK_STOCK_NEW, N_("New"), CTRLCHAR "N", NULL, G_CALLBACK(file_close) },
{ "OpenFile", GTK_STOCK_OPEN, N_("Open"), CTRLCHAR "O", NULL, G_CALLBACK(file_open) },
{ "SaveFile", GTK_STOCK_SAVE, N_("Save"), CTRLCHAR "S", NULL, G_CALLBACK(file_save) },
{ "SaveAsFile", GTK_STOCK_SAVE_AS, N_("Save As"), SHIFTCHAR CTRLCHAR "S", NULL, G_CALLBACK(file_save_as) },
{ "CloseFile", GTK_STOCK_CLOSE, N_("Close"), NULL, NULL, G_CALLBACK(file_close) },
{ "Print", GTK_STOCK_PRINT, N_("Print"), CTRLCHAR "P", NULL, G_CALLBACK(do_print) },
{ "ImportFile", GTK_STOCK_GO_BACK, N_("Import XML File(s)"), CTRLCHAR "I", NULL, G_CALLBACK(import_files) },
{ "DownloadLog", GTK_STOCK_GO_DOWN, N_("Download From Dive Computer"), CTRLCHAR "D", NULL, G_CALLBACK(download_dialog) },
{ "AddDive", GTK_STOCK_ADD, N_("Add Dive"), NULL, NULL, G_CALLBACK(add_dive_cb) },
{ "Preferences", GTK_STOCK_PREFERENCES, N_("Preferences"), PREFERENCE_ACCEL, NULL, G_CALLBACK(preferences_dialog) },
{ "Renumber", NULL, N_("Renumber"), NULL, NULL, G_CALLBACK(renumber_dialog) },
{ "YearlyStats", NULL, N_("Yearly Statistics"), NULL, NULL, G_CALLBACK(show_yearly_stats) },
{ "SelectEvents", NULL, N_("SelectEvents"), NULL, NULL, G_CALLBACK(selectevents_dialog) },
{ "Quit", GTK_STOCK_QUIT, N_("Quit"), CTRLCHAR "Q", NULL, G_CALLBACK(quit) },
{ "About", GTK_STOCK_ABOUT, N_("About"), NULL, NULL, G_CALLBACK(about_dialog) },
{ "ViewList", NULL, N_("List"), CTRLCHAR "1", NULL, G_CALLBACK(view_list) },
{ "ViewProfile", NULL, N_("Profile"), CTRLCHAR "2", NULL, G_CALLBACK(view_profile) },
{ "ViewInfo", NULL, N_("Info"), CTRLCHAR "3", NULL, G_CALLBACK(view_info) },
{ "ViewThree", NULL, N_("Three"), CTRLCHAR "4", NULL, G_CALLBACK(view_three) },
};
static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
static GtkToggleActionEntry toggle_items[] = {
{ "Autogroup", NULL, "Autogroup", NULL, NULL, G_CALLBACK(autogroup_cb), FALSE },
{ "ToggleZoom", NULL, "Toggle Zoom", CTRLCHAR "0", NULL, G_CALLBACK(toggle_zoom), FALSE },
{ "Autogroup", NULL, N_("Autogroup"), NULL, NULL, G_CALLBACK(autogroup_cb), FALSE },
{ "ToggleZoom", NULL, N_("Toggle Zoom"), CTRLCHAR "0", NULL, G_CALLBACK(toggle_zoom), FALSE },
};
static gint ntoggle_items = sizeof (toggle_items) / sizeof (toggle_items[0]);
@ -974,6 +976,7 @@ static const gchar* ui_string = " \
static GtkWidget *get_menubar_menu(GtkWidget *window, GtkUIManager *ui_manager)
{
GtkActionGroup *action_group = gtk_action_group_new("Menu");
gtk_action_group_set_translation_domain(action_group, "subsurface");
gtk_action_group_add_actions(action_group, menu_items, nmenu_items, 0);
toggle_items[0].is_active = autogroup;
gtk_action_group_add_toggle_actions(action_group, toggle_items, ntoggle_items, 0);
@ -1106,19 +1109,19 @@ void init_ui(int *argcp, char ***argvp)
/* Frame for extended dive info */
nb_page = extended_dive_info_widget();
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nb_page, gtk_label_new("Dive Notes"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nb_page, gtk_label_new(_("Dive Notes")));
/* Frame for dive equipment */
nb_page = equipment_widget(W_IDX_PRIMARY);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nb_page, gtk_label_new("Equipment"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nb_page, gtk_label_new(_("Equipment")));
/* Frame for single dive statistics */
nb_page = single_stats_widget();
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nb_page, gtk_label_new("Dive Info"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nb_page, gtk_label_new(_("Dive Info")));
/* Frame for total dive statistics */
nb_page = total_stats_widget();
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nb_page, gtk_label_new("Stats"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nb_page, gtk_label_new(_("Stats")));
gtk_widget_set_app_paintable(win, TRUE);
gtk_widget_show_all(win);
@ -1327,7 +1330,7 @@ static GtkComboBox *dive_computer_selector(GtkWidget *vbox)
model = gtk_list_store_new(1, G_TYPE_POINTER);
default_index = fill_computer_list(model);
frame = gtk_frame_new("Dive computer");
frame = gtk_frame_new(_("Dive computer"));
gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 3);
combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(model));
@ -1358,7 +1361,7 @@ static GtkEntry *dive_computer_device(GtkWidget *vbox)
hbox = gtk_hbox_new(FALSE, 6);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
frame = gtk_frame_new("Device name");
frame = gtk_frame_new(_("Device name"));
gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 3);
entry = gtk_entry_new();
@ -1390,7 +1393,7 @@ void import_files(GtkWidget *w, gpointer data)
struct stat sb;
GSList *filenames = NULL;
fs_dialog = gtk_file_chooser_dialog_new("Choose XML Files To Import Into Current Data File",
fs_dialog = gtk_file_chooser_dialog_new(_("Choose XML Files To Import Into Current Data File"),
GTK_WINDOW(main_window),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@ -1465,7 +1468,7 @@ static GtkWidget *import_dive_computer(device_data_t *data, GtkDialog *dialog)
button = gtk_dialog_get_widget_for_response(dialog, GTK_RESPONSE_ACCEPT);
gtk_button_set_use_stock(GTK_BUTTON(button), 0);
gtk_button_set_label(GTK_BUTTON(button), "Retry");
gtk_button_set_label(GTK_BUTTON(button), _("Retry"));
vbox = gtk_dialog_get_content_area(dialog);
@ -1488,7 +1491,7 @@ void download_dialog(GtkWidget *w, gpointer data)
.devname = NULL,
};
dialog = gtk_dialog_new_with_buttons("Download From Dive Computer",
dialog = gtk_dialog_new_with_buttons(_("Download From Dive Computer"),
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
@ -1496,7 +1499,7 @@ void download_dialog(GtkWidget *w, gpointer data)
NULL);
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
label = gtk_label_new(" Please select dive computer and device. ");
label = gtk_label_new(_(" Please select dive computer and device. "));
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 3);
computer = dive_computer_selector(vbox);
device = dive_computer_device(vbox);

65
info.c
View file

@ -13,6 +13,7 @@
#include <time.h>
#include <ctype.h>
#include <sys/time.h>
#include <glib/gi18n.h>
#include "dive.h"
#include "display.h"
@ -102,7 +103,7 @@ static int divename(char *buf, size_t size, struct dive *dive)
struct tm tm;
utc_mkdate(dive->when, &tm);
return snprintf(buf, size, "Dive #%d - %s %02d/%02d/%04d at %d:%02d",
return snprintf(buf, size, _("Dive #%d - %s %02d/%02d/%04d at %d:%02d"),
dive->number,
weekday(tm.tm_wday),
tm.tm_mon+1, tm.tm_mday,
@ -140,7 +141,7 @@ void show_dive_info(struct dive *dive)
if (!text)
text = "";
if (*text) {
snprintf(buffer, sizeof(buffer), "Dive #%d - %s", dive->number, text);
snprintf(buffer, sizeof(buffer), _("Dive #%d - %s"), dive->number, text);
} else {
divename(buffer, sizeof(buffer), dive);
}
@ -174,7 +175,7 @@ static int delete_dive_info(struct dive *dive)
if (!dive)
return 0;
dialog = gtk_dialog_new_with_buttons("Delete Dive",
dialog = gtk_dialog_new_with_buttons(_("Delete Dive"),
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
@ -223,8 +224,8 @@ static void add_menu_item(GtkMenu *menu, const char *label, const char *icon, vo
static void populate_popup_cb(GtkTextView *entry, GtkMenu *menu, gpointer user_data)
{
add_menu_item(menu, "Delete", GTK_STOCK_DELETE, info_menu_delete_cb);
add_menu_item(menu, "Edit", GTK_STOCK_EDIT, info_menu_edit_cb);
add_menu_item(menu, _("Delete"), GTK_STOCK_DELETE, info_menu_delete_cb);
add_menu_item(menu, _("Edit"), GTK_STOCK_EDIT, info_menu_edit_cb);
}
static GtkEntry *text_value(GtkWidget *box, const char *label)
@ -449,17 +450,17 @@ static void save_dive_info_changes(struct dive *dive, struct dive *master, struc
static void dive_trip_widget(GtkWidget *box, dive_trip_t *trip, struct dive_info *info)
{
GtkWidget *hbox, *label;
char buffer[80] = "Edit trip summary";
char buffer[80] = N_("Edit trip summary");
label = gtk_label_new(buffer);
label = gtk_label_new(_(buffer));
gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0);
info->location = text_entry(box, "Location", location_list, trip->location);
info->location = text_entry(box, _("Location"), location_list, trip->location);
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, TRUE, 0);
info->notes = text_view(box, "Notes", READ_WRITE);
info->notes = text_view(box, _("Notes"), READ_WRITE);
if (trip->notes && *trip->notes)
gtk_text_buffer_set_text(gtk_text_view_get_buffer(info->notes), trip->notes, -1);
}
@ -467,32 +468,32 @@ static void dive_trip_widget(GtkWidget *box, dive_trip_t *trip, struct dive_info
static void dive_info_widget(GtkWidget *box, struct dive *dive, struct dive_info *info, gboolean multi)
{
GtkWidget *hbox, *label, *frame, *equipment;
char buffer[80] = "Edit multiple dives";
char buffer[80] = N_("Edit multiple dives");
if (!multi)
divename(buffer, sizeof(buffer), dive);
label = gtk_label_new(buffer);
divename(_(buffer), sizeof(_(buffer)), dive);
label = gtk_label_new(_(buffer));
gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0);
info->location = text_entry(box, "Location", location_list, dive->location);
info->location = text_entry(box, _("Location"), location_list, dive->location);
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, TRUE, 0);
info->divemaster = text_entry(hbox, "Dive master", people_list, dive->divemaster);
info->buddy = text_entry(hbox, "Buddy", people_list, dive->buddy);
info->divemaster = text_entry(hbox, _("Dive master"), people_list, dive->divemaster);
info->buddy = text_entry(hbox, _("Buddy"), people_list, dive->buddy);
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, TRUE, 0);
info->rating = text_entry(hbox, "Rating", star_list, star_strings[dive->rating]);
info->suit = text_entry(hbox, "Suit", suit_list, dive->suit);
info->rating = text_entry(hbox, _("Rating"), star_list, star_strings[dive->rating]);
info->suit = text_entry(hbox, _("Suit"), suit_list, dive->suit);
/* only show notes if editing a single dive */
if (multi) {
info->notes = NULL;
} else {
info->notes = text_view(box, "Notes", READ_WRITE);
info->notes = text_view(box, _("Notes"), READ_WRITE);
if (dive->notes && *dive->notes)
gtk_text_buffer_set_text(gtk_text_view_get_buffer(info->notes), dive->notes, -1);
}
@ -500,7 +501,7 @@ static void dive_info_widget(GtkWidget *box, struct dive *dive, struct dive_info
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, TRUE, 0);
/* create a secondary Equipment widget */
frame = gtk_frame_new("Equipment");
frame = gtk_frame_new(_("Equipment"));
equipment = equipment_widget(W_IDX_SECONDARY);
gtk_container_add(GTK_CONTAINER(frame), equipment);
gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
@ -624,7 +625,7 @@ gboolean edit_trip(dive_trip_t *trip)
struct dive_info info;
memset(&info, 0, sizeof(struct dive_info));
dialog = gtk_dialog_new_with_buttons("Edit Trip Info",
dialog = gtk_dialog_new_with_buttons(_("Edit Trip Info"),
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
@ -665,7 +666,7 @@ int edit_multi_dive_info(struct dive *single_dive)
struct dive *master;
gboolean multi;
dialog = gtk_dialog_new_with_buttons("Dive Info",
dialog = gtk_dialog_new_with_buttons(_("Dive Info"),
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
@ -772,7 +773,7 @@ static timestamp_t dive_time_widget(struct dive *dive)
int success;
double depthinterval, val;
dialog = gtk_dialog_new_with_buttons("Date and Time",
dialog = gtk_dialog_new_with_buttons(_("Date and Time"),
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
@ -782,12 +783,12 @@ static timestamp_t dive_time_widget(struct dive *dive)
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
/* Calendar hbox */
hbox = frame_box(vbox, "Date:");
hbox = frame_box(vbox, _("Date:"));
cal = gtk_calendar_new();
gtk_box_pack_start(GTK_BOX(hbox), cal, FALSE, TRUE, 0);
/* Time hbox */
hbox = frame_box(vbox, "Time");
hbox = frame_box(vbox, _("Time"));
h = gtk_spin_button_new_with_range (0.0, 23.0, 1.0);
m = gtk_spin_button_new_with_range (0.0, 59.0, 1.0);
@ -827,12 +828,12 @@ static timestamp_t dive_time_widget(struct dive *dive)
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
/* Duration hbox */
box = frame_box(hbox, "Duration (min)");
box = frame_box(hbox, _("Duration (min)"));
duration = gtk_spin_button_new_with_range (0.0, 1000.0, 1.0);
gtk_box_pack_end(GTK_BOX(box), duration, FALSE, FALSE, 0);
/* Depth box */
box = frame_box(hbox, "Depth (%s):", output_units.length == FEET ? "ft" : "m");
box = frame_box(hbox, _("Depth (%s):"), output_units.length == FEET ? "ft" : "m");
if (output_units.length == FEET) {
depthinterval = 1.0;
} else {
@ -901,20 +902,20 @@ GtkWidget *extended_dive_info_widget(void)
suit_list = gtk_list_store_new(1, G_TYPE_STRING);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 6);
location = text_value(vbox, "Location");
location = text_value(vbox, _("Location"));
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
divemaster = text_value(hbox, "Divemaster");
buddy = text_value(hbox, "Buddy");
divemaster = text_value(hbox, _("Divemaster"));
buddy = text_value(hbox, _("Buddy"));
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
rating = text_value(hbox, "Rating");
suit = text_value(hbox, "Suit");
rating = text_value(hbox, _("Rating"));
suit = text_value(hbox, _("Suit"));
notes = text_view(vbox, "Notes", READ_ONLY);
notes = text_view(vbox, _("Notes"), READ_ONLY);
return vbox;
}

View file

@ -2,6 +2,7 @@
#include <pthread.h>
#include <unistd.h>
#include <inttypes.h>
#include <glib/gi18n.h>
#include "dive.h"
#include "divelist.h"

View file

@ -84,6 +84,11 @@ const char *subsurface_default_filename()
}
}
const char *subsurface_gettext_domainpath()
{
return "./locale";
}
void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar,
GtkWidget *vbox, GtkUIManager *ui_manager)
{

13
macos.c
View file

@ -104,6 +104,19 @@ const char *subsurface_default_filename()
}
}
const char *subsurface_gettext_domainpath()
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef localeURL = CFBundleCopyResourceURL(mainBundle, CFSTR("locale"), CFSTR(""), NULL);
if (localeURL) {
CFStringRef localePath = CFURLCopyFileSystemPath(localeURL, kCFURLPOSIXPathStyle);
CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
const char *path = CFStringGetCStringPtr(localePath, encodingMethod);
return path;
}
return "./locale";
}
static void show_main_window(GtkWidget *w, gpointer data)
{
gtk_widget_show(main_window);

24
main.c
View file

@ -1,8 +1,11 @@
/* main.c */
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <libintl.h>
#include <glib/gi18n.h>
#include "dive.h"
#include "divelist.h"
@ -29,17 +32,19 @@ static int sortfn(const void *_a, const void *_b)
const char *weekday(int wday)
{
static const char wday_array[7][4] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
static const char wday_array[7][7] = {
/*++GETTEXT: these are three letter days - we allow up to six code bytes */
N_("Sun"), N_("Mon"), N_("Tue"), N_("Wed"), N_("Thu"), N_("Fri"), N_("Sat")
};
return wday_array[wday];
}
const char *monthname(int mon)
{
static const char month_array[12][4] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
static const char month_array[12][7] = {
/*++GETTEXT: these are three letter months - we allow up to six code bytes*/
N_("Jan"), N_("Feb"), N_("Mar"), N_("Apr"), N_("May"), N_("Jun"),
N_("Jul"), N_("Aug"), N_("Sep"), N_("Oct"), N_("Nov"), N_("Dec"),
};
return month_array[mon];
}
@ -220,7 +225,16 @@ int main(int argc, char **argv)
{
int i;
gboolean no_filenames = TRUE;
const char *path;
/* set up l18n - the search directory needs to change
* so that it uses the correct system directory when
* subsurface isn't run from the local directory */
setlocale( LC_ALL, "" );
path = subsurface_gettext_domainpath();
bindtextdomain("subsurface", path);
bind_textdomain_codeset("subsurface", "utf-8");
textdomain("subsurface");
output_units = SI_units;
subsurface_command_line_init(&argc, &argv);

View file

@ -133,6 +133,7 @@ Section
File dll\pthreadGC2.dll
File dll\zlib1.dll
File subsurface.ico
File /r ..\..\locale
# Store installation folder in registry
WriteRegStr HKCU "Software\Subsurface" "" $INSTDIR

View file

@ -11,6 +11,7 @@
#ifdef XSLT
#include <libxslt/transform.h>
#endif
#include <glib/gi18n.h>
#include "dive.h"
#include "uemis.h"
@ -1489,12 +1490,12 @@ void parse_xml_buffer(const char *url, const char *buffer, int size, GError **er
doc = xmlReadMemory(buffer, size, url, NULL, 0);
if (!doc) {
fprintf(stderr, "Failed to parse '%s'.\n", url);
fprintf(stderr, _("Failed to parse '%s'.\n"), url);
if (error != NULL)
{
*error = g_error_new(g_quark_from_string("subsurface"),
DIVE_ERROR_PARSE,
"Failed to parse '%s'",
_("Failed to parse '%s'"),
url);
}
return;

1096
po/bg_BG.po Normal file

File diff suppressed because it is too large Load diff

1049
po/de_DE.po Normal file

File diff suppressed because it is too large Load diff

1094
po/fi_FI.po Normal file

File diff suppressed because it is too large Load diff

1098
po/fr_FR.po Normal file

File diff suppressed because it is too large Load diff

1097
po/nl_NL.po Normal file

File diff suppressed because it is too large Load diff

1094
po/no_NO.po Normal file

File diff suppressed because it is too large Load diff

1094
po/sk_SK.po Normal file

File diff suppressed because it is too large Load diff

1095
po/sv_SE.po Normal file

File diff suppressed because it is too large Load diff

33
print.c
View file

@ -1,3 +1,4 @@
#include <glib/gi18n.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
@ -63,7 +64,7 @@ static void show_dive_text(struct dive *dive, cairo_t *cr, double w,
*divenr = 0;
if (dive->number)
snprintf(divenr, sizeof(divenr), "Dive #%d - ", dive->number);
snprintf(divenr, sizeof(divenr), _("Dive #%d - "), dive->number);
utc_mkdate(dive->when, &tm);
len = snprintf(buffer, sizeof(buffer),
@ -90,9 +91,7 @@ static void show_dive_text(struct dive *dive, cairo_t *cr, double w,
depth = get_depth_units(dive->maxdepth.mm, &decimals, &unit);
snprintf(buffer, sizeof(buffer),
"Max depth: %.*f %s\n"
"Duration: %d min\n"
"%s",
_("Max depth: %.*f %s\nDuration: %d min\n%s"),
decimals, depth, unit,
(dive->duration.seconds+59) / 60,
people);
@ -152,8 +151,8 @@ static void show_table_header(cairo_t *cr, double w, double h,
int i;
double maxwidth, maxheight, colwidth, curwidth;
PangoLayout *layout;
char headers[7][80]= { "Dive#", "Date", "Depth", "Time", "Master",
"Buddy", "Location" };
char headers[7][80]= { N_("Dive#"), N_("Date"), N_("Depth"), N_("Time"), N_("Master"),
N_("Buddy"), N_("Location") };
maxwidth = w * PANGO_SCALE;
maxheight = h * PANGO_SCALE * 0.9;
@ -177,7 +176,7 @@ static void show_table_header(cairo_t *cr, double w, double h,
pango_layout_set_width(layout, colwidth);
curwidth = curwidth + colwidth;
}
pango_layout_set_text(layout, headers[i], -1);
pango_layout_set_text(layout, _(headers[i]), -1);
pango_layout_set_justify(layout, 1);
pango_cairo_show_layout(cr, layout);
}
@ -250,7 +249,7 @@ static void show_dive_table(struct dive *dive, cairo_t *cr, double w,
// Col 4: Time
len = snprintf(buffer, sizeof(buffer),
"%d min",(dive->duration.seconds+59) / 60);
_("%d min"),(dive->duration.seconds+59) / 60);
cairo_move_to(cr, curwidth / PANGO_SCALE, 0);
pango_layout_set_width(layout, colwidth/ (double) 2);
pango_layout_set_text(layout, buffer, len);
@ -472,21 +471,21 @@ static GtkWidget *print_dialog(GtkPrintOperation *operation, gpointer user_data)
{
GtkWidget *vbox, *radio1, *radio2, *frame, *box;
int dives;
gtk_print_operation_set_custom_tab_label(operation, "Dive details");
gtk_print_operation_set_custom_tab_label(operation, _("Dive details"));
vbox = gtk_vbox_new(TRUE, 5);
frame = gtk_frame_new("Print type");
frame = gtk_frame_new(_("Print type"));
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 1);
box = gtk_hbox_new(FALSE, 2);
gtk_container_add(GTK_CONTAINER(frame), box);
radio1 = gtk_radio_button_new_with_label (NULL, "Pretty print");
radio1 = gtk_radio_button_new_with_label (NULL, _("Pretty print"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio1),
print_options.type == PRETTY);
radio2 = gtk_radio_button_new_with_label_from_widget (
GTK_RADIO_BUTTON (radio1), "Table print");
GTK_RADIO_BUTTON (radio1), _("Table print"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio2),
print_options.type == TABLE);
gtk_box_pack_start (GTK_BOX (box), radio1, TRUE, TRUE, 0);
@ -498,12 +497,12 @@ static GtkWidget *print_dialog(GtkPrintOperation *operation, gpointer user_data)
dives = nr_selected_dives();
print_options.print_selected = dives >= 1;
if (print_options.print_selected) {
frame = gtk_frame_new("Print selection");
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 1);
box = gtk_hbox_new(FALSE, 1);
gtk_container_add(GTK_CONTAINER(frame), box);
frame = gtk_frame_new(_("Print selection"));
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 1);
box = gtk_hbox_new(FALSE, 1);
gtk_container_add(GTK_CONTAINER(frame), box);
GtkWidget *button;
button = gtk_check_button_new_with_label("Print only selected dives");
button = gtk_check_button_new_with_label(_("Print only selected dives"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
print_options.print_selected);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 2);

View file

@ -2,6 +2,7 @@
/* creates all the necessary data for drawing the dive profile
* uses cairo to draw it
*/
#include <glib/gi18n.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

View file

@ -8,6 +8,7 @@
* called from gtk-ui:
* GtkWidget *stats_widget(void)
*/
#include <glib/gi18n.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -155,16 +156,31 @@ static void init_tree()
pango_font_description_free(font_desc);
renderer = gtk_cell_renderer_text_new ();
char *columns[] = {
"Year\n > Month", "#", "Duration\nTotal", "\nAverage",
"\nShortest", "\nLongest", "Depth\nAverage", "\nMinimum",
"\nMaximum", "SAC\nAverage", "\nMinimum", "\nMaximum", "Temperature\nAverage",
"\nMinimum", "\nMaximum" };
/* don't use empty strings "" - they confuse gettext */
char *columnstop[] = { N_("Year"), N_("#"), N_("Duration"), " ", " ", " ", N_("Depth"), " ", " ", N_("SAC"), " ", " ", N_("Temperature"), " ", " " };
const char *columnsbot[15];
columnsbot[0] = C_("Stats", " > Month");
columnsbot[1] = " ";
columnsbot[2] = C_("Duration","Total");
columnsbot[3] = C_("Duration","Average");
columnsbot[4] = C_("Duration","Shortest");
columnsbot[5] = C_("Duration","Longest");
columnsbot[6] = C_("Depth", "Average");
columnsbot[7] = C_("Depth","Minimum");
columnsbot[8] = C_("Depth","Maximum");
columnsbot[9] = C_("SAC","Average");
columnsbot[10]= C_("SAC","Minimum");
columnsbot[11]= C_("SAC","Maximum");
columnsbot[12]= C_("Temp","Average");
columnsbot[13]= C_("Temp","Minimum");
columnsbot[14]= C_("Temp","Maximum");
/* Add all the columns to the tree view */
for (i = 0; i < N_COLUMNS; ++i) {
char buf[80];
column = gtk_tree_view_column_new();
gtk_tree_view_column_set_title(column, columns[i]);
snprintf(buf, sizeof(buf), "%s\n%s", _(columnstop[i]), columnsbot[i]);
gtk_tree_view_column_set_title(column, buf);
gtk_tree_view_append_column(GTK_TREE_VIEW(yearly_tree), column);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(column, renderer, TRUE);
@ -341,7 +357,7 @@ void show_yearly_stats()
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
gtk_window_set_title(GTK_WINDOW(window), "Yearly Statistics");
gtk_window_set_title(GTK_WINDOW(window), _("Yearly Statistics"));
gtk_container_set_border_width(GTK_CONTAINER(window), 5);
GTK_WINDOW(window)->allow_shrink = TRUE;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@ -474,15 +490,15 @@ static char * get_time_string(int seconds, int maxdays)
{
static char buf[80];
if (maxdays && seconds > 3600 * 24 * maxdays)
snprintf(buf, sizeof(buf), "more than %d days", maxdays);
snprintf(buf, sizeof(buf), _("more than %d days"), maxdays);
else {
int days = seconds / 3600 / 24;
int hours = (seconds - days * 3600 * 24) / 3600;
int minutes = (seconds - days * 3600 * 24 - hours * 3600) / 60;
if (days > 0)
snprintf(buf, sizeof(buf), "%dd %dh %dmin", days, hours, minutes);
snprintf(buf, sizeof(buf), _("%dd %dh %dmin"), days, hours, minutes);
else
snprintf(buf, sizeof(buf), "%dh %dmin", hours, minutes);
snprintf(buf, sizeof(buf), _("%dh %dmin"), hours, minutes);
}
return buf;
}
@ -508,12 +524,12 @@ static void show_single_dive_stats(struct dive *dive)
tm.tm_hour, tm.tm_min);
set_label(single_w.date, buf);
set_label(single_w.dive_time, "%d min", (dive->duration.seconds + 30) / 60);
set_label(single_w.dive_time, _("%d min"), (dive->duration.seconds + 30) / 60);
if (prev_dive)
set_label(single_w.surf_intv,
get_time_string(dive->when - (prev_dive->when + prev_dive->duration.seconds), 4));
else
set_label(single_w.surf_intv, "unknown");
set_label(single_w.surf_intv, _("unknown"));
value = get_depth_units(dive->maxdepth.mm, &decimals, &unit);
set_label(single_w.max_depth, "%.*f %s", decimals, value, unit);
value = get_depth_units(dive->meandepth.mm, &decimals, &unit);
@ -597,11 +613,11 @@ static void show_total_dive_stats(struct dive *dive)
value = get_depth_units(stats_ptr->avg_depth.mm, &decimals, &unit);
set_label(stats_w.avg_overall_depth, "%.*f %s", decimals, value, unit);
value = get_volume_units(stats_ptr->max_sac.mliter, &decimals, &unit);
set_label(stats_w.max_sac, "%.*f %s/min", decimals, value, unit);
set_label(stats_w.max_sac, _("%.*f %s/min"), decimals, value, unit);
value = get_volume_units(stats_ptr->min_sac.mliter, &decimals, &unit);
set_label(stats_w.min_sac, "%.*f %s/min", decimals, value, unit);
set_label(stats_w.min_sac, _("%.*f %s/min"), decimals, value, unit);
value = get_volume_units(stats_ptr->avg_sac.mliter, &decimals, &unit);
set_label(stats_w.avg_sac, "%.*f %s/min", decimals, value, unit);
set_label(stats_w.avg_sac, _("%.*f %s/min"), decimals, value, unit);
}
void show_dive_stats(struct dive *dive)
@ -636,7 +652,7 @@ GtkWidget *total_stats_widget(void)
vbox = gtk_vbox_new(FALSE, 3);
statsframe = gtk_frame_new("Statistics");
statsframe = gtk_frame_new(_("Statistics"));
gtk_box_pack_start(GTK_BOX(vbox), statsframe, TRUE, FALSE, 3);
framebox = gtk_vbox_new(FALSE, 3);
gtk_container_add(GTK_CONTAINER(statsframe), framebox);
@ -644,35 +660,35 @@ GtkWidget *total_stats_widget(void)
/* first row */
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
stats_w.selection_size = new_info_label_in_frame(hbox, "Dives");
stats_w.max_temp = new_info_label_in_frame(hbox, "Max Temp");
stats_w.min_temp = new_info_label_in_frame(hbox, "Min Temp");
stats_w.avg_temp = new_info_label_in_frame(hbox, "Avg Temp");
stats_w.selection_size = new_info_label_in_frame(hbox, _("Dives"));
stats_w.max_temp = new_info_label_in_frame(hbox, _("Max Temp"));
stats_w.min_temp = new_info_label_in_frame(hbox, _("Min Temp"));
stats_w.avg_temp = new_info_label_in_frame(hbox, _("Avg Temp"));
/* second row */
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
stats_w.total_time = new_info_label_in_frame(hbox, "Total Time");
stats_w.avg_time = new_info_label_in_frame(hbox, "Avg Time");
stats_w.longest_time = new_info_label_in_frame(hbox, "Longest Dive");
stats_w.shortest_time = new_info_label_in_frame(hbox, "Shortest Dive");
stats_w.total_time = new_info_label_in_frame(hbox, _("Total Time"));
stats_w.avg_time = new_info_label_in_frame(hbox, _("Avg Time"));
stats_w.longest_time = new_info_label_in_frame(hbox, _("Longest Dive"));
stats_w.shortest_time = new_info_label_in_frame(hbox, _("Shortest Dive"));
/* third row */
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
stats_w.max_overall_depth = new_info_label_in_frame(hbox, "Max Depth");
stats_w.min_overall_depth = new_info_label_in_frame(hbox, "Min Depth");
stats_w.avg_overall_depth = new_info_label_in_frame(hbox, "Avg Depth");
stats_w.max_overall_depth = new_info_label_in_frame(hbox, _("Max Depth"));
stats_w.min_overall_depth = new_info_label_in_frame(hbox, _("Min Depth"));
stats_w.avg_overall_depth = new_info_label_in_frame(hbox, _("Avg Depth"));
/* fourth row */
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
stats_w.max_sac = new_info_label_in_frame(hbox, "Max SAC");
stats_w.min_sac = new_info_label_in_frame(hbox, "Min SAC");
stats_w.avg_sac = new_info_label_in_frame(hbox, "Avg SAC");
stats_w.max_sac = new_info_label_in_frame(hbox, _("Max SAC"));
stats_w.min_sac = new_info_label_in_frame(hbox, _("Min SAC"));
stats_w.avg_sac = new_info_label_in_frame(hbox, _("Avg SAC"));
return vbox;
}
@ -683,7 +699,7 @@ GtkWidget *single_stats_widget(void)
vbox = gtk_vbox_new(FALSE, 3);
infoframe = gtk_frame_new("Dive Info");
infoframe = gtk_frame_new(_("Dive Info"));
gtk_box_pack_start(GTK_BOX(vbox), infoframe, TRUE, FALSE, 3);
framebox = gtk_vbox_new(FALSE, 3);
gtk_container_add(GTK_CONTAINER(infoframe), framebox);
@ -692,26 +708,26 @@ GtkWidget *single_stats_widget(void)
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
single_w.date = new_info_label_in_frame(hbox, "Date");
single_w.dive_time = new_info_label_in_frame(hbox, "Dive Time");
single_w.surf_intv = new_info_label_in_frame(hbox, "Surf Intv");
single_w.date = new_info_label_in_frame(hbox, _("Date"));
single_w.dive_time = new_info_label_in_frame(hbox, _("Dive Time"));
single_w.surf_intv = new_info_label_in_frame(hbox, _("Surf Intv"));
/* second row */
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
single_w.max_depth = new_info_label_in_frame(hbox, "Max Depth");
single_w.avg_depth = new_info_label_in_frame(hbox, "Avg Depth");
single_w.water_temp = new_info_label_in_frame(hbox, "Water Temp");
single_w.max_depth = new_info_label_in_frame(hbox, _("Max Depth"));
single_w.avg_depth = new_info_label_in_frame(hbox, _("Avg Depth"));
single_w.water_temp = new_info_label_in_frame(hbox, _("Water Temp"));
/* third row */
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
single_w.sac = new_info_label_in_frame(hbox, "SAC");
single_w.otu = new_info_label_in_frame(hbox, "OTU");
single_w.sac = new_info_label_in_frame(hbox, _("SAC"));
single_w.otu = new_info_label_in_frame(hbox, _("OTU"));
single_w.o2he = new_info_label_in_frame(hbox, "O" UTF8_SUBSCRIPT_2 " / He");
single_w.gas_used = new_info_label_in_frame(hbox, "Gas Used");
single_w.gas_used = new_info_label_in_frame(hbox, _("Gas Used"));
return vbox;
}

1
time.c
View file

@ -1,3 +1,4 @@
#include <glib/gi18n.h>
#include <string.h>
#include "dive.h"

View file

@ -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];
}

37
uemis.c
View file

@ -12,6 +12,7 @@
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <glib/gi18n.h>
#define __USE_XOPEN
#include <time.h>
@ -128,45 +129,45 @@ void uemis_event(struct dive *dive, struct sample *sample, uemis_sample_t *u_sam
uint8_t *flags = u_sample->flags;
if (flags[1] & 0x01)
add_event(dive, sample->time.seconds, 0, 0, 0, "Safety Stop Violation");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Safety Stop Violation"));
if (flags[1] & 0x08)
add_event(dive, sample->time.seconds, 0, 0, 0, "Speed Alarm");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Speed Alarm"));
#if WANT_CRAZY_WARNINGS
if (flags[1] & 0x06) /* both bits 1 and 2 are a warning */
add_event(dive, sample->time.seconds, 0, 0, 0, "Speed Warning");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Speed Warning"));
if (flags[1] & 0x10)
add_event(dive, sample->time.seconds, 0, 0, 0, "PO2 Green Warning");
add_event(dive, sample->time.seconds, 0, 0, 0, _("PO2 Green Warning"));
#endif
if (flags[1] & 0x20)
add_event(dive, sample->time.seconds, 0, 0, 0, "PO2 Ascend Warning");
add_event(dive, sample->time.seconds, 0, 0, 0, _("PO2 Ascend Warning"));
if (flags[1] & 0x40)
add_event(dive, sample->time.seconds, 0, 0, 0, "PO2 Ascend Alarm");
add_event(dive, sample->time.seconds, 0, 0, 0, _("PO2 Ascend Alarm"));
/* flags[2] reflects the deco / time bar
* flags[3] reflects more display details on deco and pO2 */
if (flags[4] & 0x01)
add_event(dive, sample->time.seconds, 0, 0, 0, "Tank Pressure Info");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Tank Pressure Info"));
if (flags[4] & 0x04)
add_event(dive, sample->time.seconds, 0, 0, 0, "RGT Warning");
add_event(dive, sample->time.seconds, 0, 0, 0, _("RGT Warning"));
if (flags[4] & 0x08)
add_event(dive, sample->time.seconds, 0, 0, 0, "RGT Alert");
add_event(dive, sample->time.seconds, 0, 0, 0, _("RGT Alert"));
if (flags[4] & 0x40)
add_event(dive, sample->time.seconds, 0, 0, 0, "Tank Change Suggested");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Tank Change Suggested"));
if (flags[4] & 0x80)
add_event(dive, sample->time.seconds, 0, 0, 0, "Depth Limit Exceeded");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Depth Limit Exceeded"));
if (flags[5] & 0x01)
add_event(dive, sample->time.seconds, 0, 0, 0, "Max Deco Time Warning");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Max Deco Time Warning"));
if (flags[5] & 0x04)
add_event(dive, sample->time.seconds, 0, 0, 0, "Dive Time Info");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Dive Time Info"));
if (flags[5] & 0x08)
add_event(dive, sample->time.seconds, 0, 0, 0, "Dive Time Alert");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Dive Time Alert"));
if (flags[5] & 0x10)
add_event(dive, sample->time.seconds, 0, 0, 0, "Marker");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Marker"));
if (flags[6] & 0x02)
add_event(dive, sample->time.seconds, 0, 0, 0, "No Tank Data");
add_event(dive, sample->time.seconds, 0, 0, 0, _("No Tank Data"));
if (flags[6] & 0x04)
add_event(dive, sample->time.seconds, 0, 0, 0, "Low Battery Warning");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Low Battery Warning"));
if (flags[6] & 0x08)
add_event(dive, sample->time.seconds, 0, 0, 0, "Low Battery Alert");
add_event(dive, sample->time.seconds, 0, 0, 0, _("Low Battery Alert"));
/* flags[7] reflects the little on screen icons that remind of previous
* warnings / alerts - not useful for events */
}

View file

@ -151,6 +151,11 @@ const char *subsurface_default_filename()
}
}
const char *subsurface_gettext_domainpath()
{
return "./locale";
}
void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar,
GtkWidget *vbox, GtkUIManager *ui_manager)
{