Add -a option to locale utility
* Required by POSIX. Change-Id: Ided0a9d45d5edd00f3aa6279e99ca486ca372f6c Reviewed-on: https://review.haiku-os.org/651 Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
bdcc7b74fc
commit
3bac8deff6
@ -22,6 +22,20 @@ extern const char *__progname;
|
|||||||
static const char *kProgramName = __progname;
|
static const char *kProgramName = __progname;
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
print_available_languages()
|
||||||
|
{
|
||||||
|
BMessage languages;
|
||||||
|
BLocaleRoster::Default()->GetAvailableLanguages(&languages);
|
||||||
|
BString language;
|
||||||
|
for (int i = 0; languages.FindString("language", i, &language) == B_OK;
|
||||||
|
i++) {
|
||||||
|
printf("%s.UTF-8\n", language.String());
|
||||||
|
}
|
||||||
|
printf("POSIX\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BString
|
BString
|
||||||
preferred_language()
|
preferred_language()
|
||||||
{
|
{
|
||||||
@ -73,7 +87,8 @@ print_time_conventions()
|
|||||||
void
|
void
|
||||||
usage(int status)
|
usage(int status)
|
||||||
{
|
{
|
||||||
printf("Usage: %s [-lftcm]\n"
|
printf("Usage: %s [-alftcm]\n"
|
||||||
|
" -a, --all\t\tPrint all available languages\n"
|
||||||
" -l, --language\tPrint the currently set preferred language\n"
|
" -l, --language\tPrint the currently set preferred language\n"
|
||||||
" -f, --format\t\tPrint the formatting-related locale\n"
|
" -f, --format\t\tPrint the formatting-related locale\n"
|
||||||
" -t, --time\t\tPrint the time-related locale\n"
|
" -t, --time\t\tPrint the time-related locale\n"
|
||||||
@ -90,6 +105,7 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
static struct option const longopts[] = {
|
static struct option const longopts[] = {
|
||||||
|
{"all", no_argument, 0, 'a'},
|
||||||
{"language", no_argument, 0, 'l'},
|
{"language", no_argument, 0, 'l'},
|
||||||
{"format", no_argument, 0, 'f'},
|
{"format", no_argument, 0, 'f'},
|
||||||
{"time", no_argument, 0, 't'},
|
{"time", no_argument, 0, 't'},
|
||||||
@ -100,7 +116,7 @@ main(int argc, char **argv)
|
|||||||
};
|
};
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt_long(argc, argv, "lcfmth", longopts, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "lcfmath", longopts, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'l':
|
case 'l':
|
||||||
printf("%s\n", preferred_language().String());
|
printf("%s\n", preferred_language().String());
|
||||||
@ -119,7 +135,10 @@ main(int argc, char **argv)
|
|||||||
case 'm':
|
case 'm':
|
||||||
puts("UTF-8");
|
puts("UTF-8");
|
||||||
break;
|
break;
|
||||||
// TODO 'a', 'c', 'k'
|
case 'a':
|
||||||
|
print_available_languages();
|
||||||
|
break;
|
||||||
|
// TODO 'c', 'k'
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(0);
|
usage(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user