From: Johannes Sixt Date: Mon, 15 Jan 2018 07:33:56 GMT Subject: Re: [PATCH 1/1] Mark messages for translations Message-ID: In-Reply-To: <20180115054419.4112-2-ash@kambanaria.org> Am 15.01.2018 um 06:44 schrieb Alexander Shopov: > @@ -5,11 +5,11 @@ > #include "run-command.h" > > const char git_usage_string[] = > - "git [--version] [--help] [-C ] [-c name=value]\n" > - " [--exec-path[=]] [--html-path] [--man-path] [--info-path]\n" > - " [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]\n" > - " [--git-dir=] [--work-tree=] [--namespace=]\n" > - " []"; > + N_("git [--version] [--help] [-C ] [-c name=value]\n" > + " [--exec-path[=]] [--html-path] [--man-path] [--info-path]\n" > + " [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]\n" > + " [--git-dir=] [--work-tree=] [--namespace=]\n" > + " []"); > > const char git_more_info_string[] = > 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) > *envchanged = 1; > } else if (!strcmp(cmd, "--git-dir")) { > if (*argc < 2) { > - fprintf(stderr, "No directory given for --git-dir.\n" ); > + fprintf(stderr, _("No directory given for --git-dir.\n" )); > usage(git_usage_string); It is not obvious to me where git_usage_string is looked up in the message catalog. Should this not be usage(_(git_usage_string)); (here and in later instances)? It is used that way in builtin/help.c, for example. > @@ -385,14 +385,14 @@ void setup_work_tree(void) > return; > > if (work_tree_config_is_bogus) > - die("unable to set up work tree using invalid config"); > + die(_("unable to set up work tree using invalid config")); > > work_tree = get_git_work_tree(); > git_dir = get_git_dir(); > if (!is_absolute_path(git_dir)) > git_dir = real_path(get_git_dir()); > if (!work_tree || chdir(work_tree)) > - die("This operation must be run in a work tree"); > + die(_("This operation must be run in a work tree")); We have settled with lower-case letters at the beginning of error messages. (See Documentation/CodingGuidelines, "Error Messages".) You could fix that while you are touching die, die_errno, etc, messages. > @@ -677,12 +677,12 @@ static const char *setup_explicit_git_dir(const char *gitdirenv, > else { > char *core_worktree; > if (chdir(gitdirenv)) > - die_errno("Could not chdir to '%s'", gitdirenv); > + die_errno(_("Cannot chdir to '%s'"), gitdirenv); I notice you change past tense to present tense in some cases. IMO, this makes the messages more consistent. Good. I'm not a friend of geeky abbreviations like "chdir" or "cwd" in user-visible messages, and I would have taken the opportunity to change the messages accordingly. This is really only my personal taste, though, and it's possible that I'm alone in this camp. > if (chdir(git_work_tree_cfg)) > - die_errno("Could not chdir to '%s'", git_work_tree_cfg); > + die_errno(_("Cannot chdir to '%s'"), git_work_tree_cfg); > core_worktree = xgetcwd(); > if (chdir(cwd->buf)) > - die_errno("Could not come back to cwd"); > + die_errno(_("Cannot come back to cwd"); ... > @@ -1207,7 +1207,7 @@ void sanitize_stdfds(void) > while (fd != -1 && fd < 2) > fd = dup(fd); > if (fd == -1) > - die_errno("open /dev/null or dup failed"); > + die_errno(_("open /dev/null or dup failed")); > if (fd > 2) > close(fd); > } > @@ -1222,12 +1222,12 @@ int daemonize(void) > case 0: > break; > case -1: > - die_errno("fork failed"); > + die_errno(_("fork failed")); > default: > exit(0); > } > if (setsid() == -1) > - die_errno("setsid failed"); > + die_errno(_("setsid failed")); Here is a certain class of errors: They should occur only rarely (actually, is that true?) Then it is useful to have the function name in the message. Which rises the question: why translate them at all? It's possible that translators turn the message into unusable gibberish just to please their language. All of this is only IMHO; I don't use translated Git. -- Hannes