Add -i/--input option to locale(1)
The default UI language returned by GetUserDefaultUILanguage does not necessarily reflect what the user really wants. E. g., the system could be en_US, but the desired language is en_CA, without having a CA langpack installed. Changing the settings under "Languages" and changing the keyboard layout is only affecting the so-called "Input language", while what's returned by GetUserDefaultUILanguage is the "Display language". Changing the latter requires installing MUI langpacks. Thus, we introduce a way to fetch the "Input language" using the -i or --input option. Also clean up documentation of locale(1). Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
		| @@ -787,7 +787,7 @@ ldd [OPTION]... FILE... | |||||||
|       <screen> |       <screen> | ||||||
| locale [-amvhV] | locale [-amvhV] | ||||||
| locale [-ck] NAME | locale [-ck] NAME | ||||||
| locale [-usfnU] | locale [-iusfnU] | ||||||
|       </screen> |       </screen> | ||||||
|     </refsynopsisdiv> |     </refsynopsisdiv> | ||||||
|  |  | ||||||
| @@ -807,6 +807,7 @@ Modify output format: | |||||||
|  |  | ||||||
| Default locale information: | Default locale information: | ||||||
|  |  | ||||||
|  |   -i, --input          Print current input locale | ||||||
|   -u, --user           Print locale of user's default UI language |   -u, --user           Print locale of user's default UI language | ||||||
|   -s, --system         Print locale of system default UI language |   -s, --system         Print locale of system default UI language | ||||||
|   -f, --format         Print locale of user's regional format settings |   -f, --format         Print locale of user's regional format settings | ||||||
| @@ -826,20 +827,34 @@ Other options: | |||||||
|     <para><command>locale</command> without parameters prints information about |     <para><command>locale</command> without parameters prints information about | ||||||
|       the current locale environment settings.</para> |       the current locale environment settings.</para> | ||||||
|  |  | ||||||
|     <para>The <literal>-u</literal>, <literal>-s</literal>, |     <para>The <literal>-i</literal>, <literal>-u</literal>, | ||||||
|       <literal>-f</literal>, and <literal>-n</literal> options can be used to |       <literal>-s</literal>, <literal>-f</literal>, and <literal>-n</literal> | ||||||
|       request the various Windows locale settings. The purpose is to use this |       options can be used to request the various Windows locale settings. The | ||||||
|       command in scripts to set the POSIX locale variables.</para> |       purpose is to use this command in scripts to set the POSIX locale | ||||||
|  |       variables.</para> | ||||||
|  |  | ||||||
|  |     <para>The <literal>-i</literal> option prints the current input language. | ||||||
|  |       This is called the "Input language" and basically equivalent to the | ||||||
|  |       current keyboard layout setting.</para> | ||||||
|  |  | ||||||
|     <para>The <literal>-u</literal> option prints the current user's Windows UI |     <para>The <literal>-u</literal> option prints the current user's Windows UI | ||||||
|       locale to stdout. In Windows this setting is called the |       locale to stdout. In Windows this setting is called the | ||||||
|       "Display Language". The <literal>-s</literal> option prints the systems |       "Display Language".</para> | ||||||
|       default instead. The <literal>-f</literal> option prints the user's |  | ||||||
|       setting for time, date, number and currency. That's equivalent to the |     <para>The <literal>-s</literal> option prints the systems default instead. | ||||||
|       setting in the "Formats" or "Regional Options" tab in the "Region and |     </para> | ||||||
|       Language" or "Regional and Language Options" dialog. With the |  | ||||||
|       <literal>-U</literal> option <command>locale</command> appends a |     <para>The <literal>-f</literal> option prints the user's setting for time, | ||||||
|       ".UTF-8".</para> |       date, number and currency. That's equivalent to the setting in the | ||||||
|  |       "Formats" or "Regional Options" tab in the "Region and Language" or | ||||||
|  |       "Regional and Language Options" dialog.</para> | ||||||
|  |  | ||||||
|  |     <para>The <literal>-n</literal> option prints the system's default | ||||||
|  |       language used for applications which don't support Unicode.</para> | ||||||
|  |  | ||||||
|  |     <para>With the <literal>-U</literal> option <command>locale</command> | ||||||
|  |       appends the string ".UTF-8" to enforce using UTF-8.  Using UTF-8 | ||||||
|  |       as codeset is recommended.</para> | ||||||
|  |  | ||||||
|     <para>Usage example:</para> |     <para>Usage example:</para> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -48,7 +48,7 @@ usage () | |||||||
|   printf ( |   printf ( | ||||||
| "Usage: %1$s [-amvhV]\n" | "Usage: %1$s [-amvhV]\n" | ||||||
| "   or: %1$s [-ck] NAME\n" | "   or: %1$s [-ck] NAME\n" | ||||||
| "   or: %1$s [-usfnU]\n" | "   or: %1$s [-iusfnU]\n" | ||||||
| "\n" | "\n" | ||||||
| "Get locale-specific information.\n" | "Get locale-specific information.\n" | ||||||
| "\n" | "\n" | ||||||
| @@ -65,6 +65,7 @@ usage () | |||||||
| "\n" | "\n" | ||||||
| "Default locale information:\n" | "Default locale information:\n" | ||||||
| "\n" | "\n" | ||||||
|  | "  -i, --input          Print current input locale\n" | ||||||
| "  -u, --user           Print locale of user's default UI language\n" | "  -u, --user           Print locale of user's default UI language\n" | ||||||
| "  -s, --system         Print locale of system default UI language\n" | "  -s, --system         Print locale of system default UI language\n" | ||||||
| "  -f, --format         Print locale of user's regional format settings\n" | "  -f, --format         Print locale of user's regional format settings\n" | ||||||
| @@ -93,6 +94,7 @@ struct option longopts[] = { | |||||||
|   {"category-name", no_argument, NULL, 'c'}, |   {"category-name", no_argument, NULL, 'c'}, | ||||||
|   {"format", no_argument, NULL, 'f'}, |   {"format", no_argument, NULL, 'f'}, | ||||||
|   {"help", no_argument, NULL, 'h'}, |   {"help", no_argument, NULL, 'h'}, | ||||||
|  |   {"input", no_argument, NULL, 'i'}, | ||||||
|   {"keyword-name", no_argument, NULL, 'k'}, |   {"keyword-name", no_argument, NULL, 'k'}, | ||||||
|   {"charmaps", no_argument, NULL, 'm'}, |   {"charmaps", no_argument, NULL, 'm'}, | ||||||
|   {"no-unicode", no_argument, NULL, 'n'}, |   {"no-unicode", no_argument, NULL, 'n'}, | ||||||
| @@ -103,7 +105,7 @@ struct option longopts[] = { | |||||||
|   {"version", no_argument, NULL, 'V'}, |   {"version", no_argument, NULL, 'V'}, | ||||||
|   {0, no_argument, NULL, 0} |   {0, no_argument, NULL, 0} | ||||||
| }; | }; | ||||||
| const char *opts = "acfhkmnsuUvV"; | const char *opts = "acfhikmnsuUvV"; | ||||||
|  |  | ||||||
| int | int | ||||||
| getlocale (LCID lcid, char *name) | getlocale (LCID lcid, char *name) | ||||||
| @@ -786,6 +788,9 @@ main (int argc, char **argv) | |||||||
|       case 'm': |       case 'm': | ||||||
| 	maps = 1; | 	maps = 1; | ||||||
| 	break; | 	break; | ||||||
|  |       case 'i': | ||||||
|  | 	lcid = (UINT_PTR) GetKeyboardLayout (0) & 0xffff; | ||||||
|  | 	break; | ||||||
|       case 's': |       case 's': | ||||||
| 	lcid = GetSystemDefaultUILanguage (); | 	lcid = GetSystemDefaultUILanguage (); | ||||||
| 	break; | 	break; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user