Skip to content

Commit 1d28ff4

Browse files
pcloudsgitster
authored andcommitted
builtin/config.c: mark more strings for translation
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 02f3fe5 commit 1d28ff4

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

builtin/config.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static int option_parse_type(const struct option *opt, const char *arg,
110110
* --int' and '--type=bool
111111
* --type=int'.
112112
*/
113-
error("only one type at a time");
113+
error(_("only one type at a time"));
114114
usage_with_options(builtin_config_usage,
115115
builtin_config_options);
116116
}
@@ -161,9 +161,9 @@ static void check_argc(int argc, int min, int max) {
161161
if (argc >= min && argc <= max)
162162
return;
163163
if (min == max)
164-
error("wrong number of arguments, should be %d", min);
164+
error(_("wrong number of arguments, should be %d"), min);
165165
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"),
167167
min, max);
168168
usage_with_options(builtin_config_usage, builtin_config_options);
169169
}
@@ -297,7 +297,7 @@ static int get_value(const char *key_, const char *regex_)
297297

298298
key_regexp = (regex_t*)xmalloc(sizeof(regex_t));
299299
if (regcomp(key_regexp, key, REG_EXTENDED)) {
300-
error("invalid key pattern: %s", key_);
300+
error(_("invalid key pattern: %s"), key_);
301301
FREE_AND_NULL(key_regexp);
302302
ret = CONFIG_INVALID_PATTERN;
303303
goto free_strings;
@@ -317,7 +317,7 @@ static int get_value(const char *key_, const char *regex_)
317317

318318
regexp = (regex_t*)xmalloc(sizeof(regex_t));
319319
if (regcomp(regexp, regex_, REG_EXTENDED)) {
320-
error("invalid pattern: %s", regex_);
320+
error(_("invalid pattern: %s"), regex_);
321321
FREE_AND_NULL(regexp);
322322
ret = CONFIG_INVALID_PATTERN;
323323
goto free_strings;
@@ -390,7 +390,7 @@ static char *normalize_value(const char *key, const char *value)
390390
if (type == TYPE_COLOR) {
391391
char v[COLOR_MAXLEN];
392392
if (git_config_color(v, key, value))
393-
die("cannot parse color '%s'", value);
393+
die(_("cannot parse color '%s'"), value);
394394

395395
/*
396396
* The contents of `v` now contain an ANSI escape
@@ -485,13 +485,13 @@ static int get_colorbool(const char *var, int print)
485485
static void check_write(void)
486486
{
487487
if (!given_config_source.file && !startup_info->have_repository)
488-
die("not in a git directory");
488+
die(_("not in a git directory"));
489489

490490
if (given_config_source.use_stdin)
491-
die("writing to stdin is not supported");
491+
die(_("writing to stdin is not supported"));
492492

493493
if (given_config_source.blob)
494-
die("writing config blobs is not supported");
494+
die(_("writing config blobs is not supported"));
495495
}
496496

497497
struct urlmatch_current_candidate_value {
@@ -599,7 +599,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
599599

600600
if (use_global_config + use_system_config + use_local_config +
601601
!!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"));
603603
usage_with_options(builtin_config_usage, builtin_config_options);
604604
}
605605

@@ -626,7 +626,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
626626
* location; error out even if XDG_CONFIG_HOME
627627
* is set and points at a sane location.
628628
*/
629-
die("$HOME not set");
629+
die(_("$HOME not set"));
630630

631631
if (access_or_warn(user_config, R_OK, 0) &&
632632
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)
663663
}
664664

665665
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"));
667667
usage_with_options(builtin_config_usage, builtin_config_options);
668668
}
669669

670670
if (HAS_MULTI_BITS(actions)) {
671-
error("only one action at a time");
671+
error(_("only one action at a time"));
672672
usage_with_options(builtin_config_usage, builtin_config_options);
673673
}
674674
if (actions == 0)
@@ -681,19 +681,19 @@ int cmd_config(int argc, const char **argv, const char *prefix)
681681
}
682682
if (omit_values &&
683683
!(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"));
685685
usage_with_options(builtin_config_usage, builtin_config_options);
686686
}
687687

688688
if (show_origin && !(actions &
689689
(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"));
692692
usage_with_options(builtin_config_usage, builtin_config_options);
693693
}
694694

695695
if (default_value && !(actions & ACTION_GET)) {
696-
error("--default is only applicable to --get");
696+
error(_("--default is only applicable to --get"));
697697
usage_with_options(builtin_config_usage,
698698
builtin_config_options);
699699
}
@@ -707,22 +707,22 @@ int cmd_config(int argc, const char **argv, const char *prefix)
707707
&given_config_source,
708708
&config_options) < 0) {
709709
if (given_config_source.file)
710-
die_errno("unable to read config file '%s'",
710+
die_errno(_("unable to read config file '%s'"),
711711
given_config_source.file);
712712
else
713-
die("error processing config file(s)");
713+
die(_("error processing config file(s)"));
714714
}
715715
}
716716
else if (actions == ACTION_EDIT) {
717717
char *config_file;
718718

719719
check_argc(argc, 0, 0);
720720
if (!given_config_source.file && nongit)
721-
die("not in a git directory");
721+
die(_("not in a git directory"));
722722
if (given_config_source.use_stdin)
723-
die("editing stdin is not supported");
723+
die(_("editing stdin is not supported"));
724724
if (given_config_source.blob)
725-
die("editing blobs is not supported");
725+
die(_("editing blobs is not supported"));
726726
git_config(git_default_config, NULL);
727727
config_file = given_config_source.file ?
728728
xstrdup(given_config_source.file) :
@@ -823,7 +823,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
823823
if (ret < 0)
824824
return ret;
825825
if (ret == 0)
826-
die("no such section: %s", argv[0]);
826+
die(_("no such section: %s"), argv[0]);
827827
}
828828
else if (actions == ACTION_REMOVE_SECTION) {
829829
int ret;
@@ -834,7 +834,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
834834
if (ret < 0)
835835
return ret;
836836
if (ret == 0)
837-
die("no such section: %s", argv[0]);
837+
die(_("no such section: %s"), argv[0]);
838838
}
839839
else if (actions == ACTION_GET_COLOR) {
840840
check_argc(argc, 1, 2);

t/t1308-config-set.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ test_expect_success 'check line errors for malformed values' '
233233

234234
test_expect_success 'error on modifying repo config without repo' '
235235
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
237237
'
238238

239239
cmdline_config="'foo.bar=from-cmdline'"

0 commit comments

Comments
 (0)