Adjust /bin/locale to print time-related locale, too.
* add support for printing the time-related locale (which may contain a '@strings=messages' suffix if required by locale configuration * adjust cmdline params of /bin/locale to be a bit clearer (but keep support for -c for compatibility) * adjust /etc/profile to invoke /bin/locale accordingly
This commit is contained in:
parent
ec17468f63
commit
98057dd02a
@ -17,13 +17,12 @@ export HISTFILESIZE=50
|
||||
export HISTCONTROL=ignoredups
|
||||
|
||||
# Locale
|
||||
export LANG=`locale -l`
|
||||
export LC_CTYPE=`locale -c`
|
||||
export LC_TIME=`locale -f`
|
||||
export LC_NUMERIC=$LC_TIME
|
||||
export LC_COLLATE=$LC_TIME
|
||||
export LC_MONETARY=$LC_TIME
|
||||
export LC_MESSAGES=$LC_TIME
|
||||
export LC_MESSAGES=`locale -m`
|
||||
export LC_NUMERIC=`locale -f`
|
||||
export LC_TIME=`locale -t`
|
||||
export LC_COLLATE=$LC_MESSAGES
|
||||
export LC_CTYPE=$LC_MESSAGES
|
||||
export LC_MONETARY=$LC_NUMERIC
|
||||
|
||||
alias ls="ls --color"
|
||||
alias ll="ls -lA"
|
||||
|
@ -48,14 +48,29 @@ print_formatting_conventions()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
print_time_conventions()
|
||||
{
|
||||
BFormattingConventions conventions;
|
||||
BLocale::Default()->GetFormattingConventions(&conventions);
|
||||
if (conventions.UseStringsFromPreferredLanguage()) {
|
||||
printf("%s_%s.UTF-8@strings=messages\n", conventions.LanguageCode(),
|
||||
conventions.CountryCode());
|
||||
} else {
|
||||
printf("%s_%s.UTF-8\n", conventions.LanguageCode(),
|
||||
conventions.CountryCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
usage(int status)
|
||||
{
|
||||
printf("Usage: %s [-lcf]\n"
|
||||
printf("Usage: %s [-lfmt]\n"
|
||||
" -l, --language\tPrint the currently set preferred language\n"
|
||||
" -c, --ctype\t\tPrint the LC_CTYPE value based on the preferred"
|
||||
" language\n"
|
||||
" -f, --format\t\tPrint the formatting convention language\n"
|
||||
" -f, --format\t\tPrint the formatting-related locale\n"
|
||||
" -m, --message\t\tPrint the message-related locale\n"
|
||||
" -t, --time\t\tPrint the time-related locale\n"
|
||||
" -h, --help\t\tDisplay this help and exit\n",
|
||||
kProgramName);
|
||||
|
||||
@ -68,24 +83,29 @@ main(int argc, char **argv)
|
||||
{
|
||||
static struct option const longopts[] = {
|
||||
{"language", no_argument, 0, 'l'},
|
||||
{"ctype", no_argument, 0, 'c'},
|
||||
{"format", no_argument, 0, 'f'},
|
||||
{"message", no_argument, 0, 'm'},
|
||||
{"time", no_argument, 0, 't'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int c;
|
||||
while ((c = getopt_long(argc, argv, "lcfh", longopts, NULL)) != -1) {
|
||||
while ((c = getopt_long(argc, argv, "lcfmth", longopts, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'l':
|
||||
printf("%s\n", preferred_language().String());
|
||||
break;
|
||||
case 'c':
|
||||
printf("%s.UTF-8\n", preferred_language().String());
|
||||
break;
|
||||
case 'f':
|
||||
print_formatting_conventions();
|
||||
break;
|
||||
case 'c': // for compatibility, we used to use 'c' for ctype
|
||||
case 'm':
|
||||
printf("%s.UTF-8\n", preferred_language().String());
|
||||
break;
|
||||
case 't':
|
||||
print_time_conventions();
|
||||
break;
|
||||
case 'h':
|
||||
usage(0);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user