config.c: mark more strings for translation

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Jul 21, 2018 at 09:49 UTC a769bfc74f72ed9242d4f3942c5d22f5cb693641
2 files changed +37 -37
config.c
+36 -36
@@ -116,12 +116,12 @@ static long config_buf_ftell(struct config_source *conf)
116 }
117
118 #define MAX_INCLUDE_DEPTH 10
119 -static const char include_depth_advice[] =
119 +static const char include_depth_advice[] = N_(
120 "exceeded maximum include depth (%d) while including\n"
121 " %s\n"
122 "from\n"
123 " %s\n"
124 -"Do you have circular includes?";
124 +"Do you have circular includes?");
125 static int handle_path_include(const char *path, struct config_include_data *inc)
126 {
127 int ret = 0;
@@ -133,7 +133,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
133
134 expanded = expand_user_path(path, 0);
135 if (!expanded)
136 - return error("could not expand include path '%s'", path);
136 + return error(_("could not expand include path '%s'"), path);
137 path = expanded;
138
139 /*
@@ -144,7 +144,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
144 char *slash;
145
146 if (!cf || !cf->path)
147 - return error("relative config includes must come from files");
147 + return error(_("relative config includes must come from files"));
148
149 slash = find_last_dir_sep(cf->path);
150 if (slash)
@@ -155,7 +155,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
155
156 if (!access_or_die(path, R_OK, 0)) {
157 if (++inc->depth > MAX_INCLUDE_DEPTH)
158 - die(include_depth_advice, MAX_INCLUDE_DEPTH, path,
158 + die(_(include_depth_advice), MAX_INCLUDE_DEPTH, path,
159 !cf ? "<unknown>" :
160 cf->name ? cf->name :
161 "the command line");
@@ -342,13 +342,13 @@ static int git_config_parse_key_1(const char *key, char **store_key, int *basele
342
343 if (last_dot == NULL || last_dot == key) {
344 if (!quiet)
345 - error("key does not contain a section: %s", key);
345 + error(_("key does not contain a section: %s"), key);
346 return -CONFIG_NO_SECTION_OR_NAME;
347 }
348
349 if (!last_dot[1]) {
350 if (!quiet)
351 - error("key does not contain variable name: %s", key);
351 + error(_("key does not contain variable name: %s"), key);
352 return -CONFIG_NO_SECTION_OR_NAME;
353 }
354
@@ -372,13 +372,13 @@ static int git_config_parse_key_1(const char *key, char **store_key, int *basele
372 if (!iskeychar(c) ||
373 (i == baselen + 1 && !isalpha(c))) {
374 if (!quiet)
375 - error("invalid key: %s", key);
375 + error(_("invalid key: %s"), key);
376 goto out_free_ret_1;
377 }
378 c = tolower(c);
379 } else if (c == '\n') {
380 if (!quiet)
381 - error("invalid key (newline): %s", key);
381 + error(_("invalid key (newline): %s"), key);
382 goto out_free_ret_1;
383 }
384 if (store_key)
@@ -414,7 +414,7 @@ int git_config_parse_parameter(const char *text,
414
415 pair = strbuf_split_str(text, '=', 2);
416 if (!pair[0])
417 - return error("bogus config parameter: %s", text);
417 + return error(_("bogus config parameter: %s"), text);
418
419 if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=') {
420 strbuf_setlen(pair[0], pair[0]->len - 1);
@@ -426,7 +426,7 @@ int git_config_parse_parameter(const char *text,
426 strbuf_trim(pair[0]);
427 if (!pair[0]->len) {
428 strbuf_list_free(pair);
429 - return error("bogus config parameter: %s", text);
429 + return error(_("bogus config parameter: %s"), text);
430 }
431
432 if (git_config_parse_key(pair[0]->buf, &canonical_name, NULL)) {
@@ -461,7 +461,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)
461 envw = xstrdup(env);
462
463 if (sq_dequote_to_argv(envw, &argv, &nr, &alloc) < 0) {
464 - ret = error("bogus format in %s", CONFIG_DATA_ENVIRONMENT);
464 + ret = error(_("bogus format in %s"), CONFIG_DATA_ENVIRONMENT);
465 goto out;
466 }
467
@@ -1154,7 +1154,7 @@ static int git_default_core_config(const char *var, const char *value)
1154 else {
1155 int abbrev = git_config_int(var, value);
1156 if (abbrev < minimum_abbrev || abbrev > 40)
1157 - return error("abbrev length out of range: %d", abbrev);
1157 + return error(_("abbrev length out of range: %d"), abbrev);
1158 default_abbrev = abbrev;
1159 }
1160 return 0;
@@ -1271,7 +1271,7 @@ static int git_default_core_config(const char *var, const char *value)
1271 comment_line_char = value[0];
1272 auto_comment_line_char = 0;
1273 } else
1274 - return error("core.commentChar should only be one character");
1274 + return error(_("core.commentChar should only be one character"));
1275 return 0;
1276 }
1277
@@ -1384,7 +1384,7 @@ static int git_default_branch_config(const char *var, const char *value)
1384 else if (!strcmp(value, "always"))
1385 autorebase = AUTOREBASE_ALWAYS;
1386 else
1387 - return error("malformed value for %s", var);
1387 + return error(_("malformed value for %s"), var);
1388 return 0;
1389 }
1390
@@ -1410,9 +1410,9 @@ static int git_default_push_config(const char *var, const char *value)
1410 else if (!strcmp(value, "current"))
1411 push_default = PUSH_DEFAULT_CURRENT;
1412 else {
1413 - error("malformed value for %s: %s", var, value);
1414 - return error("must be one of nothing, matching, simple, "
1415 - "upstream or current");
1413 + error(_("malformed value for %s: %s"), var, value);
1414 + return error(_("must be one of nothing, matching, simple, "
1415 + "upstream or current"));
1416 }
1417 return 0;
1418 }
@@ -1589,10 +1589,10 @@ int git_config_from_blob_oid(config_fn_t fn,
1589
1590 buf = read_object_file(oid, &type, &size);
1591 if (!buf)
1592 - return error("unable to load config blob object '%s'", name);
1592 + return error(_("unable to load config blob object '%s'"), name);
1593 if (type != OBJ_BLOB) {
1594 free(buf);
1595 - return error("reference '%s' does not point to a blob", name);
1595 + return error(_("reference '%s' does not point to a blob"), name);
1596 }
1597
1598 ret = git_config_from_mem(fn, CONFIG_ORIGIN_BLOB, name, buf, size, data);
@@ -1608,7 +1608,7 @@ static int git_config_from_blob_ref(config_fn_t fn,
1608 struct object_id oid;
1609
1610 if (get_oid(name, &oid) < 0)
1611 - return error("unable to resolve config blob '%s'", name);
1611 + return error(_("unable to resolve config blob '%s'"), name);
1612 return git_config_from_blob_oid(fn, name, &oid, data);
1613 }
1614
@@ -1638,7 +1638,7 @@ unsigned long git_env_ulong(const char *k, unsigned long val)
1638 {
1639 const char *v = getenv(k);
1640 if (v && !git_parse_ulong(v, &val))
1641 - die("failed to parse %s", k);
1641 + die(_("failed to parse %s"), k);
1642 return val;
1643 }
1644
@@ -2372,7 +2372,7 @@ static int store_aux_event(enum config_event_t type,
2372
2373 if (type == CONFIG_EVENT_SECTION) {
2374 if (cf->var.len < 2 || cf->var.buf[cf->var.len - 1] != '.')
2375 - return error("invalid section name '%s'", cf->var.buf);
2375 + return error(_("invalid section name '%s'"), cf->var.buf);
2376
2377 /* Is this the section we were looking for? */
2378 store->is_keys_section =
@@ -2428,7 +2428,7 @@ static int store_aux(const char *key, const char *value, void *cb)
2428
2429 static int write_error(const char *filename)
2430 {
2431 - error("failed to write new configuration file %s", filename);
2431 + error(_("failed to write new configuration file %s"), filename);
2432
2433 /* Same error code as "failed to rename". */
2434 return 4;
@@ -2679,7 +2679,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2679 */
2680 fd = hold_lock_file_for_update(&lock, config_filename, 0);
2681 if (fd < 0) {
2682 - error_errno("could not lock config file %s", config_filename);
2682 + error_errno(_("could not lock config file %s"), config_filename);
2683 ret = CONFIG_NO_LOCK;
2684 goto out_free;
2685 }
@@ -2690,7 +2690,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2690 in_fd = open(config_filename, O_RDONLY);
2691 if ( in_fd < 0 ) {
2692 if ( ENOENT != errno ) {
2693 - error_errno("opening %s", config_filename);
2693 + error_errno(_("opening %s"), config_filename);
2694 ret = CONFIG_INVALID_FILE; /* same as "invalid config file" */
2695 goto out_free;
2696 }
@@ -2725,7 +2725,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2725 store.value_regex = (regex_t*)xmalloc(sizeof(regex_t));
2726 if (regcomp(store.value_regex, value_regex,
2727 REG_EXTENDED)) {
2728 - error("invalid pattern: %s", value_regex);
2728 + error(_("invalid pattern: %s"), value_regex);
2729 FREE_AND_NULL(store.value_regex);
2730 ret = CONFIG_INVALID_PATTERN;
2731 goto out_free;
@@ -2750,7 +2750,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2750 if (git_config_from_file_with_options(store_aux,
2751 config_filename,
2752 &store, &opts)) {
2753 - error("invalid config file %s", config_filename);
2753 + error(_("invalid config file %s"), config_filename);
2754 ret = CONFIG_INVALID_FILE;
2755 goto out_free;
2756 }
@@ -2774,7 +2774,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2774 if (contents == MAP_FAILED) {
2775 if (errno == ENODEV && S_ISDIR(st.st_mode))
2776 errno = EISDIR;
2777 - error_errno("unable to mmap '%s'", config_filename);
2777 + error_errno(_("unable to mmap '%s'"), config_filename);
2778 ret = CONFIG_INVALID_FILE;
2779 contents = NULL;
2780 goto out_free;
@@ -2783,7 +2783,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2783 in_fd = -1;
2784
2785 if (chmod(get_lock_file_path(&lock), st.st_mode & 07777) < 0) {
2786 - error_errno("chmod on %s failed", get_lock_file_path(&lock));
2786 + error_errno(_("chmod on %s failed"), get_lock_file_path(&lock));
2787 ret = CONFIG_NO_WRITE;
2788 goto out_free;
2789 }
@@ -2868,7 +2868,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2868 }
2869
2870 if (commit_lock_file(&lock) < 0) {
2871 - error_errno("could not write config file %s", config_filename);
2871 + error_errno(_("could not write config file %s"), config_filename);
2872 ret = CONFIG_NO_WRITE;
2873 goto out_free;
2874 }
@@ -2994,7 +2994,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
2994 memset(&store, 0, sizeof(store));
2995
2996 if (new_name && !section_name_is_ok(new_name)) {
2997 - ret = error("invalid section name: %s", new_name);
2997 + ret = error(_("invalid section name: %s"), new_name);
2998 goto out_no_rollback;
2999 }
3000
@@ -3003,7 +3003,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
3003
3004 out_fd = hold_lock_file_for_update(&lock, config_filename, 0);
3005 if (out_fd < 0) {
3006 - ret = error("could not lock config file %s", config_filename);
3006 + ret = error(_("could not lock config file %s"), config_filename);
3007 goto out;
3008 }
3009
@@ -3021,7 +3021,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
3021 }
3022
3023 if (chmod(get_lock_file_path(&lock), st.st_mode & 07777) < 0) {
3024 - ret = error_errno("chmod on %s failed",
3024 + ret = error_errno(_("chmod on %s failed"),
3025 get_lock_file_path(&lock));
3026 goto out;
3027 }
@@ -3118,7 +3118,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
3118 config_file = NULL;
3119 commit_and_out:
3120 if (commit_lock_file(&lock) < 0)
3121 - ret = error_errno("could not write config file %s",
3121 + ret = error_errno(_("could not write config file %s"),
3122 config_filename);
3123 out:
3124 if (config_file)
@@ -3161,7 +3161,7 @@ int git_config_copy_section(const char *old_name, const char *new_name)
3161 #undef config_error_nonbool
3162 int config_error_nonbool(const char *var)
3163 {
3164 - return error("missing value for '%s'", var);
3164 + return error(_("missing value for '%s'"), var);
3165 }
3166
3167 int parse_config_key(const char *var,
t/t1305-config-include.sh
+1 -1
@@ -310,7 +310,7 @@ test_expect_success 'include cycles are detected' '
310 cycle
311 EOF
312 test_must_fail git config --get-all test.value 2>stderr &&
313 - grep "exceeded maximum include depth" stderr
313 + test_i18ngrep "exceeded maximum include depth" stderr
314 '
315
316 test_done