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:
+6
-7
@@ -17,13 +17,12 @@ export HISTFILESIZE=50
|
|||||||
export HISTCONTROL=ignoredups
|
export HISTCONTROL=ignoredups
|
||||||
|
|
||||||
# Locale
|
# Locale
|
||||||
export LANG=`locale -l`
|
export LC_MESSAGES=`locale -m`
|
||||||
export LC_CTYPE=`locale -c`
|
export LC_NUMERIC=`locale -f`
|
||||||
export LC_TIME=`locale -f`
|
export LC_TIME=`locale -t`
|
||||||
export LC_NUMERIC=$LC_TIME
|
export LC_COLLATE=$LC_MESSAGES
|
||||||
export LC_COLLATE=$LC_TIME
|
export LC_CTYPE=$LC_MESSAGES
|
||||||
export LC_MONETARY=$LC_TIME
|
export LC_MONETARY=$LC_NUMERIC
|
||||||
export LC_MESSAGES=$LC_TIME
|
|
||||||
|
|
||||||
alias ls="ls --color"
|
alias ls="ls --color"
|
||||||
alias ll="ls -lA"
|
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
|
void
|
||||||
usage(int status)
|
usage(int status)
|
||||||
{
|
{
|
||||||
printf("Usage: %s [-lcf]\n"
|
printf("Usage: %s [-lfmt]\n"
|
||||||
" -l, --language\tPrint the currently set preferred language\n"
|
" -l, --language\tPrint the currently set preferred language\n"
|
||||||
" -c, --ctype\t\tPrint the LC_CTYPE value based on the preferred"
|
" -f, --format\t\tPrint the formatting-related locale\n"
|
||||||
" language\n"
|
" -m, --message\t\tPrint the message-related locale\n"
|
||||||
" -f, --format\t\tPrint the formatting convention language\n"
|
" -t, --time\t\tPrint the time-related locale\n"
|
||||||
" -h, --help\t\tDisplay this help and exit\n",
|
" -h, --help\t\tDisplay this help and exit\n",
|
||||||
kProgramName);
|
kProgramName);
|
||||||
|
|
||||||
@@ -68,24 +83,29 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
static struct option const longopts[] = {
|
static struct option const longopts[] = {
|
||||||
{"language", no_argument, 0, 'l'},
|
{"language", no_argument, 0, 'l'},
|
||||||
{"ctype", no_argument, 0, 'c'},
|
|
||||||
{"format", no_argument, 0, 'f'},
|
{"format", no_argument, 0, 'f'},
|
||||||
|
{"message", no_argument, 0, 'm'},
|
||||||
|
{"time", no_argument, 0, 't'},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, 0, 'h'},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt_long(argc, argv, "lcfh", longopts, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "lcfmth", longopts, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'l':
|
case 'l':
|
||||||
printf("%s\n", preferred_language().String());
|
printf("%s\n", preferred_language().String());
|
||||||
break;
|
break;
|
||||||
case 'c':
|
|
||||||
printf("%s.UTF-8\n", preferred_language().String());
|
|
||||||
break;
|
|
||||||
case 'f':
|
case 'f':
|
||||||
print_formatting_conventions();
|
print_formatting_conventions();
|
||||||
break;
|
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':
|
case 'h':
|
||||||
usage(0);
|
usage(0);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user