eval: port v:collate

Cherry-picked from patch v8.2.0988. Required for patch v8.2.1933.
This commit is contained in:
Sean Dewar
2021-04-20 00:01:50 +01:00
parent 96f62394cf
commit 1d72b6e4cd
7 changed files with 55 additions and 7 deletions

View File

@@ -3627,6 +3627,14 @@ void set_lang_var(void)
loc = get_locale_val(LC_TIME);
# endif
set_vim_var_string(VV_LC_TIME, loc, -1);
# ifdef HAVE_GET_LOCALE_VAL
loc = get_locale_val(LC_COLLATE);
# else
// setlocale() not supported: use the default value
loc = "C";
# endif
set_vim_var_string(VV_COLLATE, loc, -1);
}
#ifdef HAVE_WORKING_LIBINTL
@@ -3667,6 +3675,10 @@ void ex_language(exarg_T *eap)
what = LC_TIME;
name = skipwhite(p);
whatstr = "time ";
} else if (STRNICMP(eap->arg, "collate", p - eap->arg) == 0) {
what = LC_COLLATE;
name = skipwhite(p);
whatstr = "collate ";
}
}
@@ -3711,7 +3723,7 @@ void ex_language(exarg_T *eap)
// Reset $LC_ALL, otherwise it would overrule everything.
os_setenv("LC_ALL", "", 1);
if (what != LC_TIME) {
if (what != LC_TIME && what != LC_COLLATE) {
// Tell gettext() what to translate to. It apparently doesn't
// use the currently effective locale.
if (what == LC_ALL) {
@@ -3726,7 +3738,7 @@ void ex_language(exarg_T *eap)
}
}
// Set v:lang, v:lc_time and v:ctype to the final result.
// Set v:lang, v:lc_time, v:collate and v:ctype to the final result.
set_lang_var();
maketitle();
}
@@ -3811,12 +3823,15 @@ char_u *get_lang_arg(expand_T *xp, int idx)
if (idx == 2) {
return (char_u *)"time";
}
if (idx == 3) {
return (char_u *)"collate";
}
init_locales();
if (locales == NULL) {
return NULL;
}
return locales[idx - 3];
return locales[idx - 4];
}
/// Function given to ExpandGeneric() to obtain the available locales.