sha1-file.c: mark more strings for translation
[gitweb.git] / builtin / config.c
index 1e31aa9f8d98ffa6790ba2c6023634841b1abf74..5761a2c4ac25d3f90938f9830d4c9d7eebaa9a92 100644 (file)
@@ -110,7 +110,7 @@ static int option_parse_type(const struct option *opt, const char *arg,
                 * --int' and '--type=bool
                 * --type=int'.
                 */
-               error("only one type at a time.");
+               error(_("only one type at a time"));
                usage_with_options(builtin_config_usage,
                        builtin_config_options);
        }
@@ -160,7 +160,11 @@ static struct option builtin_config_options[] = {
 static void check_argc(int argc, int min, int max) {
        if (argc >= min && argc <= max)
                return;
-       error("wrong number of arguments");
+       if (min == max)
+               error(_("wrong number of arguments, should be %d"), min);
+       else
+               error(_("wrong number of arguments, should be from %d to %d"),
+                     min, max);
        usage_with_options(builtin_config_usage, builtin_config_options);
 }
 
@@ -293,7 +297,7 @@ static int get_value(const char *key_, const char *regex_)
 
                key_regexp = (regex_t*)xmalloc(sizeof(regex_t));
                if (regcomp(key_regexp, key, REG_EXTENDED)) {
-                       error("invalid key pattern: %s", key_);
+                       error(_("invalid key pattern: %s"), key_);
                        FREE_AND_NULL(key_regexp);
                        ret = CONFIG_INVALID_PATTERN;
                        goto free_strings;
@@ -313,7 +317,7 @@ static int get_value(const char *key_, const char *regex_)
 
                regexp = (regex_t*)xmalloc(sizeof(regex_t));
                if (regcomp(regexp, regex_, REG_EXTENDED)) {
-                       error("invalid pattern: %s", regex_);
+                       error(_("invalid pattern: %s"), regex_);
                        FREE_AND_NULL(regexp);
                        ret = CONFIG_INVALID_PATTERN;
                        goto free_strings;
@@ -386,7 +390,7 @@ static char *normalize_value(const char *key, const char *value)
        if (type == TYPE_COLOR) {
                char v[COLOR_MAXLEN];
                if (git_config_color(v, key, value))
-                       die("cannot parse color '%s'", value);
+                       die(_("cannot parse color '%s'"), value);
 
                /*
                 * The contents of `v` now contain an ANSI escape
@@ -481,13 +485,13 @@ static int get_colorbool(const char *var, int print)
 static void check_write(void)
 {
        if (!given_config_source.file && !startup_info->have_repository)
-               die("not in a git directory");
+               die(_("not in a git directory"));
 
        if (given_config_source.use_stdin)
-               die("writing to stdin is not supported");
+               die(_("writing to stdin is not supported"));
 
        if (given_config_source.blob)
-               die("writing config blobs is not supported");
+               die(_("writing config blobs is not supported"));
 }
 
 struct urlmatch_current_candidate_value {
@@ -595,13 +599,16 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 
        if (use_global_config + use_system_config + use_local_config +
            !!given_config_source.file + !!given_config_source.blob > 1) {
-               error("only one config file at a time.");
+               error(_("only one config file at a time"));
                usage_with_options(builtin_config_usage, builtin_config_options);
        }
 
        if (use_local_config && nongit)
                die(_("--local can only be used inside a git repository"));
 
+       if (given_config_source.blob && nongit)
+               die(_("--blob can only be used inside a git repository"));
+
        if (given_config_source.file &&
                        !strcmp(given_config_source.file, "-")) {
                given_config_source.file = NULL;
@@ -619,7 +626,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
                         * location; error out even if XDG_CONFIG_HOME
                         * is set and points at a sane location.
                         */
-                       die("$HOME not set");
+                       die(_("$HOME not set"));
 
                if (access_or_warn(user_config, R_OK, 0) &&
                    xdg_config && !access_or_warn(xdg_config, R_OK, 0)) {
@@ -656,12 +663,12 @@ int cmd_config(int argc, const char **argv, const char *prefix)
        }
 
        if ((actions & (ACTION_GET_COLOR|ACTION_GET_COLORBOOL)) && type) {
-               error("--get-color and variable type are incoherent");
+               error(_("--get-color and variable type are incoherent"));
                usage_with_options(builtin_config_usage, builtin_config_options);
        }
 
        if (HAS_MULTI_BITS(actions)) {
-               error("only one action at a time.");
+               error(_("only one action at a time"));
                usage_with_options(builtin_config_usage, builtin_config_options);
        }
        if (actions == 0)
@@ -674,19 +681,19 @@ int cmd_config(int argc, const char **argv, const char *prefix)
                }
        if (omit_values &&
            !(actions == ACTION_LIST || actions == ACTION_GET_REGEXP)) {
-               error("--name-only is only applicable to --list or --get-regexp");
+               error(_("--name-only is only applicable to --list or --get-regexp"));
                usage_with_options(builtin_config_usage, builtin_config_options);
        }
 
        if (show_origin && !(actions &
                (ACTION_GET|ACTION_GET_ALL|ACTION_GET_REGEXP|ACTION_LIST))) {
-               error("--show-origin is only applicable to --get, --get-all, "
-                         "--get-regexp, and --list.");
+               error(_("--show-origin is only applicable to --get, --get-all, "
+                       "--get-regexp, and --list"));
                usage_with_options(builtin_config_usage, builtin_config_options);
        }
 
        if (default_value && !(actions & ACTION_GET)) {
-               error("--default is only applicable to --get");
+               error(_("--default is only applicable to --get"));
                usage_with_options(builtin_config_usage,
                        builtin_config_options);
        }
@@ -700,10 +707,10 @@ int cmd_config(int argc, const char **argv, const char *prefix)
                                        &given_config_source,
                                        &config_options) < 0) {
                        if (given_config_source.file)
-                               die_errno("unable to read config file '%s'",
+                               die_errno(_("unable to read config file '%s'"),
                                          given_config_source.file);
                        else
-                               die("error processing config file(s)");
+                               die(_("error processing config file(s)"));
                }
        }
        else if (actions == ACTION_EDIT) {
@@ -711,11 +718,11 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 
                check_argc(argc, 0, 0);
                if (!given_config_source.file && nongit)
-                       die("not in a git directory");
+                       die(_("not in a git directory"));
                if (given_config_source.use_stdin)
-                       die("editing stdin is not supported");
+                       die(_("editing stdin is not supported"));
                if (given_config_source.blob)
-                       die("editing blobs is not supported");
+                       die(_("editing blobs is not supported"));
                git_config(git_default_config, NULL);
                config_file = given_config_source.file ?
                                xstrdup(given_config_source.file) :
@@ -816,7 +823,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
                if (ret < 0)
                        return ret;
                if (ret == 0)
-                       die("No such section!");
+                       die(_("no such section: %s"), argv[0]);
        }
        else if (actions == ACTION_REMOVE_SECTION) {
                int ret;
@@ -827,7 +834,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
                if (ret < 0)
                        return ret;
                if (ret == 0)
-                       die("No such section!");
+                       die(_("no such section: %s"), argv[0]);
        }
        else if (actions == ACTION_GET_COLOR) {
                check_argc(argc, 1, 2);