From e00e467d3d1de49cfc5f261d91ab272cd6fae065 Mon Sep 17 00:00:00 2001 From: Peter Verthez Date: Tue, 11 Dec 2001 21:03:50 +0000 Subject: [PATCH] Added gettext calls. --- gedcom/encoding.c | 14 +++++++------- gedcom/gedcom.y | 39 +++++++++++++++++--------------------- gedcom/gedcom_lex_common.c | 15 +++++++-------- gedcom/message.c | 4 ++-- po/POTFILES.in | 4 ++++ 5 files changed, 37 insertions(+), 39 deletions(-) diff --git a/gedcom/encoding.c b/gedcom/encoding.c index a801b5f..0c7af44 100644 --- a/gedcom/encoding.c +++ b/gedcom/encoding.c @@ -64,7 +64,7 @@ void add_encoding(char *gedcom_n, char* charwidth, char *iconv_n) strcpy(nodeptr->iconv_name, iconv_n); datum = tsearch(nodeptr, &encoding_mapping, node_compare); if ((datum == NULL) || (*datum != nodeptr)) { - gedcom_warning("Duplicate entry found for encoding '%s', ignoring", + gedcom_warning(_("Duplicate entry found for encoding '%s', ignoring"), gedcom_n); } } @@ -81,7 +81,7 @@ char* get_encoding(char* gedcom_n, ENCODING enc) datum = tfind(&search_node, &encoding_mapping, node_compare); free(buffer); if (datum == NULL) { - gedcom_error("No encoding found for '%s'", gedcom_n); + gedcom_error(_("No encoding found for '%s'"), gedcom_n); return NULL; } else { @@ -118,7 +118,7 @@ void init_encodings() GCONV_SEARCH_PATH, gconv_path, PKGDATADIR); } if (putenv(new_gconv_path) != 0) { - gedcom_warning("Failed updating environment variable %s", + gedcom_warning(_("Failed updating environment variable %s"), GCONV_SEARCH_PATH); } } @@ -131,13 +131,13 @@ void init_encodings() in = fopen(path, "r"); } if (in == NULL) { - gedcom_warning("Could not open encoding configuration file '%s'", + gedcom_warning(_("Could not open encoding configuration file '%s'"), ENCODING_CONF_FILE); } else { while (fgets(buffer, sizeof(buffer), in) != NULL) { if (buffer[strlen(buffer) - 1] != '\n') { - gedcom_error("Line too long in encoding configuration file '%s'", + gedcom_error(_("Line too long in encoding configuration file '%s'"), ENCODING_CONF_FILE); return; } @@ -146,7 +146,7 @@ void init_encodings() add_encoding(gedcom_n, charwidth, iconv_n); } else { - gedcom_error("Missing data in encoding configuration file '%s'", + gedcom_error(_("Missing data in encoding configuration file '%s'"), ENCODING_CONF_FILE); return; } @@ -178,7 +178,7 @@ int open_conv_to_internal(char* fromcode) conv_buf_size = 0; cd_to_internal = iconv_open(INTERNAL_ENCODING, encoding); if (cd_to_internal == (iconv_t) -1) { - gedcom_error("Error opening conversion context for encoding %s: %s", + gedcom_error(_("Error opening conversion context for encoding %s: %s"), encoding, strerror(errno)); } } diff --git a/gedcom/gedcom.y b/gedcom/gedcom.y index 3765b7b..dbef9e5 100644 --- a/gedcom/gedcom.y +++ b/gedcom/gedcom.y @@ -197,7 +197,7 @@ int compat_mode(int flags); #define CHK(TAG) \ { if (!check_occurrence(TAG_##TAG)) { \ char* parenttag = get_parenttag(); \ - gedcom_error("The tag '%s' is mandatory within '%s', but missing", \ + gedcom_error(_("The tag '%s' is mandatory within '%s', but missing"),\ #TAG, parenttag); \ HANDLE_ERROR; \ } \ @@ -219,20 +219,19 @@ int compat_mode(int flags); { int num = count_tag(TAG_##CHILDTAG); \ if (num > MAX) { \ char* parenttag = get_parenttag(); \ - gedcom_error("The tag '%s' can maximally occur %d " \ - "time(s) within '%s'", \ + gedcom_error(_("The tag '%s' can maximally occur %d time(s) within '%s'"), \ #CHILDTAG, MAX, parenttag); \ HANDLE_ERROR; \ } \ } #define INVALID_TAG(CHILDTAG) \ { char* parenttag = get_parenttag(); \ - gedcom_error("The tag '%s' is not a valid tag within '%s'", \ + gedcom_error(_("The tag '%s' is not a valid tag within '%s'"), \ CHILDTAG, parenttag); \ HANDLE_ERROR; \ } #define INVALID_TOP_TAG(CHILDTAG) \ - { gedcom_error("The tag '%s' is not a valid top-level tag", \ + { gedcom_error(_("The tag '%s' is not a valid top-level tag"), \ CHILDTAG); \ HANDLE_ERROR; \ } @@ -1044,12 +1043,11 @@ note_rec : OPEN DELIM POINTER DELIM TAG_NOTE note_line_item note_line_item : /* empty */ { if (!compat_mode(C_FTREE)) { - gedcom_error("Missing value"); YYERROR; + gedcom_error(_("Missing value")); YYERROR; } } | DELIM line_item - { gedcom_debug_print("==Val: %s==\n", $2); - $$ = $2; } + { $$ = $2; } ; note_subs : /* empty */ @@ -2265,7 +2263,7 @@ no_std_rec : user_rec /* 0:M */ user_rec : OPEN DELIM opt_xref USERTAG { if ($4[0] != '_') { - gedcom_error("Undefined tag (and not a valid user tag): %s", + gedcom_error(_("Undefined tag (and not a valid user tag): %s"), $4); YYERROR; } @@ -2281,7 +2279,7 @@ user_rec : OPEN DELIM opt_xref USERTAG ; user_sect : OPEN DELIM opt_xref USERTAG { if ($4[0] != '_') { - gedcom_error("Undefined tag (and not a valid user tag): %s", + gedcom_error(_("Undefined tag (and not a valid user tag): %s"), $4); YYERROR; } @@ -2313,14 +2311,12 @@ line_value : POINTER { $$ = $1; } | line_item { $$ = $1; } ; -mand_pointer : /* empty */ { gedcom_error("Missing pointer"); YYERROR; } - | DELIM POINTER { gedcom_debug_print("==Ptr: %s==\n", $2); - $$ = $2; } +mand_pointer : /* empty */ { gedcom_error(_("Missing pointer")); YYERROR; } + | DELIM POINTER { $$ = $2; } ; -mand_line_item : /* empty */ { gedcom_error("Missing value"); YYERROR; } - | DELIM line_item { gedcom_debug_print("==Val: %s==\n", $2); - $$ = $2; } +mand_line_item : /* empty */ { gedcom_error(_("Missing value")); YYERROR; } + | DELIM line_item { $$ = $2; } ; opt_line_item : /* empty */ { } @@ -2386,7 +2382,7 @@ gen_rec_norm : OPEN DELIM opt_xref anystdtag ; gen_rec_top : OPEN DELIM anytoptag - { gedcom_error("Missing cross-reference"); YYERROR; } + { gedcom_error(_("Missing cross-reference")); YYERROR; } opt_value opt_sects CLOSE { } ; @@ -2549,13 +2545,13 @@ void push_countarray() { int *count = NULL; if (count_level > MAXGEDCLEVEL) { - gedcom_error("Internal error: count array overflow"); + gedcom_error(_("Internal error: count array overflow")); exit(1); } else { count = (int *)calloc(YYNTOKENS, sizeof(int)); if (count == NULL) { - gedcom_error("Internal error: count array calloc error"); + gedcom_error(_("Internal error: count array calloc error")); exit(1); } else { @@ -2600,7 +2596,7 @@ void pop_countarray() { int *count; if (count_level < 0) { - gedcom_error("Internal error: count array underflow"); + gedcom_error(_("Internal error: count array underflow")); exit(1); } else { @@ -2660,9 +2656,8 @@ void gedcom_set_compat_handling(int enable_compat) void set_compatibility(char* program) { if (compat_enabled) { - gedcom_debug_print("==== Program: %s\n", program); if (! strncmp(program, "ftree", 6)) { - gedcom_warning("Enabling compatibility with 'ftree'"); + gedcom_warning(_("Enabling compatibility with 'ftree'")); compatibility = C_FTREE; } else { diff --git a/gedcom/gedcom_lex_common.c b/gedcom/gedcom_lex_common.c index d528b02..93c26f3 100644 --- a/gedcom/gedcom_lex_common.c +++ b/gedcom/gedcom_lex_common.c @@ -97,7 +97,7 @@ int test_loop(ENCODING enc, char* code) { if (line_len != (size_t)-1) { \ line_len += strlen(yytext); \ if (line_len > MAXGEDCLINELEN * encoding_width) { \ - gedcom_error("Line too long, max %d characters", \ + gedcom_error(_("Line too long, max %d characters"), \ MAXGEDCLINELEN); \ line_len = (size_t)-1; \ return BADTOKEN; \ @@ -170,7 +170,7 @@ int test_loop(ENCODING enc, char* code) #define ACTION_0_DIGITS \ - { gedcom_error ("Level number with leading zero"); \ + { gedcom_error (_("Level number with leading zero")); \ return BADTOKEN; \ } @@ -179,7 +179,7 @@ int test_loop(ENCODING enc, char* code) { int level = atoi(TO_INTERNAL(yytext, str_buf)); \ CHECK_LINE_LEN; \ if ((level < 0) || (level > MAXGEDCLEVEL)) { \ - gedcom_error ("Level number out of range [0..%d]", \ + gedcom_error (_("Level number out of range [0..%d]"), \ MAXGEDCLEVEL); \ return BADTOKEN; \ } \ @@ -197,8 +197,7 @@ int test_loop(ENCODING enc, char* code) } \ else { \ /* should never happen (error to GEDCOM spec) */ \ - gedcom_error ("GEDCOM level number is %d higher than " \ - "previous", \ + gedcom_error (_("GEDCOM level number is %d higher than previous"), \ level_diff); \ return BADTOKEN; \ } \ @@ -207,7 +206,7 @@ int test_loop(ENCODING enc, char* code) #define ACTION_ALPHANUM \ { if (strlen(yytext) > MAXGEDCTAGLEN * encoding_width) { \ - gedcom_error("Tag '%s' too long, max %d characters", \ + gedcom_error(_("Tag '%s' too long, max %d characters"), \ yytext, MAXGEDCTAGLEN); \ return BADTOKEN; \ } \ @@ -249,7 +248,7 @@ int test_loop(ENCODING enc, char* code) #define ACTION_POINTER \ { CHECK_LINE_LEN; \ if (strlen(yytext) > MAXGEDCPTRLEN * encoding_width) { \ - gedcom_error("Pointer '%s' too long, max %d characters", \ + gedcom_error(_("Pointer '%s' too long, max %d characters"), \ yytext, MAXGEDCPTRLEN); \ return BADTOKEN; \ } \ @@ -293,7 +292,7 @@ int test_loop(ENCODING enc, char* code) #define ACTION_UNEXPECTED \ - { gedcom_error("Unexpected character: '%s' (0x%02x)", \ + { gedcom_error(_("Unexpected character: '%s' (0x%02x)"), \ yytext, yytext[0]); \ return BADTOKEN; \ } diff --git a/gedcom/message.c b/gedcom/message.c index f2f4130..49e91e5 100644 --- a/gedcom/message.c +++ b/gedcom/message.c @@ -106,7 +106,7 @@ int gedcom_warning(char* s, ...) va_list ap; reset_mess_buffer(); - safe_buf_append("Warning on line %d: ", line_no); + safe_buf_append(_("Warning on line %d: "), line_no); va_start(ap, s); res = safe_buf_vappend(s, ap); va_end(ap); @@ -123,7 +123,7 @@ int gedcom_error(char* s, ...) va_list ap; reset_mess_buffer(); - safe_buf_append("Error on line %d: ", line_no); + safe_buf_append(_("Error on line %d: "), line_no); va_start(ap, s); res = safe_buf_vappend(s, ap); va_end(ap); diff --git a/po/POTFILES.in b/po/POTFILES.in index e69de29..01e55be 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -0,0 +1,4 @@ +gedcom/encoding.c +gedcom/gedcom.y +gedcom/gedcom_lex_common.c +gedcom/multilex.c -- 2.30.2