From eb06da6a334bc37108cdce9bfc7f26cfcb2003ee Mon Sep 17 00:00:00 2001 From: John Darrington Date: Fri, 21 Feb 2014 10:06:00 +0100 Subject: [PATCH] Replace syntactical keywords in error/warning messages by printf directives. A number of translators are still making the mistake of translating syntax keywords in messages (such as "REPEAT") into thier literal equivalents in the target language. This change avoids the posibility of that mistake, by removing the keywords from the translatable string. --- src/data/file-name.c | 2 +- src/language/command.c | 11 ++++++----- src/language/control/do-if.c | 2 +- src/language/control/repeat.c | 2 +- src/language/data-io/data-list.c | 7 +++---- src/language/data-io/data-reader.c | 8 ++++---- src/language/data-io/get-data.c | 8 ++++---- src/language/data-io/inpt-pgm.c | 4 ++-- src/language/data-io/print-space.c | 6 +++--- src/language/data-io/print.c | 2 +- src/language/data-io/save-translate.c | 4 ++-- src/language/expressions/parse.c | 2 +- src/language/lexer/value-parser.c | 2 +- src/language/stats/factor.c | 6 ++++-- src/language/stats/flip.c | 24 ++++++++++++------------ src/language/stats/npar.c | 4 ++-- src/language/stats/rank.c | 4 ++-- src/language/stats/t-test-parser.c | 8 ++++---- src/language/utilities/date.c | 2 +- src/language/utilities/host.c | 2 +- src/language/utilities/permissions.c | 2 +- src/language/xforms/recode.c | 2 +- 22 files changed, 58 insertions(+), 56 deletions(-) diff --git a/src/data/file-name.c b/src/data/file-name.c index 9eeb4b1cfc..fa0eb79401 100644 --- a/src/data/file-name.c +++ b/src/data/file-name.c @@ -170,7 +170,7 @@ fn_getenv_default (const char *key, const char *def) static FILE * safety_violation (const char *fn) { - msg (SE, _("Not opening pipe file `%s' because SAFER option set."), fn); + msg (SE, _("Not opening pipe file `%s' because %s option set."), fn, "SAFER"); errno = EPERM; return NULL; } diff --git a/src/language/command.c b/src/language/command.c index 78fd5f00b0..7637703588 100644 --- a/src/language/command.c +++ b/src/language/command.c @@ -385,11 +385,11 @@ report_state_mismatch (const struct command *command, enum cmd_state state) "been defined."), command->name); break; case S_INPUT_PROGRAM: - msg (SE, _("%s is allowed only inside INPUT PROGRAM."), - command->name); + msg (SE, _("%s is allowed only inside %s."), + command->name, "INPUT PROGRAM"); break; case S_FILE_TYPE: - msg (SE, _("%s is allowed only inside FILE TYPE."), command->name); + msg (SE, _("%s is allowed only inside %s."), command->name, "FILE TYPE"); break; /* Two allowed states. */ @@ -412,7 +412,8 @@ report_state_mismatch (const struct command *command, enum cmd_state state) command->name, "FILE TYPE"); break; case S_INPUT_PROGRAM | S_FILE_TYPE: - msg (SE, _("%s is allowed only inside INPUT PROGRAM or inside FILE TYPE."), command->name); + msg (SE, _("%s is allowed only inside %s or inside %s."), command->name, + "INPUT PROGRAM", "FILE TYPE"); break; /* Three allowed states. */ @@ -525,7 +526,7 @@ cmd_erase (struct lexer *lexer, struct dataset *ds UNUSED) if (settings_get_safer_mode ()) { - msg (SE, _("This command not allowed when the SAFER option is set.")); + msg (SE, _("This command not allowed when the %s option is set."), "SAFER"); return CMD_FAILURE; } diff --git a/src/language/control/do-if.c b/src/language/control/do-if.c index a44f6e8189..6b6dc16d4d 100644 --- a/src/language/control/do-if.c +++ b/src/language/control/do-if.c @@ -174,7 +174,7 @@ must_not_have_else (struct do_if_trns *do_if) { if (has_else (do_if)) { - msg (SE, _("This command may not follow ELSE in DO IF...END IF.")); + msg (SE, _("This command may not follow %s in %s ... %s."), "ELSE", "DO IF", "END IF"); return false; } else diff --git a/src/language/control/repeat.c b/src/language/control/repeat.c index b2c2bb413e..c2e136cf41 100644 --- a/src/language/control/repeat.c +++ b/src/language/control/repeat.c @@ -439,6 +439,6 @@ parse_strings (struct lexer *lexer, struct dummy_var *dv) int cmd_end_repeat (struct lexer *lexer UNUSED, struct dataset *ds UNUSED) { - msg (SE, _("No matching DO REPEAT.")); + msg (SE, _("No matching %s."), "DO REPEAT"); return CMD_CASCADING_FAILURE; } diff --git a/src/language/data-io/data-list.c b/src/language/data-io/data-list.c index 834a2f8d7f..f68b2e1b4d 100644 --- a/src/language/data-io/data-list.c +++ b/src/language/data-io/data-list.c @@ -138,13 +138,12 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds) { if (!in_input_program ()) { - msg (SE, _("The END subcommand may only be used within " - "INPUT PROGRAM.")); + msg (SE, _("The %s subcommand may only be used within %s."), "END", "INPUT PROGRAM"); goto error; } if (end) { - msg (SE, _("The END subcommand may only be specified once.")); + msg (SE, _("The %s subcommand may only be specified once."), "END"); goto error; } @@ -252,7 +251,7 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds) if (type != DP_FIXED && end != NULL) { - msg (SE, _("The END subcommand may be used only with DATA LIST FIXED.")); + msg (SE, _("The %s subcommand may be used only with %s."), "END", "DATA LIST FIXED"); goto error; } diff --git a/src/language/data-io/data-reader.c b/src/language/data-io/data-reader.c index 14cb57d77a..c28fa0700e 100644 --- a/src/language/data-io/data-reader.c +++ b/src/language/data-io/data-reader.c @@ -236,11 +236,11 @@ read_inline_record (struct dfm_reader *r) { if (!lex_match_id (r->lexer, "END") || !lex_match_id (r->lexer, "DATA")) { - msg (SE, _("Missing END DATA while reading inline data. " + msg (SE, _("Missing %s while reading inline data. " "This probably indicates a missing or incorrectly " - "formatted END DATA command. END DATA must appear " + "formatted %s command. %s must appear " "by itself on a single line with exactly one space " - "between words.")); + "between words."), "END DATA", "END DATA", "END DATA"); lex_discard_rest_of_command (r->lexer); } return false; @@ -573,7 +573,7 @@ dfm_eof (struct dfm_reader *r) msg (ME, _("Attempt to read beyond end-of-file on file %s."), fh_get_name (r->fh)); else - msg (ME, _("Attempt to read beyond END DATA.")); + msg (ME, _("Attempt to read beyond %s."), "END DATA"); } } diff --git a/src/language/data-io/get-data.c b/src/language/data-io/get-data.c index 2738cb29f1..e6d5eac9f6 100644 --- a/src/language/data-io/get-data.c +++ b/src/language/data-io/get-data.c @@ -433,7 +433,7 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds) goto error; if (lex_integer (lexer) < 1) { - msg (SE, _("Value of FIRSTCASE must be 1 or greater.")); + msg (SE, _("Value of %s must be 1 or greater."), "FIRSTCASE"); goto error; } data_parser_set_skip (parser, lex_integer (lexer) - 1); @@ -471,7 +471,7 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds) goto error; if (lex_integer (lexer) < 1) { - msg (SE, _("Value of FIXCASE must be at least 1.")); + msg (SE, _("Value of %s must be 1 or greater."), "FIXCASE"); goto error; } data_parser_set_records (parser, lex_integer (lexer)); @@ -491,7 +491,7 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds) goto error; if (lex_integer (lexer) < 1) { - msg (SE, _("Value of FIRST must be at least 1.")); + msg (SE, _("Value of %s must be 1 or greater."), "FIRST"); goto error; } data_parser_set_case_limit (parser, lex_integer (lexer)); @@ -503,7 +503,7 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds) goto error; if (lex_integer (lexer) < 1 || lex_integer (lexer) > 100) { - msg (SE, _("Value of PERCENT must be between 1 and 100.")); + msg (SE, _("Value of %s must be between 1 and 100."), "PERCENT"); goto error; } data_parser_set_case_percent (parser, lex_integer (lexer)); diff --git a/src/language/data-io/inpt-pgm.c b/src/language/data-io/inpt-pgm.c index 0301d7d057..b9488f17f4 100644 --- a/src/language/data-io/inpt-pgm.c +++ b/src/language/data-io/inpt-pgm.c @@ -130,7 +130,7 @@ cmd_input_program (struct lexer *lexer, struct dataset *ds) && lex_get_error_mode (lexer) != LEX_ERROR_TERMINAL) { if (result == CMD_EOF) - msg (SE, _("Unexpected end-of-file within INPUT PROGRAM.")); + msg (SE, _("Unexpected end-of-file within %s."), "INPUT PROGRAM"); inside_input_program = false; destroy_input_program (inp); return result; @@ -143,7 +143,7 @@ cmd_input_program (struct lexer *lexer, struct dataset *ds) if (!saw_DATA_LIST && !saw_END_FILE) { - msg (SE, _("Input program must contain DATA LIST or END FILE.")); + msg (SE, _("Input program must contain %s or %s."), "DATA LIST", "END FILE"); destroy_input_program (inp); return CMD_FAILURE; } diff --git a/src/language/data-io/print-space.c b/src/language/data-io/print-space.c index adeb92ba5b..9f27da80f4 100644 --- a/src/language/data-io/print-space.c +++ b/src/language/data-io/print-space.c @@ -124,10 +124,10 @@ print_space_trns_proc (void *t_, struct ccase **c, { double f = expr_evaluate_num (trns->expr, *c, case_num); if (f == SYSMIS) - msg (SW, _("The expression on PRINT SPACE evaluated to the " - "system-missing value.")); + msg (SW, _("The expression on %s evaluated to the " + "system-missing value."), "PRINT SPACE"); else if (f < 0 || f > INT_MAX) - msg (SW, _("The expression on PRINT SPACE evaluated to %g."), f); + msg (SW, _("The expression on %s evaluated to %g."), "PRINT SPACE", f); else n = f; } diff --git a/src/language/data-io/print.c b/src/language/data-io/print.c index e2c5adc073..7781a317b6 100644 --- a/src/language/data-io/print.c +++ b/src/language/data-io/print.c @@ -220,7 +220,7 @@ internal_cmd_print (struct lexer *lexer, struct dataset *ds, } if (binary && fh == NULL) { - msg (SE, _("OUTFILE is required when binary formats are specified.")); + msg (SE, _("%s is required when binary formats are specified."), "OUTFILE"); goto error; } diff --git a/src/language/data-io/save-translate.c b/src/language/data-io/save-translate.c index 6601f30b18..54b769ddee 100644 --- a/src/language/data-io/save-translate.c +++ b/src/language/data-io/save-translate.c @@ -249,8 +249,8 @@ cmd_save_translate (struct lexer *lexer, struct dataset *ds) } else if (!replace && fn_exists (fh_get_file_name (handle))) { - msg (SE, _("Output file `%s' exists but REPLACE was not specified."), - fh_get_file_name (handle)); + msg (SE, _("Output file `%s' exists but %s was not specified."), + fh_get_file_name (handle), "REPLACE"); goto error; } diff --git a/src/language/expressions/parse.c b/src/language/expressions/parse.c index 7b845a8d36..b2c2cf8e2f 100644 --- a/src/language/expressions/parse.c +++ b/src/language/expressions/parse.c @@ -1298,7 +1298,7 @@ parse_function (struct lexer *lexer, struct expression *e) if ((f->flags & OPF_PERM_ONLY) && proc_in_temporary_transformations (e->ds)) { - msg (SE, _("%s may not appear after TEMPORARY."), f->prototype); + msg (SE, _("%s may not appear after %s."), f->prototype, "TEMPORARY"); goto fail; } diff --git a/src/language/lexer/value-parser.c b/src/language/lexer/value-parser.c index 65e34a348b..39f5eb68a9 100644 --- a/src/language/lexer/value-parser.c +++ b/src/language/lexer/value-parser.c @@ -79,7 +79,7 @@ parse_num_range (struct lexer *lexer, { if (*x == LOWEST) { - msg (SE, _("LO or LOWEST must be part of a range.")); + msg (SE, _("%s or %s must be part of a range."), "LO", "LOWEEST"); return false; } *y = *x; diff --git a/src/language/stats/factor.c b/src/language/stats/factor.c index fa9987332f..1ab2618dfe 100644 --- a/src/language/stats/factor.c +++ b/src/language/stats/factor.c @@ -1923,13 +1923,15 @@ do_factor (const struct cmd_factor *factor, struct casereader *r) if (idata->n_extractions == 0) { - msg (MW, _("The FACTOR criteria result in zero factors extracted. Therefore no analysis will be performed.")); + msg (MW, _("The %s criteria result in zero factors extracted. Therefore no analysis will be performed."), "FACTOR"); goto finish; } if (idata->n_extractions > factor->n_vars) { - msg (MW, _("The FACTOR criteria result in more factors than variables, which is not meaningful. No analysis will be performed.")); + msg (MW, + _("The %s criteria result in more factors than variables, which is not meaningful. No analysis will be performed."), + "FACTOR"); goto finish; } diff --git a/src/language/stats/flip.c b/src/language/stats/flip.c index e1ae9330dd..68152b1b19 100644 --- a/src/language/stats/flip.c +++ b/src/language/stats/flip.c @@ -97,8 +97,8 @@ cmd_flip (struct lexer *lexer, struct dataset *ds) bool ok; if (proc_make_temporary_transformations_permanent (ds)) - msg (SW, _("FLIP ignores TEMPORARY. " - "Temporary transformations will be made permanent.")); + msg (SW, _("%s ignores %s. " + "Temporary transformations will be made permanent."), "FLIP", "TEMPORARY"); flip = pool_create_container (struct flip_pgm, pool); flip->n_vars = 0; @@ -148,7 +148,7 @@ cmd_flip (struct lexer *lexer, struct dataset *ds) flip->file = pool_create_temp_file (flip->pool); if (flip->file == NULL) { - msg (SE, _("Could not create temporary file for FLIP.")); + msg (SE, _("Could not create temporary file for %s."), "FLIP"); goto error; } @@ -330,14 +330,14 @@ flip_file (struct flip_pgm *flip) input_file = flip->file; if (fseeko (input_file, 0, SEEK_SET) != 0) { - msg (SE, _("Error rewinding FLIP file: %s."), strerror (errno)); + msg (SE, _("Error rewinding %s file: %s."), "FLIP", strerror (errno)); return false; } output_file = pool_create_temp_file (flip->pool); if (output_file == NULL) { - msg (SE, _("Error creating FLIP source file.")); + msg (SE, _("Error creating %s source file."), "FLIP"); return false; } @@ -350,9 +350,9 @@ flip_file (struct flip_pgm *flip) if (read_cases != fread (input_buf, case_bytes, read_cases, input_file)) { if (ferror (input_file)) - msg (SE, _("Error reading FLIP file: %s."), strerror (errno)); + msg (SE, _("Error reading %s file: %s."), "FLIP", strerror (errno)); else - msg (SE, _("Unexpected end of file reading FLIP file.")); + msg (SE, _("Unexpected end of file reading %s file."), "FLIP"); return false; } @@ -368,7 +368,7 @@ flip_file (struct flip_pgm *flip) + (off_t) i * flip->n_cases), SEEK_SET) != 0) { - msg (SE, _("Error seeking FLIP source file: %s."), + msg (SE, _("Error seeking %s source file: %s."), "FLIP", strerror (errno)); return false; } @@ -376,7 +376,7 @@ flip_file (struct flip_pgm *flip) if (fwrite (output_buf, sizeof *output_buf, read_cases, output_file) != read_cases) { - msg (SE, _("Error writing FLIP source file: %s."), + msg (SE, _("Error writing %s source file: %s."), "FLIP", strerror (errno)); return false; } @@ -391,7 +391,7 @@ flip_file (struct flip_pgm *flip) if (fseeko (output_file, 0, SEEK_SET) != 0) { - msg (SE, _("Error rewinding FLIP source file: %s."), strerror (errno)); + msg (SE, _("Error rewinding %s source file: %s."), "FLIP", strerror (errno)); return false; } flip->file = output_file; @@ -422,10 +422,10 @@ flip_casereader_read (struct casereader *reader, void *flip_) { case_unref (c); if (ferror (flip->file)) - msg (SE, _("Error reading FLIP temporary file: %s."), + msg (SE, _("Error reading %s temporary file: %s."), "FLIP", strerror (errno)); else if (feof (flip->file)) - msg (SE, _("Unexpected end of file reading FLIP temporary file.")); + msg (SE, _("Unexpected end of file reading %s temporary file."), "FLIP"); else NOT_REACHED (); flip->error = true; diff --git a/src/language/stats/npar.c b/src/language/stats/npar.c index fbcdeae058..019e958cb2 100644 --- a/src/language/stats/npar.c +++ b/src/language/stats/npar.c @@ -534,7 +534,7 @@ npar_execute (struct casereader *input, const struct npar_test *test = specs->test[t]; if ( NULL == test->execute ) { - msg (SW, _("NPAR subcommand not currently implemented.")); + msg (SW, _("%s subcommand not currently implemented."), "NPAR"); continue; } test->execute (ds, casereader_clone (input), specs->filter, test, specs->exact, specs->timer); @@ -688,7 +688,7 @@ npar_runs (struct lexer *lexer, struct dataset *ds, } else { - lex_error (lexer, _("Expecting MEAN, MEDIAN, MODE or number")); + lex_error (lexer, _("Expecting %s, %s, %s or a number."), "MEAN", "MEDIAN", "MODE"); return 0; } diff --git a/src/language/stats/rank.c b/src/language/stats/rank.c index a29a3fd11f..5a849b8cf8 100644 --- a/src/language/stats/rank.c +++ b/src/language/stats/rank.c @@ -318,7 +318,7 @@ parse_into (struct lexer *lexer, struct rank *cmd, const char *name = lex_tokcstr (lexer); if ( var_count >= subcase_get_n_fields (&cmd->sc) ) - msg (SE, _("Too many variables in INTO clause.")); + msg (SE, _("Too many variables in %s clause."), "INTO"); else if ( dict_lookup_var (cmd->dict, name) != NULL ) msg (SE, _("Variable %s already exists."), name); else if (string_set_contains (new_names, name)) @@ -820,7 +820,7 @@ cmd_rank (struct lexer *lexer, struct dataset *ds) { int v; - tab_output_text (0, _("Variables Created By RANK")); + tab_output_text_format (0, _("Variables Created By %s"), "RANK"); tab_output_text (0, ""); for (i = 0 ; i < rank.n_rs ; ++i ) diff --git a/src/language/stats/t-test-parser.c b/src/language/stats/t-test-parser.c index 3ce1d028f9..9e134e2a72 100644 --- a/src/language/stats/t-test-parser.c +++ b/src/language/stats/t-test-parser.c @@ -120,8 +120,8 @@ cmd_t_test (struct lexer *lexer, struct dataset *ds) if ( cut == true && var_is_alpha (gvar)) { - msg (SE, _("When applying GROUPS to a string variable, two " - "values must be specified.")); + msg (SE, _("When applying %s to a string variable, two " + "values must be specified."), "GROUPS"); goto parse_failed; } } @@ -132,7 +132,7 @@ cmd_t_test (struct lexer *lexer, struct dataset *ds) if (tt.n_vars > 0) { - msg (SE, _("VARIABLES subcommand may not be used with PAIRS.")); + msg (SE, _("%s subcommand may not be used with %s."), "VARIABLES", "PAIRS"); goto parse_failed; } @@ -228,7 +228,7 @@ cmd_t_test (struct lexer *lexer, struct dataset *ds) { if ( tt.mode == MODE_PAIRED) { - msg (SE, _("VARIABLES subcommand may not be used with PAIRS.")); + msg (SE, _("%s subcommand may not be used with %s."), "VARIABLES", "PAIRS"); goto parse_failed; } diff --git a/src/language/utilities/date.c b/src/language/utilities/date.c index 3b754b4980..8afbe6562d 100644 --- a/src/language/utilities/date.c +++ b/src/language/utilities/date.c @@ -30,6 +30,6 @@ cmd_use (struct lexer *lexer, struct dataset *ds UNUSED) if (lex_match (lexer, T_ALL)) return CMD_SUCCESS; - msg (SW, _("Only USE ALL is currently implemented.")); + msg (SW, _("Only %s is currently implemented."), "USE ALL"); return CMD_FAILURE; } diff --git a/src/language/utilities/host.c b/src/language/utilities/host.c index fbc9d208be..b01e621bf1 100644 --- a/src/language/utilities/host.c +++ b/src/language/utilities/host.c @@ -127,7 +127,7 @@ cmd_host (struct lexer *lexer, struct dataset *ds UNUSED) { if (settings_get_safer_mode ()) { - msg (SE, _("This command not allowed when the SAFER option is set.")); + msg (SE, _("This command not allowed when the %s option is set."), "SAFER"); return CMD_FAILURE; } diff --git a/src/language/utilities/permissions.c b/src/language/utilities/permissions.c index 2ea91de1dc..a52cd198aa 100644 --- a/src/language/utilities/permissions.c +++ b/src/language/utilities/permissions.c @@ -102,7 +102,7 @@ change_permissions (const char *file_name, enum PER per) if (settings_get_safer_mode ()) { - msg (SE, _("This command not allowed when the SAFER option is set.")); + msg (SE, _("This command not allowed when the %s option is set."), "SAFER"); return 0; } diff --git a/src/language/xforms/recode.c b/src/language/xforms/recode.c index a1c2f7a449..275408de90 100644 --- a/src/language/xforms/recode.c +++ b/src/language/xforms/recode.c @@ -336,7 +336,7 @@ parse_map_in (struct lexer *lexer, struct map_in *in, struct pool *pool, if (lex_token (lexer) == T_ID && lex_id_match (ss_cstr ("THRU"), lex_tokss (lexer))) { - msg (SE, _("THRU is not allowed with string variables.")); + msg (SE, _("%s is not allowed with string variables."), "THRU"); return false; } } -- 2.30.2