builtin/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
1d28ff4ce6d767b0f16f6e2ed872d98abc40480f
2 files changed
+25
-25
builtin/config.c
+24
-24
@@ -110,7 +110,7 @@ static int option_parse_type(const struct option *opt, const char *arg,
110
* --int' and '--type=bool
111
* --type=int'.
112
*/
113
- error("only one type at a time");
113
+ error(_("only one type at a time"));
114
usage_with_options(builtin_config_usage,
115
builtin_config_options);
116
}
@@ -161,9 +161,9 @@ static void check_argc(int argc, int min, int max) {
161
if (argc >= min && argc <= max)
162
return;
163
if (min == max)
164
- error("wrong number of arguments, should be %d", min);
164
+ error(_("wrong number of arguments, should be %d"), min);
165
else
166
- error("wrong number of arguments, should be from %d to %d",
166
+ error(_("wrong number of arguments, should be from %d to %d"),
167
min, max);
168
usage_with_options(builtin_config_usage, builtin_config_options);
169
}
@@ -297,7 +297,7 @@ static int get_value(const char *key_, const char *regex_)
297
298
key_regexp = (regex_t*)xmalloc(sizeof(regex_t));
299
if (regcomp(key_regexp, key, REG_EXTENDED)) {
300
- error("invalid key pattern: %s", key_);
300
+ error(_("invalid key pattern: %s"), key_);
301
FREE_AND_NULL(key_regexp);
302
ret = CONFIG_INVALID_PATTERN;
303
goto free_strings;
@@ -317,7 +317,7 @@ static int get_value(const char *key_, const char *regex_)
317
318
regexp = (regex_t*)xmalloc(sizeof(regex_t));
319
if (regcomp(regexp, regex_, REG_EXTENDED)) {
320
- error("invalid pattern: %s", regex_);
320
+ error(_("invalid pattern: %s"), regex_);
321
FREE_AND_NULL(regexp);
322
ret = CONFIG_INVALID_PATTERN;
323
goto free_strings;
@@ -390,7 +390,7 @@ static char *normalize_value(const char *key, const char *value)
390
if (type == TYPE_COLOR) {
391
char v[COLOR_MAXLEN];
392
if (git_config_color(v, key, value))
393
- die("cannot parse color '%s'", value);
393
+ die(_("cannot parse color '%s'"), value);
394
395
/*
396
* The contents of `v` now contain an ANSI escape
@@ -485,13 +485,13 @@ static int get_colorbool(const char *var, int print)
485
static void check_write(void)
486
{
487
if (!given_config_source.file && !startup_info->have_repository)
488
- die("not in a git directory");
488
+ die(_("not in a git directory"));
489
490
if (given_config_source.use_stdin)
491
- die("writing to stdin is not supported");
491
+ die(_("writing to stdin is not supported"));
492
493
if (given_config_source.blob)
494
- die("writing config blobs is not supported");
494
+ die(_("writing config blobs is not supported"));
495
}
496
497
struct urlmatch_current_candidate_value {
@@ -599,7 +599,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
599
600
if (use_global_config + use_system_config + use_local_config +
601
!!given_config_source.file + !!given_config_source.blob > 1) {
602
- error("only one config file at a time");
602
+ error(_("only one config file at a time"));
603
usage_with_options(builtin_config_usage, builtin_config_options);
604
}
605
@@ -626,7 +626,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
626
* location; error out even if XDG_CONFIG_HOME
627
* is set and points at a sane location.
628
*/
629
- die("$HOME not set");
629
+ die(_("$HOME not set"));
630
631
if (access_or_warn(user_config, R_OK, 0) &&
632
xdg_config && !access_or_warn(xdg_config, R_OK, 0)) {
@@ -663,12 +663,12 @@ int cmd_config(int argc, const char **argv, const char *prefix)
663
}
664
665
if ((actions & (ACTION_GET_COLOR|ACTION_GET_COLORBOOL)) && type) {
666
- error("--get-color and variable type are incoherent");
666
+ error(_("--get-color and variable type are incoherent"));
667
usage_with_options(builtin_config_usage, builtin_config_options);
668
}
669
670
if (HAS_MULTI_BITS(actions)) {
671
- error("only one action at a time");
671
+ error(_("only one action at a time"));
672
usage_with_options(builtin_config_usage, builtin_config_options);
673
}
674
if (actions == 0)
@@ -681,19 +681,19 @@ int cmd_config(int argc, const char **argv, const char *prefix)
681
}
682
if (omit_values &&
683
!(actions == ACTION_LIST || actions == ACTION_GET_REGEXP)) {
684
- error("--name-only is only applicable to --list or --get-regexp");
684
+ error(_("--name-only is only applicable to --list or --get-regexp"));
685
usage_with_options(builtin_config_usage, builtin_config_options);
686
}
687
688
if (show_origin && !(actions &
689
(ACTION_GET|ACTION_GET_ALL|ACTION_GET_REGEXP|ACTION_LIST))) {
690
- error("--show-origin is only applicable to --get, --get-all, "
691
- "--get-regexp, and --list");
690
+ error(_("--show-origin is only applicable to --get, --get-all, "
691
+ "--get-regexp, and --list"));
692
usage_with_options(builtin_config_usage, builtin_config_options);
693
}
694
695
if (default_value && !(actions & ACTION_GET)) {
696
- error("--default is only applicable to --get");
696
+ error(_("--default is only applicable to --get"));
697
usage_with_options(builtin_config_usage,
698
builtin_config_options);
699
}
@@ -707,10 +707,10 @@ int cmd_config(int argc, const char **argv, const char *prefix)
707
&given_config_source,
708
&config_options) < 0) {
709
if (given_config_source.file)
710
- die_errno("unable to read config file '%s'",
710
+ die_errno(_("unable to read config file '%s'"),
711
given_config_source.file);
712
else
713
- die("error processing config file(s)");
713
+ die(_("error processing config file(s)"));
714
}
715
}
716
else if (actions == ACTION_EDIT) {
@@ -718,11 +718,11 @@ int cmd_config(int argc, const char **argv, const char *prefix)
718
719
check_argc(argc, 0, 0);
720
if (!given_config_source.file && nongit)
721
- die("not in a git directory");
721
+ die(_("not in a git directory"));
722
if (given_config_source.use_stdin)
723
- die("editing stdin is not supported");
723
+ die(_("editing stdin is not supported"));
724
if (given_config_source.blob)
725
- die("editing blobs is not supported");
725
+ die(_("editing blobs is not supported"));
726
git_config(git_default_config, NULL);
727
config_file = given_config_source.file ?
728
xstrdup(given_config_source.file) :
@@ -823,7 +823,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
823
if (ret < 0)
824
return ret;
825
if (ret == 0)
826
- die("no such section: %s", argv[0]);
826
+ die(_("no such section: %s"), argv[0]);
827
}
828
else if (actions == ACTION_REMOVE_SECTION) {
829
int ret;
@@ -834,7 +834,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
834
if (ret < 0)
835
return ret;
836
if (ret == 0)
837
- die("no such section: %s", argv[0]);
837
+ die(_("no such section: %s"), argv[0]);
838
}
839
else if (actions == ACTION_GET_COLOR) {
840
check_argc(argc, 1, 2);
t/t1308-config-set.sh
+1
-1
@@ -233,7 +233,7 @@ test_expect_success 'check line errors for malformed values' '
233
234
test_expect_success 'error on modifying repo config without repo' '
235
nongit test_must_fail git config a.b c 2>err &&
236
- grep "not in a git directory" err
236
+ test_i18ngrep "not in a git directory" err
237
'
238
239
cmdline_config="'foo.bar=from-cmdline'"