Mark messages for translations
Small changes in messages to fit the style and typography of rest. Reuse already translated messages if possible. Do not translate messages aimed at developers of git. Fix unit tests depending on the original string. Use `test_i18ngrep` for tests with translatable strings. Change and verify rest of tests via `make GETTEXT_POISON=1 test`. Signed-off-by: Alexander Shopov <ash@kambanaria.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alexander Shopov committed
Feb 13, 2018 at 14:19 UTC
fc045fe7d4fa220f19274715c936636fe0516ea3
5 files changed
+54
-54
git.c
+19
-19
@@ -5,11 +5,11 @@
5
#include "run-command.h"
6
7
const char git_usage_string[] =
8
- "git [--version] [--help] [-C <path>] [-c name=value]\n"
9
- " [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
10
- " [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]\n"
11
- " [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
12
- " <command> [<args>]";
8
+ N_("git [--version] [--help] [-C <path>] [-c <name>=<value>]\n"
9
+ " [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
10
+ " [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]\n"
11
+ " [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
12
+ " <command> [<args>]");
13
14
const char git_more_info_string[] =
15
N_("'git help -a' and 'git help -g' list available subcommands and some\n"
@@ -92,7 +92,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
92
*envchanged = 1;
93
} else if (!strcmp(cmd, "--git-dir")) {
94
if (*argc < 2) {
95
- fprintf(stderr, "No directory given for --git-dir.\n" );
95
+ fprintf(stderr, _("no directory given for --git-dir\n" ));
96
usage(git_usage_string);
97
}
98
setenv(GIT_DIR_ENVIRONMENT, (*argv)[1], 1);
@@ -106,7 +106,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
106
*envchanged = 1;
107
} else if (!strcmp(cmd, "--namespace")) {
108
if (*argc < 2) {
109
- fprintf(stderr, "No namespace given for --namespace.\n" );
109
+ fprintf(stderr, _("no namespace given for --namespace\n" ));
110
usage(git_usage_string);
111
}
112
setenv(GIT_NAMESPACE_ENVIRONMENT, (*argv)[1], 1);
@@ -120,7 +120,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
120
*envchanged = 1;
121
} else if (!strcmp(cmd, "--work-tree")) {
122
if (*argc < 2) {
123
- fprintf(stderr, "No directory given for --work-tree.\n" );
123
+ fprintf(stderr, _("no directory given for --work-tree\n" ));
124
usage(git_usage_string);
125
}
126
setenv(GIT_WORK_TREE_ENVIRONMENT, (*argv)[1], 1);
@@ -134,7 +134,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
134
*envchanged = 1;
135
} else if (!strcmp(cmd, "--super-prefix")) {
136
if (*argc < 2) {
137
- fprintf(stderr, "No prefix given for --super-prefix.\n" );
137
+ fprintf(stderr, _("no prefix given for --super-prefix\n" ));
138
usage(git_usage_string);
139
}
140
setenv(GIT_SUPER_PREFIX_ENVIRONMENT, (*argv)[1], 1);
@@ -156,7 +156,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
156
*envchanged = 1;
157
} else if (!strcmp(cmd, "-c")) {
158
if (*argc < 2) {
159
- fprintf(stderr, "-c expects a configuration string\n" );
159
+ fprintf(stderr, _("-c expects a configuration string\n" ));
160
usage(git_usage_string);
161
}
162
git_config_push_parameter((*argv)[1]);
@@ -194,12 +194,12 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
194
*envchanged = 1;
195
} else if (!strcmp(cmd, "-C")) {
196
if (*argc < 2) {
197
- fprintf(stderr, "No directory given for -C.\n" );
197
+ fprintf(stderr, _("no directory given for -C\n" ));
198
usage(git_usage_string);
199
}
200
if ((*argv)[1][0]) {
201
if (chdir((*argv)[1]))
202
- die_errno("Cannot change to '%s'", (*argv)[1]);
202
+ die_errno("cannot change to '%s'", (*argv)[1]);
203
if (envchanged)
204
*envchanged = 1;
205
}
@@ -209,7 +209,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
209
list_builtins();
210
exit(0);
211
} else {
212
- fprintf(stderr, "Unknown option: %s\n", cmd);
212
+ fprintf(stderr, _("unknown option: %s\n"), cmd);
213
usage(git_usage_string);
214
}
215
@@ -247,7 +247,7 @@ static int handle_alias(int *argcp, const char ***argv)
247
if (ret >= 0) /* normal exit */
248
exit(ret);
249
250
- die_errno("While expanding alias '%s': '%s'",
250
+ die_errno("while expanding alias '%s': '%s'",
251
alias_command, alias_string + 1);
252
}
253
count = split_cmdline(alias_string, &new_argv);
@@ -256,8 +256,8 @@ static int handle_alias(int *argcp, const char ***argv)
256
split_cmdline_strerror(count));
257
option_count = handle_options(&new_argv, &count, &envchanged);
258
if (envchanged)
259
- die("alias '%s' changes environment variables\n"
260
- "You can use '!git' in the alias to do this.",
259
+ die("alias '%s' changes environment variables.\n"
260
+ "You can use '!git' in the alias to do this",
261
alias_command);
262
memmove(new_argv - option_count, new_argv,
263
count * sizeof(char *));
@@ -684,8 +684,8 @@ int cmd_main(int argc, const char **argv)
684
if (errno != ENOENT)
685
break;
686
if (was_alias) {
687
- fprintf(stderr, "Expansion of alias '%s' failed; "
688
- "'%s' is not a git command\n",
687
+ fprintf(stderr, _("expansion of alias '%s' failed; "
688
+ "'%s' is not a git command\n"),
689
cmd, argv[0]);
690
exit(1);
691
}
@@ -696,7 +696,7 @@ int cmd_main(int argc, const char **argv)
696
break;
697
}
698
699
- fprintf(stderr, "Failed to run command '%s': %s\n",
699
+ fprintf(stderr, _("failed to run command '%s': %s\n"),
700
cmd, strerror(errno));
701
702
return 1;
setup.c
+31
-31
@@ -119,7 +119,7 @@ char *prefix_path(const char *prefix, int len, const char *path)
119
{
120
char *r = prefix_path_gently(prefix, len, NULL, path);
121
if (!r)
122
- die("'%s' is outside repository", path);
122
+ die(_("'%s' is outside repository"), path);
123
return r;
124
}
125
@@ -160,7 +160,7 @@ int check_filename(const char *prefix, const char *arg)
160
free(to_free);
161
return 0; /* file does not exist */
162
}
163
- die_errno("failed to stat '%s'", arg);
163
+ die_errno(_("failed to stat '%s'"), arg);
164
}
165
166
static void NORETURN die_verify_filename(const char *prefix,
@@ -230,7 +230,7 @@ void verify_filename(const char *prefix,
230
int diagnose_misspelt_rev)
231
{
232
if (*arg == '-')
233
- die("option '%s' must come before non-option arguments", arg);
233
+ die(_("option '%s' must come before non-option arguments"), arg);
234
if (looks_like_pathspec(arg) || check_filename(prefix, arg))
235
return;
236
die_verify_filename(prefix, arg, diagnose_misspelt_rev);
@@ -385,14 +385,14 @@ void setup_work_tree(void)
385
return;
386
387
if (work_tree_config_is_bogus)
388
- die("unable to set up work tree using invalid config");
388
+ die(_("unable to set up work tree using invalid config"));
389
390
work_tree = get_git_work_tree();
391
git_dir = get_git_dir();
392
if (!is_absolute_path(git_dir))
393
git_dir = real_path(get_git_dir());
394
if (!work_tree || chdir(work_tree))
395
- die("This operation must be run in a work tree");
395
+ die(_("this operation must be run in a work tree"));
396
397
/*
398
* Make sure subsequent git processes find correct worktree
@@ -525,17 +525,17 @@ void read_gitfile_error_die(int error_code, const char *path, const char *dir)
525
/* non-fatal; follow return path */
526
break;
527
case READ_GITFILE_ERR_OPEN_FAILED:
528
- die_errno("Error opening '%s'", path);
528
+ die_errno(_("error opening '%s'"), path);
529
case READ_GITFILE_ERR_TOO_LARGE:
530
- die("Too large to be a .git file: '%s'", path);
530
+ die(_("too large to be a .git file: '%s'"), path);
531
case READ_GITFILE_ERR_READ_FAILED:
532
- die("Error reading %s", path);
532
+ die(_("error reading %s"), path);
533
case READ_GITFILE_ERR_INVALID_FORMAT:
534
- die("Invalid gitfile format: %s", path);
534
+ die(_("invalid gitfile format: %s"), path);
535
case READ_GITFILE_ERR_NO_PATH:
536
- die("No path in gitfile: %s", path);
536
+ die(_("no path in gitfile: %s"), path);
537
case READ_GITFILE_ERR_NOT_A_REPO:
538
- die("Not a git repository: %s", dir);
538
+ die(_("not a git repository: %s"), dir);
539
default:
540
die("BUG: unknown error code");
541
}
@@ -634,7 +634,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
634
int offset;
635
636
if (PATH_MAX - 40 < strlen(gitdirenv))
637
- die("'$%s' too big", GIT_DIR_ENVIRONMENT);
637
+ die(_("'$%s' too big"), GIT_DIR_ENVIRONMENT);
638
639
gitfile = (char*)read_gitfile(gitdirenv);
640
if (gitfile) {
@@ -648,7 +648,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
648
free(gitfile);
649
return NULL;
650
}
651
- die("Not a git repository: '%s'", gitdirenv);
651
+ die(_("not a git repository: '%s'"), gitdirenv);
652
}
653
654
if (check_repository_format_gently(gitdirenv, repo_fmt, nongit_ok)) {
@@ -677,12 +677,12 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
677
else {
678
char *core_worktree;
679
if (chdir(gitdirenv))
680
- die_errno("Could not chdir to '%s'", gitdirenv);
680
+ die_errno(_("cannot chdir to '%s'"), gitdirenv);
681
if (chdir(git_work_tree_cfg))
682
- die_errno("Could not chdir to '%s'", git_work_tree_cfg);
682
+ die_errno(_("cannot chdir to '%s'"), git_work_tree_cfg);
683
core_worktree = xgetcwd();
684
if (chdir(cwd->buf))
685
- die_errno("Could not come back to cwd");
685
+ die_errno(_("cannot come back to cwd"));
686
set_git_work_tree(core_worktree);
687
free(core_worktree);
688
}
@@ -710,7 +710,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
710
if (offset >= 0) { /* cwd inside worktree? */
711
set_git_dir(real_path(gitdirenv));
712
if (chdir(worktree))
713
- die_errno("Could not chdir to '%s'", worktree);
713
+ die_errno(_("cannot chdir to '%s'"), worktree);
714
strbuf_addch(cwd, '/');
715
free(gitfile);
716
return cwd->buf + offset;
@@ -738,7 +738,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
738
if (offset != cwd->len && !is_absolute_path(gitdir))
739
gitdir = to_free = real_pathdup(gitdir, 1);
740
if (chdir(cwd->buf))
741
- die_errno("Could not come back to cwd");
741
+ die_errno(_("cannot come back to cwd"));
742
ret = setup_explicit_git_dir(gitdir, cwd, repo_fmt, nongit_ok);
743
free(to_free);
744
return ret;
@@ -748,7 +748,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
748
if (is_bare_repository_cfg > 0) {
749
set_git_dir(offset == cwd->len ? gitdir : real_path(gitdir));
750
if (chdir(cwd->buf))
751
- die_errno("Could not come back to cwd");
751
+ die_errno(_("cannot come back to cwd"));
752
return NULL;
753
}
754
@@ -787,7 +787,7 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
787
788
gitdir = offset == cwd->len ? "." : xmemdupz(cwd->buf, offset);
789
if (chdir(cwd->buf))
790
- die_errno("Could not come back to cwd");
790
+ die_errno(_("cannot come back to cwd"));
791
return setup_explicit_git_dir(gitdir, cwd, repo_fmt, nongit_ok);
792
}
793
@@ -795,7 +795,7 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
795
inside_work_tree = 0;
796
if (offset != cwd->len) {
797
if (chdir(cwd->buf))
798
- die_errno("Cannot come back to cwd");
798
+ die_errno(_("cannot come back to cwd"));
799
root_len = offset_1st_component(cwd->buf);
800
strbuf_setlen(cwd, offset > root_len ? offset : root_len);
801
set_git_dir(cwd->buf);
@@ -808,9 +808,9 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
808
static const char *setup_nongit(const char *cwd, int *nongit_ok)
809
{
810
if (!nongit_ok)
811
- die(_("Not a git repository (or any of the parent directories): %s"), DEFAULT_GIT_DIR_ENVIRONMENT);
811
+ die(_("not a git repository (or any of the parent directories): %s"), DEFAULT_GIT_DIR_ENVIRONMENT);
812
if (chdir(cwd))
813
- die_errno(_("Cannot come back to cwd"));
813
+ die_errno(_("cannot come back to cwd"));
814
*nongit_ok = 1;
815
return NULL;
816
}
@@ -819,7 +819,7 @@ static dev_t get_device_or_die(const char *path, const char *prefix, int prefix_
819
{
820
struct stat buf;
821
if (stat(path, &buf)) {
822
- die_errno("failed to stat '%*s%s%s'",
822
+ die_errno(_("failed to stat '%*s%s%s'"),
823
prefix_len,
824
prefix ? prefix : "",
825
prefix ? "/" : "", path);
@@ -1061,13 +1061,13 @@ const char *setup_git_directory_gently(int *nongit_ok)
1061
break;
1062
case GIT_DIR_DISCOVERED:
1063
if (dir.len < cwd.len && chdir(dir.buf))
1064
- die(_("Cannot change to '%s'"), dir.buf);
1064
+ die(_("cannot change to '%s'"), dir.buf);
1065
prefix = setup_discovered_git_dir(gitdir.buf, &cwd, dir.len,
1066
&repo_fmt, nongit_ok);
1067
break;
1068
case GIT_DIR_BARE:
1069
if (dir.len < cwd.len && chdir(dir.buf))
1070
- die(_("Cannot change to '%s'"), dir.buf);
1070
+ die(_("cannot change to '%s'"), dir.buf);
1071
prefix = setup_bare_git_dir(&cwd, dir.len, &repo_fmt, nongit_ok);
1072
break;
1073
case GIT_DIR_HIT_CEILING:
@@ -1080,7 +1080,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
1080
strbuf_release(&dir);
1081
return NULL;
1082
}
1083
- die(_("Not a git repository (or any parent up to mount point %s)\n"
1083
+ die(_("not a git repository (or any parent up to mount point %s)\n"
1084
"Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)."),
1085
dir.buf);
1086
default:
@@ -1164,7 +1164,7 @@ int git_config_perm(const char *var, const char *value)
1164
/* A filemode value was given: 0xxx */
1165
1166
if ((i & 0600) != 0600)
1167
- die(_("Problem with core.sharedRepository filemode value "
1167
+ die(_("problem with core.sharedRepository filemode value "
1168
"(0%.3o).\nThe owner of files must always have "
1169
"read and write permissions."), i);
1170
@@ -1207,7 +1207,7 @@ void sanitize_stdfds(void)
1207
while (fd != -1 && fd < 2)
1208
fd = dup(fd);
1209
if (fd == -1)
1210
- die_errno("open /dev/null or dup failed");
1210
+ die_errno(_("open /dev/null or dup failed"));
1211
if (fd > 2)
1212
close(fd);
1213
}
@@ -1222,12 +1222,12 @@ int daemonize(void)
1222
case 0:
1223
break;
1224
case -1:
1225
- die_errno("fork failed");
1225
+ die_errno(_("fork failed"));
1226
default:
1227
exit(0);
1228
}
1229
if (setsid() == -1)
1230
- die_errno("setsid failed");
1230
+ die_errno(_("setsid failed"));
1231
close(0);
1232
close(1);
1233
close(2);
t/t0002-gitfile.sh
+2
-2
@@ -31,7 +31,7 @@ test_expect_success 'bad setup: invalid .git file format' '
31
echo "git rev-parse accepted an invalid .git file"
32
false
33
fi &&
34
- if ! grep "Invalid gitfile format" .err
34
+ if ! test_i18ngrep "invalid gitfile format" .err
35
then
36
echo "git rev-parse returned wrong error"
37
false
@@ -45,7 +45,7 @@ test_expect_success 'bad setup: invalid .git file path' '
45
echo "git rev-parse accepted an invalid .git file path"
46
false
47
fi &&
48
- if ! grep "Not a git repository" .err
48
+ if ! test_i18ngrep "not a git repository" .err
49
then
50
echo "git rev-parse returned wrong error"
51
false
t/t0008-ignores.sh
+1
-1
@@ -307,7 +307,7 @@ test_expect_success_multi 'needs work tree' '' '
307
cd .git &&
308
test_check_ignore "foo" 128
309
) &&
310
- stderr_contains "fatal: This operation must be run in a work tree"
310
+ stderr_contains "fatal: this operation must be run in a work tree"
311
'
312
313
############################################################################
t/t1506-rev-parse-diagnosis.sh
+1
-1
@@ -157,7 +157,7 @@ test_expect_success 'relative path not found' '
157
test_expect_success 'relative path outside worktree' '
158
test_must_fail git rev-parse HEAD:../file.txt >output 2>error &&
159
test -z "$(cat output)" &&
160
- grep "outside repository" error
160
+ test_i18ngrep "outside repository" error
161
'
162
163
test_expect_success 'relative path when cwd is outside worktree' '