diff options
author | Thomas White <taw@bitwiz.me.uk> | 2018-04-15 17:08:44 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2018-04-15 17:09:12 +0200 |
commit | 39b16e3f9fa51e737dd4cdfed7def8259757d24c (patch) | |
tree | cd19d32fe64364e24d03795d6fdf5d246c309b92 /src | |
parent | a20ab237477fe774d69fa742d59a5659ede35b15 (diff) |
Internationalise all strings in source code
Diffstat (limited to 'src')
-rw-r--r-- | src/colloquium.c | 1 | ||||
-rw-r--r-- | src/debugger.c | 1 | ||||
-rw-r--r-- | src/frame.c | 111 | ||||
-rw-r--r-- | src/imagestore.c | 7 | ||||
-rw-r--r-- | src/narrative_window.c | 42 | ||||
-rw-r--r-- | src/pr_clock.c | 29 | ||||
-rw-r--r-- | src/presentation.c | 20 | ||||
-rw-r--r-- | src/print.c | 5 | ||||
-rw-r--r-- | src/render.c | 4 | ||||
-rw-r--r-- | src/sc_editor.c | 30 | ||||
-rw-r--r-- | src/sc_interp.c | 49 | ||||
-rw-r--r-- | src/sc_parse.c | 33 | ||||
-rw-r--r-- | src/slide_window.c | 1 | ||||
-rw-r--r-- | src/slideshow.c | 7 | ||||
-rw-r--r-- | src/testcard.c | 22 | ||||
-rw-r--r-- | src/utils.c | 4 | ||||
-rw-r--r-- | src/utils.h | 1 |
17 files changed, 189 insertions, 178 deletions
diff --git a/src/colloquium.c b/src/colloquium.c index 3e6c2bf..ea55c20 100644 --- a/src/colloquium.c +++ b/src/colloquium.c @@ -32,7 +32,6 @@ #include <sys/stat.h> #include <glib.h> #include <glib/gstdio.h> -#include <libintl.h> #include "colloquium.h" #include "presentation.h" diff --git a/src/debugger.c b/src/debugger.c index 53c0596..edb79e1 100644 --- a/src/debugger.c +++ b/src/debugger.c @@ -29,7 +29,6 @@ #include <assert.h> #include <stdlib.h> #include <string.h> -#include <libintl.h> #include "presentation.h" #include "narrative_window.h" diff --git a/src/frame.c b/src/frame.c index 3c4451d..ff00530 100644 --- a/src/frame.c +++ b/src/frame.c @@ -34,6 +34,7 @@ #include "sc_parse.h" #include "frame.h" #include "imagestore.h" +#include "utils.h" struct text_run { @@ -116,7 +117,7 @@ struct frame *frame_new() n->children = NULL; n->max_children = 32; if ( alloc_ro(n) ) { - fprintf(stderr, "Couldn't allocate children\n"); + fprintf(stderr, _("Couldn't allocate children\n")); free(n); return NULL; } @@ -193,7 +194,7 @@ void show_hierarchy(struct frame *fr, const char *t) strcpy(tn, t); strcat(tn, " "); - printf("%s%p (%.2f x %.2f)\n", t, fr, fr->w, fr->h); + printf(_("%s%p (%.2f x %.2f)\n"), t, fr, fr->w, fr->h); for ( i=0; i<fr->num_children; i++ ) { show_hierarchy(fr->children[i], tn); @@ -229,7 +230,7 @@ void delete_subframe(struct frame *top, struct frame *fr) parent = find_parent(top, fr); if ( parent == NULL ) { - fprintf(stderr, "Couldn't find parent when deleting frame.\n"); + fprintf(stderr, _("Couldn't find parent when deleting frame.\n")); return; } @@ -243,7 +244,7 @@ void delete_subframe(struct frame *top, struct frame *fr) } if ( !found ) { - fprintf(stderr, "Couldn't find child when deleting frame.\n"); + fprintf(stderr, _("Couldn't find child when deleting frame.\n")); return; } @@ -274,17 +275,17 @@ struct frame *find_frame_with_scblocks(struct frame *fr, SCBlock *scblocks) static size_t run_text_len(const struct text_run *run) { if ( run == NULL ) { - fprintf(stderr, "NULL run passed to run_text_len\n"); + fprintf(stderr, _("NULL run passed to run_text_len\n")); return 0; } if ( run->rscblock == NULL ) { - fprintf(stderr, "NULL rscblock in run_text_len\n"); + fprintf(stderr, _("NULL rscblock in run_text_len\n")); return 0; } if ( sc_block_contents(run->rscblock) == NULL ) { - fprintf(stderr, "NULL rscblock contents in run_text_len\n"); + fprintf(stderr, _("NULL rscblock contents in run_text_len\n")); return 0; } @@ -322,7 +323,7 @@ void wrap_paragraph(Paragraph *para, PangoContext *pc, double w, /* Allocate the complete text */ text = malloc(total_len+1); if ( text == NULL ) { - fprintf(stderr, "Couldn't allocate combined text (%lli)\n", + fprintf(stderr, _("Couldn't allocate combined text (%lli)\n"), (long long int)total_len); return; } @@ -403,7 +404,7 @@ void add_run(Paragraph *para, SCBlock *scblock, SCBlock *rscblock, runs_new = realloc(para->runs, (para->n_runs+1)*sizeof(struct text_run)); if ( runs_new == NULL ) { - fprintf(stderr, "Failed to add run.\n"); + fprintf(stderr, _("Failed to add run.\n")); return; } @@ -458,7 +459,7 @@ Paragraph *insert_paragraph(struct frame *fr, int pos) int i; if ( pos >= fr->n_paras ) { - fprintf(stderr, "insert_paragraph(): pos too high!\n"); + fprintf(stderr, _("insert_paragraph(): pos too high!\n")); return NULL; } @@ -493,7 +494,7 @@ Paragraph *add_callback_para(struct frame *fr, SCBlock *bl, SCBlock *rbl, } else { pnew = create_paragraph(fr, bl, rbl); if ( pnew == NULL ) { - fprintf(stderr, "Failed to add callback paragraph\n"); + fprintf(stderr, _("Failed to add callback paragraph\n")); return NULL; } } @@ -522,7 +523,7 @@ void add_image_para(struct frame *fr, SCBlock *scblock, SCBlock *rscblock, int wi, hi; if ( is == NULL ) { - fprintf(stderr, "Adding image without ImageStore!\n"); + fprintf(stderr, _("Adding image without ImageStore!\n")); return; } @@ -531,13 +532,13 @@ void add_image_para(struct frame *fr, SCBlock *scblock, SCBlock *rscblock, } else { pnew = create_paragraph(fr, scblock, rscblock); if ( pnew == NULL ) { - fprintf(stderr, "Failed to add image paragraph\n"); + fprintf(stderr, _("Failed to add image paragraph\n")); return; } } if ( imagestore_get_size(is, filename, &wi, &hi) ) { - fprintf(stderr, "Couldn't get size for %s\n", filename); + fprintf(stderr, _("Couldn't get size for %s\n"), filename); wi = 100; hi = 100; } @@ -639,7 +640,7 @@ void render_paragraph(cairo_t *cr, Paragraph *para, ImageStore *is) if ( surf != NULL ) { render_from_surf(surf, cr, para->image_w, para->image_h, 0); } else { - printf("surf = NULL!\n"); + printf(_("surf = NULL!\n")); } break; @@ -683,7 +684,7 @@ static size_t text_para_pos(Paragraph *para, double x, double y, int *ptrail) void show_edit_pos(struct edit_pos a) { - printf("para %i, pos %li, trail %i\n", a.para, (long int)a.pos, a.trail); + printf(_("para %i, pos %li, trail %i\n"), a.para, (long int)a.pos, a.trail); } @@ -725,7 +726,7 @@ void ensure_run(struct frame *fr, struct edit_pos cpos) if ( para->type != PARA_TYPE_TEXT ) return; if ( para->scblock != para->rscblock ) { - fprintf(stderr, "Need to add run, but paragraph not editable\n"); + fprintf(stderr, _("Need to add run, but paragraph not editable\n")); return; } @@ -733,7 +734,7 @@ void ensure_run(struct frame *fr, struct edit_pos cpos) bl = sc_block_prepend(para->scblock, fr->scblocks); if ( bl == NULL ) { - fprintf(stderr, "Couldn't prepend block\n"); + fprintf(stderr, _("Couldn't prepend block\n")); return; } sc_block_set_contents(bl, strdup("")); @@ -760,7 +761,7 @@ int find_cursor(struct frame *fr, double x, double y, struct edit_pos *pos) int i; if ( fr == NULL ) { - fprintf(stderr, "Cursor frame is NULL.\n"); + fprintf(stderr, _("Cursor frame is NULL.\n")); return 1; } @@ -782,7 +783,7 @@ int find_cursor(struct frame *fr, double x, double y, struct edit_pos *pos) } if ( fr->n_paras == 0 ) { - printf("No paragraphs in frame.\n"); + printf(_("No paragraphs in frame.\n")); return 1; } @@ -803,12 +804,12 @@ int get_para_highlight(struct frame *fr, int cursor_para, double py = 0.0; if ( fr == NULL ) { - fprintf(stderr, "Cursor frame is NULL.\n"); + fprintf(stderr, _("Cursor frame is NULL.\n")); return 1; } if ( cursor_para >= fr->n_paras ) { - fprintf(stderr, "Highlight paragraph number is too high!\n"); + fprintf(stderr, _("Highlight paragraph number is too high!\n")); return 1; } @@ -834,12 +835,12 @@ int get_cursor_pos(struct frame *fr, int cursor_para, int cursor_pos, double py = 0.0; if ( fr == NULL ) { - fprintf(stderr, "Cursor frame is NULL.\n"); + fprintf(stderr, _("Cursor frame is NULL.\n")); return 1; } if ( cursor_para >= fr->n_paras ) { - fprintf(stderr, "Cursor paragraph number is too high!\n"); + fprintf(stderr, _("Cursor paragraph number is too high!\n")); return 1; } @@ -963,12 +964,12 @@ size_t pos_trail_to_offset(Paragraph *para, size_t offs, int trail) nrun = which_run(para, offs); if ( nrun == para->n_runs ) { - fprintf(stderr, "pos_trail_to_offset: Offset too high\n"); + fprintf(stderr, _("pos_trail_to_offset: Offset too high\n")); return 0; } if ( para->n_runs == 0 ) { - fprintf(stderr, "pos_trail_to_offset: No runs\n"); + fprintf(stderr, _("pos_trail_to_offset: No runs\n")); return 0; } @@ -977,18 +978,18 @@ size_t pos_trail_to_offset(Paragraph *para, size_t offs, int trail) if ( para->type != PARA_TYPE_TEXT ) return 0; if ( run == NULL ) { - fprintf(stderr, "pos_trail_to_offset: No run\n"); + fprintf(stderr, _("pos_trail_to_offset: No run\n")); return 0; } if ( run->scblock == NULL ) { - fprintf(stderr, "pos_trail_to_offset: SCBlock = NULL?\n"); + fprintf(stderr, _("pos_trail_to_offset: SCBlock = NULL?\n")); return 0; } if ( sc_block_contents(run->rscblock) == NULL ) { - fprintf(stderr, "pos_trail_to_offset: No contents " - "(%p name=%s, options=%s)\n", + fprintf(stderr, _("pos_trail_to_offset: No contents " + "(%p name=%s, options=%s)\n"), run->scblock, sc_block_name(run->scblock), sc_block_options(run->scblock)); return 0; @@ -1005,8 +1006,8 @@ size_t pos_trail_to_offset(Paragraph *para, size_t offs, int trail) char_offs += trail; if ( char_offs > g_utf8_strlen(run_text, -1) ) { - printf("Offset outside string! '%s'\n" - "char_offs %li offs %li len %li\n", + printf(_("Offset outside string! '%s'\n" + "char_offs %li offs %li len %li\n"), run_text, (long int)char_offs, (long int)offs, (long int)g_utf8_strlen(run_text, -1)); } @@ -1023,31 +1024,31 @@ int position_editable(struct frame *fr, struct edit_pos cp) size_t paraoffs; if ( fr == NULL ) { - fprintf(stderr, "Frame is NULL.\n"); + fprintf(stderr, _("Frame is NULL.\n")); return 0; } if ( cp.para >= fr->n_paras ) { - fprintf(stderr, "Paragraph number is too high!\n"); + fprintf(stderr, _("Paragraph number is too high!\n")); return 0; } para = fr->paras[cp.para]; if ( para->scblock != para->rscblock ) { - fprintf(stderr, "Paragraph is not editable.\n"); + fprintf(stderr, _("Paragraph is not editable.\n")); return 0; } if ( para->type != PARA_TYPE_TEXT ) { - fprintf(stderr, "Paragraph is not text.\n"); + fprintf(stderr, _("Paragraph is not text.\n")); return 0; } paraoffs = pos_trail_to_offset(para, cp.pos, cp.trail); run = which_run(para, paraoffs); if ( run == para->n_runs ) { - fprintf(stderr, "Couldn't find run!\n"); + fprintf(stderr, _("Couldn't find run!\n")); return 0; } @@ -1062,12 +1063,12 @@ void insert_text_in_paragraph(Paragraph *para, size_t offs, const char *t) /* Find which run we are in */ nrun = which_run(para, offs); if ( nrun == para->n_runs ) { - fprintf(stderr, "Couldn't find run to insert into.\n"); + fprintf(stderr, _("Couldn't find run to insert into.\n")); return; } if ( para->n_runs == 0 ) { - printf("No runs in paragraph?\n"); + printf(_("No runs in paragraph?\n")); } else { struct text_run *run; size_t run_offs; @@ -1170,7 +1171,7 @@ static int pos_to_run_number(struct frame *fr, struct edit_pos p) static void delete_run(Paragraph *para, int nrun) { - printf("deleting run %i of %i from para %p\n", nrun, para->n_runs, para); + printf(_("deleting run %i of %i from para %p\n"), nrun, para->n_runs, para); memmove(¶->runs[nrun], ¶->runs[nrun+1], (para->n_runs-nrun-1)*sizeof(struct text_run)); para->n_runs--; @@ -1264,7 +1265,7 @@ static int paragraph_number(struct frame *fr, Paragraph *p, int *err) for ( i=0; i<fr->n_paras; i++ ) { if ( fr->paras[i] == p ) return i; } - fprintf(stderr, "Couldn't find paragraph %p\n", p); + fprintf(stderr, _("Couldn't find paragraph %p\n"), p); *err = 1; return 0; } @@ -1286,11 +1287,11 @@ static void delete_paragraph(struct frame *fr, Paragraph *para, int *pnp) { int pn = find_para(fr, para); if ( pn == fr->n_paras ) { - fprintf(stderr, "Couldn't find paragraph to delete (%p)\n", para); + fprintf(stderr, _("Couldn't find paragraph to delete (%p)\n"), para); return; } - printf("deleting paragraph %i (%p)\n", pn, para); + printf(_("deleting paragraph %i (%p)\n"), pn, para); memmove(&fr->paras[pn], &fr->paras[pn+1], (fr->n_paras-pn-1)*sizeof(Paragraph *)); @@ -1317,7 +1318,7 @@ static void delete_run_for_scblock(struct frame *fr, para = find_run_for_scblock(fr, pn1, pn2, bl, &run); if ( para == NULL ) { - fprintf(stderr, "Couldn't find block %p between paragraphs %p and %p\n", + fprintf(stderr, _("Couldn't find block %p between paragraphs %p and %p\n"), bl, p1, p2); return; } @@ -1339,7 +1340,7 @@ static signed int merge_paragraph_runs(Paragraph *p1, Paragraph *p2) runs_new = realloc(p1->runs, (p1->n_runs+p2->n_runs)*sizeof(struct text_run)); if ( runs_new == NULL ) { - fprintf(stderr, "Failed to allocate merged runs.\n"); + fprintf(stderr, _("Failed to allocate merged runs.\n")); return -1; } p1->runs = runs_new; @@ -1382,7 +1383,7 @@ static void merge_paragraphs_by_newpara(struct frame *fr, SCBlock *np) show_para(p2); spos = merge_paragraph_runs(p1, p2); if ( spos < 0 ) { - fprintf(stderr, "Failed to merge paragraphs\n"); + fprintf(stderr, _("Failed to merge paragraphs\n")); return; } printf("-------------------------------\n"); @@ -1398,7 +1399,7 @@ static void merge_paragraphs_by_newpara(struct frame *fr, SCBlock *np) } } - fprintf(stderr, "Couldn't find paragraphs to merge by newpara\n"); + fprintf(stderr, _("Couldn't find paragraphs to merge by newpara\n")); } @@ -1459,7 +1460,7 @@ void delete_text_from_frame(struct frame *fr, struct edit_pos p1, struct edit_po } if ( !position_editable(fr, p1) || !position_editable(fr, p2) ) { - fprintf(stderr, "Delete outside editable region\n"); + fprintf(stderr, _("Delete outside editable region\n")); return; } @@ -1595,22 +1596,22 @@ void delete_text_from_frame(struct frame *fr, struct edit_pos p1, struct edit_po void show_para(Paragraph *p) { int i; - printf("Paragraph %p\n", p); + printf(_("Paragraph %p\n"), p); if ( p->type == PARA_TYPE_TEXT ) { - printf("%i runs:\n", p->n_runs); + printf(_("%i runs:\n"), p->n_runs); for ( i=0; i<p->n_runs; i++ ) { - printf(" Run %2i: SCBlock %p/%p %s '%s'\n", + printf(_(" Run %2i: SCBlock %p/%p %s '%s'\n"), i, p->runs[i].scblock, p->runs[i].rscblock, pango_font_description_to_string(p->runs[i].fontdesc), sc_block_contents(p->runs[i].rscblock)); } } else if ( p->type == PARA_TYPE_IMAGE ) { - printf(" Image: %s\n", p->filename); + printf(_(" Image: %s\n"), p->filename); } else { - printf(" Other paragraph type\n"); + printf(_(" Other paragraph type\n")); } } @@ -1628,7 +1629,7 @@ static SCBlock *split_text_paragraph(struct frame *fr, int pn, size_t pos, pnew = insert_paragraph(fr, pn); if ( pnew == NULL ) { - fprintf(stderr, "Failed to insert paragraph\n"); + fprintf(stderr, _("Failed to insert paragraph\n")); return NULL; } @@ -1802,7 +1803,7 @@ int get_sc_pos(struct frame *fr, int pn, size_t pos, nrun = which_run(para, pos); if ( nrun == para->n_runs ) { - fprintf(stderr, "Couldn't find run to insert into.\n"); + fprintf(stderr, _("Couldn't find run to insert into.\n")); return 1; } run = ¶->runs[nrun]; diff --git a/src/imagestore.c b/src/imagestore.c index 7775f3b..b6297b7 100644 --- a/src/imagestore.c +++ b/src/imagestore.c @@ -36,6 +36,7 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include "imagestore.h" +#include "utils.h" #define MAX_SIZES (32) @@ -212,7 +213,7 @@ static struct image_record *add_image_record(ImageStore *is, if ( is->n_images == is->max_images ) { if ( alloc_images(is, is->max_images+32) ) { - fprintf(stderr, "Couldn't allocate memory.\n"); + fprintf(stderr, _("Couldn't allocate memory.\n")); return NULL; } } @@ -326,11 +327,11 @@ void show_imagestore(ImageStore *is) { int i; - printf("Store %p contains %i records.\n", is, is->n_images); + printf(_("Store %p contains %i records.\n"), is, is->n_images); for ( i=0; i<is->n_images; i++ ) { - printf("%s :\n", is->images[i].filename); + printf(_("%s :\n"), is->images[i].filename); printf("\n"); } diff --git a/src/narrative_window.c b/src/narrative_window.c index 17885e1..551195e 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -105,7 +105,7 @@ static gint saveas_response_sig(GtkWidget *d, gint response, GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(d)); if ( save_presentation(nw->p, file) ) { - show_error(nw, "Failed to save presentation"); + show_error(nw, _("Failed to save presentation")); } g_object_unref(file); @@ -123,11 +123,11 @@ static void saveas_sig(GSimpleAction *action, GVariant *parameter, gpointer vp) GtkWidget *d; NarrativeWindow *nw = vp; - d = gtk_file_chooser_dialog_new("Save Presentation", + d = gtk_file_chooser_dialog_new(_("Save Presentation"), GTK_WINDOW(nw->window), GTK_FILE_CHOOSER_ACTION_SAVE, - "_Cancel", GTK_RESPONSE_CANCEL, - "_Save", GTK_RESPONSE_ACCEPT, + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_Save"), GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(d), TRUE); @@ -169,7 +169,7 @@ static void delete_slide_sig(GSimpleAction *action, GVariant *parameter, /* Get the SCBlock corresponding to the slide */ ns = sc_editor_get_cursor_bvp(nw->sceditor); if ( ns == NULL ) { - fprintf(stderr, "Not a slide!\n"); + fprintf(stderr, _("Not a slide!\n")); return; } @@ -296,10 +296,10 @@ static gint load_ss_response_sig(GtkWidget *d, gint response, nw->dummy_top); } else { - fprintf(stderr, "Not a style sheet\n"); + fprintf(stderr, _("Not a style sheet\n")); } } else { - fprintf(stderr, "Failed to load\n"); + fprintf(stderr, _("Failed to load\n")); } g_free(filename); @@ -320,11 +320,11 @@ static void load_ss_sig(GSimpleAction *action, GVariant *parameter, NarrativeWindow *nw = vp; GtkWidget *d; - d = gtk_file_chooser_dialog_new("Load stylesheet", + d = gtk_file_chooser_dialog_new(_("Load stylesheet"), GTK_WINDOW(nw->window), GTK_FILE_CHOOSER_ACTION_OPEN, - "_Cancel", GTK_RESPONSE_CANCEL, - "_Open", GTK_RESPONSE_ACCEPT, + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_Open"), GTK_RESPONSE_ACCEPT, NULL); g_signal_connect(G_OBJECT(d), "response", @@ -354,7 +354,7 @@ static void add_slide_sig(GSimpleAction *action, GVariant *parameter, if ( nsblock != NULL ) { sc_block_append_p(nsblock, templ); } else { - fprintf(stderr, "Failed to split paragraph\n"); + fprintf(stderr, _("Failed to split paragraph\n")); } sc_editor_set_scblock(nw->sceditor, nw->dummy_top); @@ -480,11 +480,11 @@ static void exportpdf_sig(GSimpleAction *action, GVariant *parameter, struct presentation *p = vp; GtkWidget *d; - d = gtk_file_chooser_dialog_new("Export PDF", + d = gtk_file_chooser_dialog_new(_("Export PDF"), NULL, GTK_FILE_CHOOSER_ACTION_SAVE, - "_Cancel", GTK_RESPONSE_CANCEL, - "_Export", GTK_RESPONSE_ACCEPT, + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_Export"), GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(d), TRUE); @@ -781,7 +781,7 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *papp Colloquium *app = COLLOQUIUM(papp); if ( p->narrative_window != NULL ) { - fprintf(stderr, "Narrative window is already open!\n"); + fprintf(stderr, _("Narrative window is already open!\n")); return NULL; } @@ -833,7 +833,7 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *papp /* Fullscreen */ image = gtk_image_new_from_icon_name("view-fullscreen", GTK_ICON_SIZE_LARGE_TOOLBAR); - button = gtk_tool_button_new(image, "Start slideshow"); + button = gtk_tool_button_new(image, _("Start slideshow")); gtk_actionable_set_action_name(GTK_ACTIONABLE(button), "win.startslideshow"); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); @@ -844,7 +844,7 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *papp /* Add slide */ image = gtk_image_new_from_icon_name("list-add", GTK_ICON_SIZE_LARGE_TOOLBAR); - button = gtk_tool_button_new(image, "Add slide"); + button = gtk_tool_button_new(image, _("Add slide")); gtk_actionable_set_action_name(GTK_ACTIONABLE(button), "win.slide"); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); @@ -854,28 +854,28 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *papp image = gtk_image_new_from_icon_name("go-top", GTK_ICON_SIZE_LARGE_TOOLBAR); - nw->bfirst = gtk_tool_button_new(image, "First slide"); + nw->bfirst = gtk_tool_button_new(image, _("First slide")); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(nw->bfirst)); gtk_actionable_set_action_name(GTK_ACTIONABLE(nw->bfirst), "win.first"); image = gtk_image_new_from_icon_name("go-up", GTK_ICON_SIZE_LARGE_TOOLBAR); - nw->bprev = gtk_tool_button_new(image, "Previous slide"); + nw->bprev = gtk_tool_button_new(image, _("Previous slide")); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(nw->bprev)); gtk_actionable_set_action_name(GTK_ACTIONABLE(nw->bprev), "win.prev"); image = gtk_image_new_from_icon_name("go-down", GTK_ICON_SIZE_LARGE_TOOLBAR); - nw->bnext = gtk_tool_button_new(image, "Next slide"); + nw->bnext = gtk_tool_button_new(image, _("Next slide")); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(nw->bnext)); gtk_actionable_set_action_name(GTK_ACTIONABLE(nw->bnext), "win.next"); image = gtk_image_new_from_icon_name("go-bottom", GTK_ICON_SIZE_LARGE_TOOLBAR); - nw->blast = gtk_tool_button_new(image, "Last slide"); + nw->blast = gtk_tool_button_new(image, _("Last slide")); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(nw->blast)); gtk_actionable_set_action_name(GTK_ACTIONABLE(nw->blast), "win.last"); diff --git a/src/pr_clock.c b/src/pr_clock.c index 82b9af5..f9fcbe4 100644 --- a/src/pr_clock.c +++ b/src/pr_clock.c @@ -32,6 +32,7 @@ #include "presentation.h" #include "pr_clock.h" +#include "utils.h" struct pr_clock @@ -266,7 +267,7 @@ static gboolean clock_draw_sig(GtkWidget *da, cairo_t *cr, struct pr_clock *n) CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); - cairo_show_text(cr, "Timer is NOT running!"); + cairo_show_text(cr, _("Timer is NOT running!")); } return FALSE; @@ -281,7 +282,7 @@ static void set_sig(GtkEditable *w, struct pr_clock *n) t = gtk_entry_get_text(GTK_ENTRY(n->entry)); n->time_allowed = 60.0 * strtod(t, &check); if ( check == t ) { - fprintf(stderr, "Invalid time '%s'\n", t); + fprintf(stderr, _("Invalid time '%s'\n"), t); n->time_allowed = 0.0; } @@ -325,7 +326,7 @@ static gboolean start_sig(GtkWidget *w, gpointer data) n->running = 0; n->time_elapsed_at_start = n->time_elapsed; gtk_label_set_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(w))), - "Start"); + _("Start")); } else { n->time_elapsed_at_start = n->time_elapsed; if ( n->start != NULL ) { @@ -334,7 +335,7 @@ static gboolean start_sig(GtkWidget *w, gpointer data) n->start = g_date_time_new_now(n->tz); n->running = 1; gtk_label_set_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(w))), - "Stop"); + _("Stop")); } update_clock(n); @@ -368,21 +369,21 @@ PRClock *pr_clock_new() hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 10); - label = gtk_label_new("Length (mins):"); - gtk_label_set_markup(GTK_LABEL(label), "<b>Length (mins):</b>"); + label = gtk_label_new(_("Length (mins):")); + gtk_label_set_markup(GTK_LABEL(label), _("<b>Length (mins):</b>")); g_object_set(G_OBJECT(label), "halign", GTK_ALIGN_END, NULL); gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 10); n->entry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), n->entry, TRUE, TRUE, 0); - n->startbutton = gtk_button_new_with_label("Start"); + n->startbutton = gtk_button_new_with_label(_("Start")); gtk_box_pack_start(GTK_BOX(hbox), n->startbutton, TRUE, TRUE, 10); - resetbutton = gtk_button_new_with_label("Reset"); + resetbutton = gtk_button_new_with_label(_("Reset")); gtk_box_pack_start(GTK_BOX(hbox), resetbutton, TRUE, TRUE, 10); - setposbutton = gtk_button_new_with_label("Set position"); + setposbutton = gtk_button_new_with_label(_("Set position")); gtk_box_pack_start(GTK_BOX(hbox), setposbutton, TRUE, TRUE, 10); n->da = gtk_drawing_area_new(); @@ -395,11 +396,11 @@ PRClock *pr_clock_new() gtk_grid_set_row_spacing(GTK_GRID(grid), 10); gtk_grid_set_column_homogeneous(GTK_GRID(grid), TRUE); gtk_box_pack_start(GTK_BOX(vbox), grid, FALSE, FALSE, 10); - label = gtk_label_new("Time elapsed"); - gtk_label_set_markup(GTK_LABEL(label), "<b>Time elapsed</b>"); + label = gtk_label_new(_("Time elapsed")); + gtk_label_set_markup(GTK_LABEL(label), _("<b>Time elapsed</b>")); gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1); - label = gtk_label_new("Time remaining"); - gtk_label_set_markup(GTK_LABEL(label), "<b>Time remaining</b>"); + label = gtk_label_new(_("Time remaining")); + gtk_label_set_markup(GTK_LABEL(label), _("<b>Time remaining</b>")); gtk_grid_attach(GTK_GRID(grid), label, 1, 0, 1, 1); n->status = gtk_label_new("<status>"); gtk_grid_attach(GTK_GRID(grid), n->status, 2, 0, 1, 1); @@ -430,7 +431,7 @@ PRClock *pr_clock_new() update_clock(n); n->timer_id = g_timeout_add_seconds(1, update_clock, n); - gtk_window_set_title(GTK_WINDOW(n->window), "Presentation clock"); + gtk_window_set_title(GTK_WINDOW(n->window), _("Presentation clock")); gtk_widget_show_all(n->window); return n; diff --git a/src/presentation.c b/src/presentation.c index 576768d..b8b4589 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -57,7 +57,7 @@ void free_presentation(struct presentation *p) char *get_titlebar_string(struct presentation *p) { if ( p == NULL || p->uri == NULL ) { - return strdup("(untitled)"); + return strdup(_("(untitled)")); } else { GFile *f = g_file_new_for_uri(p->uri); char *bn = g_file_get_basename(f); @@ -101,7 +101,7 @@ int save_presentation(struct presentation *p, GFile *file) fh = g_file_replace(file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error); if ( fh == NULL ) { - fprintf(stderr, "Open failed: %s\n", error->message); + fprintf(stderr, _("Open failed: %s\n"), error->message); return 1; } r = save_sc_block(G_OUTPUT_STREAM(fh), p->scblocks); @@ -161,7 +161,7 @@ SCBlock *first_slide(struct presentation *p) bl = sc_block_next(bl); } - fprintf(stderr, "Couldn't find first slide!\n"); + fprintf(stderr, _("Couldn't find first slide!\n")); return NULL; } @@ -179,7 +179,7 @@ SCBlock *last_slide(struct presentation *p) } if ( l == NULL ) { - fprintf(stderr, "Couldn't find last slide!\n"); + fprintf(stderr, _("Couldn't find last slide!\n")); } return l; } @@ -200,7 +200,7 @@ SCBlock *next_slide(struct presentation *p, SCBlock *sl) bl = sc_block_next(bl); } - fprintf(stderr, "Couldn't find next slide!\n"); + fprintf(stderr, _("Couldn't find next slide!\n")); return NULL; } @@ -221,7 +221,7 @@ SCBlock *prev_slide(struct presentation *p, SCBlock *sl) bl = sc_block_next(bl); } - fprintf(stderr, "Couldn't find prev slide!\n"); + fprintf(stderr, _("Couldn't find prev slide!\n")); return NULL; } @@ -267,14 +267,14 @@ SCBlock *find_stylesheet(SCBlock *bl) static void install_stylesheet(struct presentation *p) { if ( p->stylesheet != NULL ) { - fprintf(stderr, "Duplicate style sheet!\n"); + fprintf(stderr, _("Duplicate style sheet!\n")); return; } p->stylesheet = find_stylesheet(p->scblocks); if ( p->stylesheet == NULL ) { - fprintf(stderr, "No style sheet.\n"); + fprintf(stderr, _("No style sheet.\n")); } } @@ -307,7 +307,7 @@ int load_presentation(struct presentation *p, GFile *file) assert(p->completely_empty); if ( !g_file_load_contents(file, NULL, &everything, NULL, NULL, NULL) ) { - fprintf(stderr, "Failed to load '%s'\n", g_file_get_uri(file)); + fprintf(stderr, _("Failed to load '%s'\n"), g_file_get_uri(file)); return 1; } @@ -320,7 +320,7 @@ int load_presentation(struct presentation *p, GFile *file) if ( r ) { p->completely_empty = 1; - fprintf(stderr, "Parse error.\n"); + fprintf(stderr, _("Parse error.\n")); return r; /* Error */ } diff --git a/src/print.c b/src/print.c index d2e8ac2..b0e3a84 100644 --- a/src/print.c +++ b/src/print.c @@ -33,6 +33,7 @@ #include "presentation.h" #include "narrative_window.h" #include "render.h" +#include "utils.h" static GtkPrintSettings *print_settings = NULL; @@ -86,9 +87,9 @@ static GObject *print_widget(GtkPrintOperation *op, void *vp) /* What do you want to print? */ cbox = gtk_combo_box_text_new(); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(cbox), "slides", - "Print the slides only"); + _("Print the slides only")); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(cbox), "narrative", - "Print the narrative"); + _("Print the narrative")); gtk_box_pack_start(GTK_BOX(vbox), cbox, FALSE, FALSE, 10); gtk_combo_box_set_active(GTK_COMBO_BOX(cbox), 1); ps->combo = cbox; diff --git a/src/render.c b/src/render.c index 103194e..fd8151c 100644 --- a/src/render.c +++ b/src/render.c @@ -191,7 +191,7 @@ struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets, scin = sc_interp_new(pc, lang, is, top); if ( scin == NULL ) { - fprintf(stderr, "Failed to set up interpreter.\n"); + fprintf(stderr, _("Failed to set up interpreter.\n")); frame_free(top); return NULL; } @@ -290,7 +290,7 @@ int export_pdf(struct presentation *p, const char *filename) surf = cairo_pdf_surface_create(filename, w, w*r); if ( cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS ) { - fprintf(stderr, "Couldn't create Cairo surface\n"); + fprintf(stderr, _("Couldn't create Cairo surface\n")); return 1; } diff --git a/src/sc_editor.c b/src/sc_editor.c index bb22400..96606c6 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -70,7 +70,7 @@ static void debug_paragraphs(SCEditor *e) struct frame *fr = e->cursor_frame; int i; - printf("Paragraphs in current frame:\n"); + printf(_("Paragraphs in current frame:\n")); for ( i=0; i<fr->n_paras; i++ ) { show_para(fr->paras[i]); } @@ -766,7 +766,7 @@ static void do_backspace(struct frame *fr, SCEditor *e) } else { /* FIXME: Implement this */ - fprintf(stderr, "Deleting non-text paragraph\n"); + fprintf(stderr, _("Deleting non-text paragraph\n")); } @@ -807,7 +807,7 @@ static void insert_text(char *t, SCEditor *e) /* Yes. The "easy" case */ if ( !position_editable(e->cursor_frame, e->cpos) ) { - fprintf(stderr, "Position not editable\n"); + fprintf(stderr, _("Position not editable\n")); return; } @@ -828,20 +828,20 @@ static void insert_text(char *t, SCEditor *e) bd = para_scblock(para); if ( bd == NULL ) { - fprintf(stderr, "No SCBlock for para\n"); + fprintf(stderr, _("No SCBlock for para\n")); return; } /* No. Create a new text paragraph straight afterwards */ ad = sc_block_insert_after(bd, NULL, NULL, strdup(t)); if ( ad == NULL ) { - fprintf(stderr, "Failed to add SCBlock\n"); + fprintf(stderr, _("Failed to add SCBlock\n")); return; } pnew = insert_paragraph(e->cursor_frame, e->cpos.para); if ( pnew == NULL ) { - fprintf(stderr, "Failed to insert paragraph\n"); + fprintf(stderr, _("Failed to insert paragraph\n")); return; } add_run(pnew, ad, ad, e->cursor_frame->fontdesc, @@ -1421,7 +1421,7 @@ static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event, { case DRAG_REASON_NONE : - printf("Release on pointless drag.\n"); + printf(_("Release on pointless drag.\n")); break; case DRAG_REASON_CREATE : @@ -1436,7 +1436,7 @@ static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event, e->cpos.pos = 0; e->cpos.trail = 0; } else { - fprintf(stderr, "Failed to create frame!\n"); + fprintf(stderr, _("Failed to create frame!\n")); } break; @@ -1589,16 +1589,16 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, if ( event->state & GDK_CONTROL_MASK ) { debug_paragraphs(e); } else if ( event->state & GDK_SHIFT_MASK ) { - printf("Cursor frame block = %p\n", e->cursor_frame->scblocks); - printf("Editor top block = %p\n", e->scblocks); + printf(_("Cursor frame block = %p\n"), e->cursor_frame->scblocks); + printf(_("Editor top block = %p\n"), e->scblocks); show_sc_block(e->cursor_frame->scblocks, ""); } else { open_debugger(e->cursor_frame); } } else { if ( event->state & GDK_SHIFT_MASK ) { - printf("Debugging the top frame:\n"); - printf("Editor top block = %p\n", e->scblocks); + printf(_("Debugging the top frame:\n")); + printf(_("Editor top block = %p\n"), e->scblocks); show_sc_block(e->top->scblocks, ""); } } @@ -1802,7 +1802,7 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context, opts = malloc(len); if ( opts == NULL ) { free(filename); - fprintf(stderr, "Failed to allocate SC\n"); + fprintf(stderr, _("Failed to allocate SC\n")); return; } snprintf(opts, len, "1fx1f+0+0,filename=\"%s\"", @@ -2033,7 +2033,7 @@ void sc_editor_set_scale(SCEditor *e, int scale) void sc_editor_set_imagestore(SCEditor *e, ImageStore *is) { if ( e->is != NULL ) { - fprintf(stderr, "WARNING: Changing imagestore\n"); + fprintf(stderr, _("WARNING: Changing imagestore\n")); } e->is = is; } @@ -2077,7 +2077,7 @@ SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets, sceditor->bg_pixbuf = gdk_pixbuf_new_from_resource("/uk/me/bitwiz/Colloquium/sky.png", &err); if ( sceditor->bg_pixbuf == NULL ) { - fprintf(stderr, "Failed to load background: %s\n", + fprintf(stderr, _("Failed to load background: %s\n"), err->message); } diff --git a/src/sc_interp.c b/src/sc_interp.c index 98a944d..9ee6e34 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -35,6 +35,7 @@ #include "sc_parse.h" #include "sc_interp.h" #include "presentation.h" +#include "utils.h" struct macro @@ -185,7 +186,7 @@ void sc_callback_list_add_callback(SCCallbackList *cbl, const char *name, if ( (names_new == NULL) || (box_funcs_new == NULL) || (vps_new == NULL) || (draw_funcs_new == NULL) || (click_funcs_new == NULL) ) { - fprintf(stderr, "Failed to grow callback list\n"); + fprintf(stderr, _("Failed to grow callback list\n")); return; } @@ -210,8 +211,8 @@ void sc_callback_list_add_callback(SCCallbackList *cbl, const char *name, void sc_interp_set_callbacks(SCInterpreter *scin, SCCallbackList *cbl) { if ( scin->cbl != NULL ) { - fprintf(stderr, "WARNING: Interpreter already has a callback " - "list.\n"); + fprintf(stderr, _("WARNING: Interpreter already has a callback " + "list.\n")); } scin->cbl = cbl; } @@ -325,7 +326,7 @@ static void update_font(SCInterpreter *scin) scin->pc, st->fontdesc); if ( st->font == NULL ) { char *f = pango_font_description_to_string(st->fontdesc); - fprintf(stderr, "Couldn't load font '%s' (font map %p, pc %p)\n", + fprintf(stderr, _("Couldn't load font '%s' (font map %p, pc %p)\n"), f, pango_context_get_font_map(scin->pc), scin->pc); g_free(f); return; @@ -346,7 +347,7 @@ static void set_font(SCInterpreter *scin, const char *font_name) st->fontdesc = pango_font_description_from_string(font_name); if ( st->fontdesc == NULL ) { - fprintf(stderr, "Couldn't describe font.\n"); + fprintf(stderr, _("Couldn't describe font.\n")); return; } @@ -380,7 +381,7 @@ static void set_fontsize(SCInterpreter *scin, const char *size_str) size = strtoul(size_str, &end, 10); if ( end[0] != '\0' ) { - fprintf(stderr, "Invalid font size '%s'\n", size_str); + fprintf(stderr, _("Invalid font size '%s'\n"), size_str); return; } @@ -431,7 +432,7 @@ static void set_colour(SCInterpreter *scin, const char *colour) struct sc_state *st = &scin->state[scin->j]; if ( colour == NULL ) { - printf("Invalid colour\n"); + printf(_("Invalid colour\n")); st->col[0] = 0.0; st->col[1] = 0.0; st->col[2] = 0.0; @@ -456,7 +457,7 @@ static void set_frame_bgcolour(struct frame *fr, const char *colour) if ( fr == NULL ) return; if ( colour == NULL ) { - printf("Invalid colour\n"); + printf(_("Invalid colour\n")); fr->bgcol[0] = 0.0; fr->bgcol[1] = 0.0; fr->bgcol[2] = 0.0; @@ -484,13 +485,13 @@ static void set_frame_bggrad(struct frame *fr, const char *options, if ( fr == NULL ) return; if ( options == NULL ) { - fprintf(stderr, "Invalid bg gradient spec '%s'\n", options); + fprintf(stderr, _("Invalid bg gradient spec '%s'\n"), options); return; } n2 = strchr(optcopy, ','); if ( n2 == NULL ) { - fprintf(stderr, "Invalid bg gradient spec '%s'\n", options); + fprintf(stderr, _("Invalid bg gradient spec '%s'\n"), options); return; } @@ -524,7 +525,7 @@ void sc_interp_save(SCInterpreter *scin) stack_new = realloc(scin->state, sizeof(struct sc_state) * (scin->max_state+8)); if ( stack_new == NULL ) { - fprintf(stderr, "Failed to add to stack.\n"); + fprintf(stderr, _("Failed to add to stack.\n")); return; } @@ -668,7 +669,7 @@ static int parse_double(const char *a, float v[2]) nn = sscanf(a, "%fx%f", &v[0], &v[1]); if ( nn != 2 ) { - fprintf(stderr, "Invalid size '%s'\n", a); + fprintf(stderr, _("Invalid size '%s'\n"), a); return 1; } @@ -682,7 +683,7 @@ static int parse_tuple(const char *a, float v[4]) nn = sscanf(a, "%f,%f,%f,%f", &v[0], &v[1], &v[2], &v[3]); if ( nn != 4 ) { - fprintf(stderr, "Invalid tuple '%s'\n", a); + fprintf(stderr, _("Invalid tuple '%s'\n"), a); return 1; } @@ -750,7 +751,7 @@ static LengthUnits get_units(const char *t) if ( t[len-1] == 'f' ) return UNITS_FRAC; if ( t[len-1] == 'u' ) return UNITS_SLIDE; - fprintf(stderr, "Invalid units in '%s'\n", t); + fprintf(stderr, _("Invalid units in '%s'\n"), t); return UNITS_SLIDE; } @@ -815,7 +816,7 @@ static int parse_dims(const char *opt, struct frame *parent, return 0; invalid: - fprintf(stderr, "Invalid dimensions '%s'\n", opt); + fprintf(stderr, _("Invalid dimensions '%s'\n"), opt); return 1; } @@ -828,7 +829,7 @@ static int parse_frame_option(const char *opt, struct frame *fr, return parse_dims(opt, parent, &fr->w, &fr->h, &fr->x, &fr->y); } - fprintf(stderr, "Unrecognised frame option '%s'\n", opt); + fprintf(stderr, _("Unrecognised frame option '%s'\n"), opt); return 1; } @@ -885,7 +886,7 @@ static int parse_image_option(const char *opt, struct frame *parent, char *fn; fn = strdup(opt+10); if ( fn[strlen(fn)-1] != '\"' ) { - fprintf(stderr, "Unterminated filename?\n"); + fprintf(stderr, _("Unterminated filename?\n")); free(fn); return 1; } @@ -894,7 +895,7 @@ static int parse_image_option(const char *opt, struct frame *parent, return 0; } - fprintf(stderr, "Unrecognised image option '%s'\n", opt); + fprintf(stderr, _("Unrecognised image option '%s'\n"), opt); return 1; } @@ -1041,7 +1042,7 @@ static int check_outputs(SCBlock *bl, SCInterpreter *scin) filename, scin->is, w, h, 1); free(filename); } else { - fprintf(stderr, "Invalid image options '%s'\n", + fprintf(stderr, _("Invalid image options '%s'\n"), options); } @@ -1057,7 +1058,7 @@ static int check_outputs(SCBlock *bl, SCInterpreter *scin) fr->resizable = 1; } if ( fr == NULL ) { - fprintf(stderr, "Failed to add frame.\n"); + fprintf(stderr, _("Failed to add frame.\n")); return 1; } @@ -1292,7 +1293,7 @@ static int try_add_macro(SCInterpreter *scin, const char *options, SCBlock *bl) macros_new = realloc(st->macros, sizeof(struct macro) * (st->max_macros+16)); if ( macros_new == NULL ) { - fprintf(stderr, "Failed to add macro.\n"); + fprintf(stderr, _("Failed to add macro.\n")); return 1; } @@ -1326,7 +1327,7 @@ static int try_add_template(SCInterpreter *scin, const char *options, SCBlock *b for ( i=0; i<st->n_templates; i++ ) { if ( strcmp(st->templates[i].name, nn) == 0 ) { - fprintf(stderr, "Duplicate template '%s'\n", nn); + fprintf(stderr, _("Duplicate template '%s'\n"), nn); return 0; } } @@ -1338,7 +1339,7 @@ static int try_add_template(SCInterpreter *scin, const char *options, SCBlock *b templates_new = realloc(st->templates, sizeof(struct template) * (st->max_templates+16)); if ( templates_new == NULL ) { - fprintf(stderr, "Failed to add templates\n"); + fprintf(stderr, _("Failed to add templates\n")); return 1; } @@ -1367,7 +1368,7 @@ void sc_interp_run_stylesheet(SCInterpreter *scin, SCBlock *bl) if ( bl == NULL ) return; if ( strcmp(sc_block_name(bl), "stylesheet") != 0 ) { - fprintf(stderr, "Style sheet isn't a style sheet.\n"); + fprintf(stderr, _("Style sheet isn't a style sheet.\n")); return; } diff --git a/src/sc_parse.c b/src/sc_parse.c index 3212872..a13c876 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -34,6 +34,7 @@ #include <gio/gio.h> #include "sc_parse.h" +#include "utils.h" struct _scblock { @@ -112,7 +113,7 @@ SCBlock *sc_block_prepend(SCBlock *bl, SCBlock *top) prev = sc_find_previous(top, bl); if ( prev == NULL ) { - fprintf(stderr, "Couldn't find previous\n"); + fprintf(stderr, _("Couldn't find previous\n")); return NULL; } @@ -266,7 +267,7 @@ static SCBlock *sc_find_parent(SCBlock *top, SCBlock *find) void sc_block_substitute(SCBlock **top, SCBlock *old, SCBlock *new) { if ( old == NULL ) { - fprintf(stderr, "Substituting nothing!\n"); + fprintf(stderr, _("Substituting nothing!\n")); return; } @@ -288,11 +289,11 @@ int sc_block_unlink(SCBlock **top, SCBlock *deleteme) if ( parent == NULL ) { /* Maybe it's the first block? */ if ( *top == deleteme ) { - fprintf(stderr, "Unlinking at top\n"); + fprintf(stderr, _("Unlinking at top\n")); *top = (*top)->next; return 0; } else { - fprintf(stderr, "Couldn't find block parent!\n"); + fprintf(stderr, _("Couldn't find block parent!\n")); return 1; } } @@ -418,12 +419,12 @@ int save_sc_block(GOutputStream *fh, const SCBlock *bl) char *a = serialise_sc_block(bl); gssize r; if ( a == NULL ) { - fprintf(stderr, "Failed to serialise block\n"); + fprintf(stderr, _("Failed to serialise block\n")); return 1; } r = g_output_stream_write(fh, a, strlen(a), NULL, &error); if ( r == -1 ) { - fprintf(stderr, "Write failed: %s\n", error->message); + fprintf(stderr, _("Write failed: %s\n"), error->message); return 1; } free(a); @@ -546,7 +547,7 @@ static size_t read_block(const char *sc, char **pname, char **options, i += get_subexpr(sc+i+1, "[]", options, err) + 1; if ( *err ) { - printf("Couldn't find end of options '%s'\n", sc+i); + printf(_("Couldn't find end of options '%s'\n"), sc+i); return 0; } @@ -558,7 +559,7 @@ static size_t read_block(const char *sc, char **pname, char **options, i += get_subexpr(sc+i+1, "{}", contents, err) + 1; if ( *err ) { - printf("Couldn't find end of content '%s'\n", sc+i); + printf(_("Couldn't find end of content '%s'\n"), sc+i); return 0; } @@ -656,7 +657,7 @@ SCBlock *sc_parse(const char *sc) bl = sc_block_append(bl, NULL, NULL, strdup(tbuf), &blf); if ( bl == NULL ) { - fprintf(stderr, "Block add failed.\n"); + fprintf(stderr, _("Block add failed.\n")); sc_block_free(blf); free(tbuf); return NULL; @@ -666,7 +667,7 @@ SCBlock *sc_parse(const char *sc) i += read_block(sc+i+1, &name, &opt, &contents, &err); if ( err ) { - printf("Parse error\n"); + printf(_("Parse error\n")); sc_block_free(blf); free(tbuf); return NULL; @@ -674,7 +675,7 @@ SCBlock *sc_parse(const char *sc) bl = sc_block_append(bl, name, opt, contents, &blf); if ( bl == NULL ) { - fprintf(stderr, "Block add failed.\n"); + fprintf(stderr, _("Block add failed.\n")); sc_block_free(blf); free(tbuf); return NULL; @@ -699,7 +700,7 @@ SCBlock *sc_parse(const char *sc) tbuf[j] = '\0'; bl = sc_block_append(bl, NULL, NULL, tbuf, &blf); if ( bl == NULL ) { - fprintf(stderr, "Block add failed.\n"); + fprintf(stderr, _("Block add failed.\n")); sc_block_free(blf); free(tbuf); return NULL; @@ -716,7 +717,7 @@ SCBlock *sc_parse(const char *sc) void sc_block_set_name(SCBlock *bl, char *nam) { if ( bl == NULL ) { - fprintf(stderr, "sc_block_set_name: NULL block\n"); + fprintf(stderr, _("sc_block_set_name: NULL block\n")); return; } free(bl->name); @@ -795,7 +796,7 @@ size_t scblock_delete_text(SCBlock *b, ssize_t o1, ssize_t o2) size_t len; if ( b->contents == NULL ) { - fprintf(stderr, "Deleting text from block \\%s\n", b->name); + fprintf(stderr, _("Deleting text from block \\%s\n"), b->name); return 0; } @@ -808,7 +809,7 @@ size_t scblock_delete_text(SCBlock *b, ssize_t o1, ssize_t o2) len = strlen(b->contents); if ( o2 < 0 ) o2 = len; if ( (o1 >= o2) || (o1 > len) || (o2 > len) ) { - fprintf(stderr, "Invalid delete: %i %i %i\n", + fprintf(stderr, _("Invalid delete: %i %i %i\n"), (int)o1, (int)o2, (int)len); return 0; } @@ -861,7 +862,7 @@ SCBlock *sc_block_split(SCBlock *bl, size_t pos) SCBlock *n = sc_block_new(); if ( bl->child != NULL ) { - fprintf(stderr, "Splitting a block with a child!\n"); + fprintf(stderr, _("Splitting a block with a child!\n")); return NULL; } diff --git a/src/slide_window.c b/src/slide_window.c index 9dcab2d..28d556b 100644 --- a/src/slide_window.c +++ b/src/slide_window.c @@ -43,6 +43,7 @@ #include "sc_parse.h" #include "sc_interp.h" #include "sc_editor.h" +#include "utils.h" struct _slidewindow diff --git a/src/slideshow.c b/src/slideshow.c index 194befd..754a453 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -36,6 +36,7 @@ #include "render.h" #include "pr_clock.h" #include "frame.h" +#include "utils.h" G_DEFINE_TYPE_WITH_CODE(SCSlideshow, sc_slideshow, GTK_TYPE_WINDOW, NULL) @@ -216,11 +217,11 @@ SCSlideshow *sc_slideshow_new(struct presentation *p, GtkApplication *app) GdkMonitor *mon_ss; if ( n_monitors == 1 ) { mon_ss = gdk_display_get_primary_monitor(display); - printf("Single monitor mode\n"); + printf(_("Single monitor mode\n")); ss->single_monitor = 1; } else { mon_ss = gdk_display_get_monitor(display, 1); - printf("Dual monitor mode\n"); + printf(_("Dual monitor mode\n")); ss->single_monitor = 0; } @@ -235,7 +236,7 @@ SCSlideshow *sc_slideshow_new(struct presentation *p, GtkApplication *app) if ( app != NULL ) { ss->inhibit_cookie = gtk_application_inhibit(app, GTK_WINDOW(ss), GTK_APPLICATION_INHIBIT_IDLE, - "Presentation slide show is running"); + _("Presentation slide show is running")); } return ss; diff --git a/src/testcard.c b/src/testcard.c index 5c723a0..2b6598f 100644 --- a/src/testcard.c +++ b/src/testcard.c @@ -32,6 +32,7 @@ #include <gdk/gdkkeysyms.h> #include "presentation.h" +#include "utils.h" struct testcard @@ -173,9 +174,10 @@ static gboolean tc_draw_sig(GtkWidget *da, cairo_t *cr, struct testcard *tc) cairo_save(cr); cairo_translate(cr, 0.0, yp); - snprintf(tmp, 1024, "Colloquium "PACKAGE_VERSION" test card\n" + snprintf(tmp, 1024, _("Colloquium %s test card\n" "Screen resolution %.0f × %.0f\n" - "Slide resolution %i × %i", width, height, + "Slide resolution %i × %i"), + PACKAGE_VERSION, width, height, tc->slide_width, h); pl = pango_cairo_create_layout(cr); @@ -192,12 +194,12 @@ static gboolean tc_draw_sig(GtkWidget *da, cairo_t *cr, struct testcard *tc) /* Colour boxes */ xp = (tc->slide_width-450)/2.0; - colour_box(cr, xp+0, 200, 1.0, 0.0, 0.0, "Red"); - colour_box(cr, xp+80, 200, 0.0, 1.0, 0.0, "Green"); - colour_box(cr, xp+160, 200, 0.0, 0.0, 1.0, "Blue"); - colour_box(cr, xp+240, 200, 1.0, 1.0, 0.0, "Yellow"); - colour_box(cr, xp+320, 200, 1.0, 0.0, 1.0, "Pink"); - colour_box(cr, xp+400, 200, 0.0, 1.0, 1.0, "Cyan"); + colour_box(cr, xp+0, 200, 1.0, 0.0, 0.0, _("Red")); + colour_box(cr, xp+80, 200, 0.0, 1.0, 0.0, _("Green")); + colour_box(cr, xp+160, 200, 0.0, 0.0, 1.0, _("Blue")); + colour_box(cr, xp+240, 200, 1.0, 1.0, 0.0, _("Yellow")); + colour_box(cr, xp+320, 200, 1.0, 0.0, 1.0, _("Pink")); + colour_box(cr, xp+400, 200, 0.0, 1.0, 1.0, _("Cyan")); /* Shades of grey */ double i; @@ -268,10 +270,10 @@ void show_testcard(struct presentation *p) GdkMonitor *mon_ss; if ( n_monitors == 1 ) { mon_ss = gdk_display_get_primary_monitor(display); - printf("Single monitor mode\n"); + printf(_("Single monitor mode\n")); } else { mon_ss = gdk_display_get_monitor(display, 1); - printf("Dual monitor mode\n"); + printf(_("Dual monitor mode\n")); } /* Workaround because gtk_window_fullscreen_on_monitor doesn't work */ diff --git a/src/utils.c b/src/utils.c index 0191d18..9033466 100644 --- a/src/utils.c +++ b/src/utils.c @@ -29,6 +29,8 @@ #include <stdio.h> #include <stdlib.h> +#include "utils.h" + void chomp(char *s) { size_t i; @@ -125,7 +127,7 @@ char *load_everything(const char *filename) everything = realloc(everything, el+len); if ( everything == NULL ) { - fprintf(stderr, "Failed to allocate memory\n"); + fprintf(stderr, _("Failed to allocate memory\n")); return NULL; } el += len; diff --git a/src/utils.h b/src/utils.h index cc686f2..bfc04c2 100644 --- a/src/utils.h +++ b/src/utils.h @@ -32,6 +32,7 @@ extern void chomp(char *s); extern int safe_strcmp(const char *a, const char *b); extern char *load_everything(const char *filename); +#include <libintl.h> #define _(x) gettext(x) #endif /* UTILS_H */ |