From 4fa4b31507f28b3a6486e44b620ab36c6380cb7d Mon Sep 17 00:00:00 2001 From: Vasco Almeida Date: Mon, 19 Sep 2016 13:08:16 +0000 Subject: i18n: commit: mark message for translation Mark message commit_utf8_warn for translation. Update tests to reflect changes. Signed-off-by: Vasco Almeida Signed-off-by: Junio C Hamano diff --git a/commit.c b/commit.c index ba6dee3..8eb1707 100644 --- a/commit.c +++ b/commit.c @@ -1511,9 +1511,9 @@ static int verify_utf8(struct strbuf *buf) } static const char commit_utf8_warn[] = -"Warning: commit message did not conform to UTF-8.\n" -"You may want to amend it after fixing the message, or set the config\n" -"variable i18n.commitencoding to the encoding your project uses.\n"; +N_("Warning: commit message did not conform to UTF-8.\n" + "You may want to amend it after fixing the message, or set the config\n" + "variable i18n.commitencoding to the encoding your project uses.\n"); int commit_tree_extended(const char *msg, size_t msg_len, const unsigned char *tree, @@ -1566,7 +1566,7 @@ int commit_tree_extended(const char *msg, size_t msg_len, /* And check the encoding */ if (encoding_is_utf8 && !verify_utf8(&buffer)) - fprintf(stderr, commit_utf8_warn); + fprintf(stderr, _(commit_utf8_warn)); if (sign_commit && do_sign_commit(&buffer, sign_commit)) return -1; diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh index 4bf1dbe..3b94283 100755 --- a/t/t3900-i18n-commit.sh +++ b/t/t3900-i18n-commit.sh @@ -45,7 +45,7 @@ test_expect_success 'UTF-8 invalid characters refused' ' printf "Commit message\n\nInvalid surrogate:\355\240\200\n" \ >"$HOME/invalid" && git commit -a -F "$HOME/invalid" 2>"$HOME"/stderr && - grep "did not conform" "$HOME"/stderr + test_i18ngrep "did not conform" "$HOME"/stderr ' test_expect_success 'UTF-8 overlong sequences rejected' ' @@ -55,7 +55,7 @@ test_expect_success 'UTF-8 overlong sequences rejected' ' printf "\340\202\251ommit message\n\nThis is not a space:\300\240\n" \ >"$HOME/invalid" && git commit -a -F "$HOME/invalid" 2>"$HOME"/stderr && - grep "did not conform" "$HOME"/stderr + test_i18ngrep "did not conform" "$HOME"/stderr ' test_expect_success 'UTF-8 non-characters refused' ' @@ -64,7 +64,7 @@ test_expect_success 'UTF-8 non-characters refused' ' printf "Commit message\n\nNon-character:\364\217\277\276\n" \ >"$HOME/invalid" && git commit -a -F "$HOME/invalid" 2>"$HOME"/stderr && - grep "did not conform" "$HOME"/stderr + test_i18ngrep "did not conform" "$HOME"/stderr ' test_expect_success 'UTF-8 non-characters refused' ' @@ -73,7 +73,7 @@ test_expect_success 'UTF-8 non-characters refused' ' printf "Commit message\n\nNon-character:\357\267\220\n" \ >"$HOME/invalid" && git commit -a -F "$HOME/invalid" 2>"$HOME"/stderr && - grep "did not conform" "$HOME"/stderr + test_i18ngrep "did not conform" "$HOME"/stderr ' for H in ISO8859-1 eucJP ISO-2022-JP diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh index 509084e..f663d56 100755 --- a/t/t3901-i18n-patch.sh +++ b/t/t3901-i18n-patch.sh @@ -295,7 +295,7 @@ test_expect_success 'am --no-utf8 (U/L)' ' # commit-tree will warn that the commit message does not contain valid UTF-8 # as mailinfo did not convert it - grep "did not conform" err && + test_i18ngrep "did not conform" err && check_encoding 2 ' -- cgit v0.10.2-6-g49f6 From f2b93b388ccbce342bc8b58d8581f6a077f42eff Mon Sep 17 00:00:00 2001 From: Vasco Almeida Date: Mon, 19 Sep 2016 13:08:17 +0000 Subject: i18n: connect: mark die messages for translation Mark messages passed to die() in die_initial_contact(). Update test to reflect changes. Signed-off-by: Vasco Almeida Signed-off-by: Junio C Hamano diff --git a/connect.c b/connect.c index 722dc3f..06bff0b 100644 --- a/connect.c +++ b/connect.c @@ -46,11 +46,11 @@ int check_ref_type(const struct ref *ref, int flags) static void die_initial_contact(int got_at_least_one_head) { if (got_at_least_one_head) - die("The remote end hung up upon initial contact"); + die(_("The remote end hung up upon initial contact")); else - die("Could not read from remote repository.\n\n" - "Please make sure you have the correct access rights\n" - "and the repository exists."); + die(_("Could not read from remote repository.\n\n" + "Please make sure you have the correct access rights\n" + "and the repository exists.")); } static void parse_one_symref_info(struct string_list *symref, const char *val, int len) diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index 819b9dd..c23434b 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -99,7 +99,7 @@ test_expect_success 'confuses pattern as remote when no remote specified' ' # We could just as easily have used "master"; the "*" emphasizes its # role as a pattern. test_must_fail git ls-remote refs*master >actual 2>&1 && - test_cmp exp actual + test_i18ncmp exp actual ' test_expect_success 'die with non-2 for wrong repository even with --exit-code' ' -- cgit v0.10.2-6-g49f6 From a2f05c94545a5409d4a90fcad5d495d3d758b218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20AVILA?= Date: Tue, 20 Sep 2016 21:04:27 +0200 Subject: i18n: i18n: diff: mark die messages for translation While marking individual messages for translation, consolidate some messages "option 'foo' requires a value" that is used for many options into one by introducing a helper function to die with the message with the option name embedded in it, and ask the translators to localize that single message instead. Signed-off-by: Vasco Almeida Signed-off-by: Jean-Noel Avila Signed-off-by: Junio C Hamano diff --git a/diff.c b/diff.c index 534c12e..9270228 100644 --- a/diff.c +++ b/diff.c @@ -54,6 +54,11 @@ static char diff_colors[][COLOR_MAXLEN] = { GIT_COLOR_NORMAL, /* FUNCINFO */ }; +static NORETURN void die_want_option(const char *option_name) +{ + die(_("option '%s' requires a value"), option_name); +} + static int parse_diff_color_slot(const char *var) { if (!strcasecmp(var, "context") || !strcasecmp(var, "plain")) @@ -3322,7 +3327,7 @@ void diff_setup_done(struct diff_options *options) if (options->output_format & DIFF_FORMAT_NO_OUTPUT) count++; if (count > 1) - die("--name-only, --name-status, --check and -s are mutually exclusive"); + die(_("--name-only, --name-status, --check and -s are mutually exclusive")); /* * Most of the time we can say "there are changes" @@ -3518,7 +3523,7 @@ static int stat_opt(struct diff_options *options, const char **av) if (*arg == '=') width = strtoul(arg + 1, &end, 10); else if (!*arg && !av[1]) - die("Option '--stat-width' requires a value"); + die_want_option("--stat-width"); else if (!*arg) { width = strtoul(av[1], &end, 10); argcount = 2; @@ -3527,7 +3532,7 @@ static int stat_opt(struct diff_options *options, const char **av) if (*arg == '=') name_width = strtoul(arg + 1, &end, 10); else if (!*arg && !av[1]) - die("Option '--stat-name-width' requires a value"); + die_want_option("--stat-name-width"); else if (!*arg) { name_width = strtoul(av[1], &end, 10); argcount = 2; @@ -3536,7 +3541,7 @@ static int stat_opt(struct diff_options *options, const char **av) if (*arg == '=') graph_width = strtoul(arg + 1, &end, 10); else if (!*arg && !av[1]) - die("Option '--stat-graph-width' requires a value"); + die_want_option("--stat-graph-width"); else if (!*arg) { graph_width = strtoul(av[1], &end, 10); argcount = 2; @@ -3545,7 +3550,7 @@ static int stat_opt(struct diff_options *options, const char **av) if (*arg == '=') count = strtoul(arg + 1, &end, 10); else if (!*arg && !av[1]) - die("Option '--stat-count' requires a value"); + die_want_option("--stat-count"); else if (!*arg) { count = strtoul(av[1], &end, 10); argcount = 2; -- cgit v0.10.2-6-g49f6 From 166e55e328a5b303031140f758a0463df331777a Mon Sep 17 00:00:00 2001 From: Vasco Almeida Date: Mon, 19 Sep 2016 13:08:19 +0000 Subject: i18n: ident: mark hint for translation Mark env_hint for translation. Signed-off-by: Vasco Almeida Signed-off-by: Junio C Hamano diff --git a/ident.c b/ident.c index e20a772..92c3cca 100644 --- a/ident.c +++ b/ident.c @@ -331,17 +331,17 @@ person_only: } static const char *env_hint = -"\n" -"*** Please tell me who you are.\n" -"\n" -"Run\n" -"\n" -" git config --global user.email \"you@example.com\"\n" -" git config --global user.name \"Your Name\"\n" -"\n" -"to set your account\'s default identity.\n" -"Omit --global to set the identity only in this repository.\n" -"\n"; +N_("\n" + "*** Please tell me who you are.\n" + "\n" + "Run\n" + "\n" + " git config --global user.email \"you@example.com\"\n" + " git config --global user.name \"Your Name\"\n" + "\n" + "to set your account\'s default identity.\n" + "Omit --global to set the identity only in this repository.\n" + "\n"); const char *fmt_ident(const char *name, const char *email, const char *date_str, int flag) @@ -356,13 +356,13 @@ const char *fmt_ident(const char *name, const char *email, if (!name) { if (strict && ident_use_config_only && !(ident_config_given & IDENT_NAME_GIVEN)) { - fputs(env_hint, stderr); + fputs(_(env_hint), stderr); die("no name was given and auto-detection is disabled"); } name = ident_default_name(); using_default = 1; if (strict && default_name_is_bogus) { - fputs(env_hint, stderr); + fputs(_(env_hint), stderr); die("unable to auto-detect name (got '%s')", name); } } @@ -370,7 +370,7 @@ const char *fmt_ident(const char *name, const char *email, struct passwd *pw; if (strict) { if (using_default) - fputs(env_hint, stderr); + fputs(_(env_hint), stderr); die("empty ident name (for <%s>) not allowed", email); } pw = xgetpwuid_self(NULL); @@ -381,12 +381,12 @@ const char *fmt_ident(const char *name, const char *email, if (!email) { if (strict && ident_use_config_only && !(ident_config_given & IDENT_MAIL_GIVEN)) { - fputs(env_hint, stderr); + fputs(_(env_hint), stderr); die("no email was given and auto-detection is disabled"); } email = ident_default_email(); if (strict && default_email_is_bogus) { - fputs(env_hint, stderr); + fputs(_(env_hint), stderr); die("unable to auto-detect email address (got '%s')", email); } } -- cgit v0.10.2-6-g49f6 From c041c6d06a7fce3aa563d7b0c4a47feccc541400 Mon Sep 17 00:00:00 2001 From: Vasco Almeida Date: Mon, 19 Sep 2016 13:08:20 +0000 Subject: i18n: notes-merge: mark die messages for translation Update test to reflect changes. Signed-off-by: Vasco Almeida Signed-off-by: Junio C Hamano diff --git a/notes-merge.c b/notes-merge.c index 97fc42f..3bbeb86 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -269,15 +269,15 @@ static void check_notes_merge_worktree(struct notes_merge_options *o) if (file_exists(git_path(NOTES_MERGE_WORKTREE)) && !is_empty_dir(git_path(NOTES_MERGE_WORKTREE))) { if (advice_resolve_conflict) - die("You have not concluded your previous " + die(_("You have not concluded your previous " "notes merge (%s exists).\nPlease, use " "'git notes merge --commit' or 'git notes " "merge --abort' to commit/abort the " "previous merge before you start a new " - "notes merge.", git_path("NOTES_MERGE_*")); + "notes merge."), git_path("NOTES_MERGE_*")); else - die("You have not concluded your notes merge " - "(%s exists).", git_path("NOTES_MERGE_*")); + die(_("You have not concluded your notes merge " + "(%s exists)."), git_path("NOTES_MERGE_*")); } if (safe_create_leading_directories_const(git_path( diff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh index 6967436..baef2d6 100755 --- a/t/t3310-notes-merge-manual-resolve.sh +++ b/t/t3310-notes-merge-manual-resolve.sh @@ -225,7 +225,7 @@ test_expect_success 'cannot do merge w/conflicts when previous merge is unfinish test -d .git/NOTES_MERGE_WORKTREE && test_must_fail git notes merge z >output 2>&1 && # Output should indicate what is wrong - grep -q "\\.git/NOTES_MERGE_\\* exists" output + test_i18ngrep -q "\\.git/NOTES_MERGE_\\* exists" output ' # Setup non-conflicting merge between x and new notes ref w -- cgit v0.10.2-6-g49f6 From 850251f33be0e1d0a30d11285b618bdce23be3d7 Mon Sep 17 00:00:00 2001 From: Vasco Almeida Date: Mon, 19 Sep 2016 13:08:21 +0000 Subject: i18n: stash: mark messages for translation Signed-off-by: Vasco Almeida Signed-off-by: Junio C Hamano diff --git a/git-stash.sh b/git-stash.sh index 826af18..90d63f2 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -100,7 +100,7 @@ create_stash () { u_tree=$(git write-tree) && printf 'untracked files on %s\n' "$msg" | git commit-tree $u_tree && rm -f "$TMPindex" - ) ) || die "Cannot save the untracked files" + ) ) || die "$(gettext "Cannot save the untracked files")" untracked_commit_option="-p $u_commit"; else @@ -248,7 +248,7 @@ save_stash () { if test -n "$patch_mode" && test -n "$untracked" then - die "Can't use --patch and --include-untracked or --all at the same time" + die "$(gettext "Can't use --patch and --include-untracked or --all at the same time")" fi stash_msg="$*" @@ -494,7 +494,7 @@ apply_stash () { GIT_INDEX_FILE="$TMPindex" git-read-tree "$u_tree" && GIT_INDEX_FILE="$TMPindex" git checkout-index --all && rm -f "$TMPindex" || - die 'Could not restore untracked files from stash' + die "$(gettext "Could not restore untracked files from stash")" fi eval " -- cgit v0.10.2-6-g49f6