Get system locale windows

Как получить системную локаль в Windows 7 cmd?

Как я могу получить системный язык в Windows 7?

Я имею в виду что-то вроде: cs_CZ.UTF-8

Я попытался написать «локаль» в командной строке, но это не работает в Windows. Какие-либо предложения?

Нет конкретной команды (или, по крайней мере, не известной мне) для получения этой информации, но вы можете найти ее между теми, которые предоставляет systeminfo.exe .

Get-UICulture или Get-Host в PowerShell

(заглавная буква необязательна)

Если вам нужен фактический язык для условного выполнения других действий в командном файле, вы можете создать командный файл (сохранить текстовый файл с расширением .bat) с помощью следующего. В качестве отправной точки это выведет в командную строку, например, «en-us» (без кавычек). Вы также можете использовать переменную! VERBOSE_SYSTEM_LOCALE! для удобочитаемого языка, например, английского (UnitedStates)

На самом деле, ваши предложения терпят неудачу, потому что они основаны на поиске строки (« Системная локаль »), которая меняется в зависимости от текущей локали! На моем французском Win10Pro строка » Option régionale du système » (с акцентированной буквой, которую очень трудно правильно обработать в файле CMD).

Я провел некоторое тестирование, и, похоже, в моей системе строки о локали в выходных данных systeminfo — единственные, которые содержат точку с запятой («;»):

Основываясь на этом (что не может быть правдой в других системах с другими языками), я написал этот скрипт get_locale.cmd :

Результат моего скрипта на МОЕЙ системе:

Однако имейте в виду, что три переменные среды существуют только внутри сценария, они НЕ сохраняются в среде CMD после завершения сценария (нет команды экспорта, как в * nix).

Я обнаружил небольшое улучшение в моем сценарии. Используя SETX, можно хранить переменные среды в среде USER для использования в будущем CMD Windows (как указано в SETX /? Второе замечание).

Тогда скрипт get_locale.cmd становится:

Для переменной VERBOSE_SYSTEM_LOCALE, поскольку значение может быть длиной в несколько слов, необходимо заключить %% C в кавычки, чтобы SETX получил только один параметр, как и ожидалось.

Теперь в любом новом окне CMD будут доступны следующие значения:

PS: Было бы неплохо, если бы другие участники из других стран с другими языками могли подтвердить, что ищут точку с запятой ‘;’ работает в своих системах Windows. Заранее спасибо!

Find Current System Locale in Windows 10

As you may already know from previous articles, Windows 10 supports changing the display language using language packs. If you are working in a localized user account in Windows 10 which is your native language, you might be interested in learning what language is used for older apps that doesn’t support Unicode. Here are a number of methods you can use.

Читайте также:  Windows driver kit wdk что это

Windows 10 supports language packs. By installing one or several language packs, you can switch your Windows display language on-the-fly. It is also possible to have a different display language for each user account.

There are plenty of apps that don’t support Unicode. Most of them are apps that have been created for previous Windows versions.

The option that specifies the default language to use for non-Unicode programs is called System Locale. The system locale defines the bitmap fonts and code pages (ANSI or DOS) that are used on the system by default. The system locale setting affects only ANSI (non-Unicode) applications. The language for non-Unicode programs is a per-system setting.

To Find Current System Locale in Windows 10, do the following.

  1. Open Settings.
  2. Go to Time & Language.
  3. On the left, click on Language.
  4. In the right pane, click on the Administrative language settings link.
  5. In the Region dialog, click on the Administrative tab.
  6. You’ll find the current system locale under the Language for non-Unicode programs section.

Alternatively, you can access the same option with the classic Control Panel app. Open the classic Control Panel and navigate to Control Panel\Clock and Region. Click on Region and switch to the Administrative tab.

Another method you can use to find the system locale is a special PowerShell applet, Get-WinSystemLocale.

Find The Current System Locale with PowerShell

  1. Open PowerShell as Administrator.Tip: You can add «Open PowerShell As Administrator» context menu.
  2. Type or copy-paste the following command: Get-WinSystemLocale .

You can also use the classic command prompt to see the current system locale. Here’s how.

Find the System Locale with the Command Prompt

  1. Open a command prompt in Windows 10.
  2. Type or paste the following command: systeminfo .
  3. Besides other useful info, it contains the current OS locale:

Finally, you can find the system locale information in the built-in msinfo32 tool.

Find the System Locale with the System Information app

  1. Press the Win + R hotkeys together on the keyboard and type the following command in your Run box: msinfo32 .
  2. Click the System Summary section on the left.
  3. On the right, see the Locale value.

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

Share this post

About Sergey Tkachenko

Sergey Tkachenko is a software developer from Russia who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

Читайте также:  Полезные службы для принтера windows

1 thought on “ Find Current System Locale in Windows 10 ”

You’re doing a great job.
Keep it up.
Thank you very much.

SystemLocale (microsoft-windows-international-core-winpe-systemlocale)

SystemLocale specifies the default language to use for non-Unicode programs.

This setting is used by both WindowsВ Setup and WindowsВ Deployment Services.

The system locale specifies which bitmap fonts and code pages (for example, ANSI or DOS) are used on the system by default. The system locale setting affects only ANSI applications (non-Unicode) applications. The language for non-Unicode programs is a per-system setting.

Users can change the system locale by using the Administrative tab in the Region and Language Options item in Control Panel.

For the list of supported languages, locales, and identifiers, see Supported Language Packs and Default Settings.

Values

Specifies the locale of the system.

The System_locale string is based on the language-tagging conventions of RFC 3066. The pattern language-region is used, where language is a language code and region is a country or region identifier (for example, en-US, fr-FR, or es-ES).

This value is not case-sensitive.

This string type supports empty elements.

Parent Hierarchy

Valid Configuration Passes

Applies To

For the list of the Windows editions and architectures that this component supports, see microsoft-windows-international-core-winpe—.

XML Example

The following example shows how to set the system locale to English (United States).

GetLocaleInfoA function (winnls.h)

Retrieves information about a locale specified by identifier.

Syntax

Parameters

Locale identifier for which to retrieve information. You can use the MAKELCID macro to create a locale identifier or use one of the following predefined values.

The locale information to retrieve. For detailed definitions, see the LCType parameter of GetLocaleInfoEx.

Pointer to a buffer in which this function retrieves the requested locale information. This pointer is not used if cchData is set to 0. For more information, see the Remarks section.

Size, in TCHAR values, of the data buffer indicated by lpLCData. Alternatively, the application can set this parameter to 0. In this case, the function does not use the lpLCData parameter and returns the required buffer size, including the terminating null character.

Return value

Returns the number of characters retrieved in the locale data buffer if successful and cchData is a nonzero value. If the function succeeds, cchData is nonzero, and LOCALE_RETURN_NUMBER is specified, the return value is the size of the integer retrieved in the data buffer; that is, 2 for the Unicode version of the function or 4 for the ANSI version. If the function succeeds and the value of cchData is 0, the return value is the required size, in characters including a null character, for the locale data buffer.

The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
  • ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.
Читайте также:  Windows 10 20h2 mediacreationtool

Remarks

For the operation of this function, see Remarks for GetLocaleInfoEx.

The ANSI string retrieved by the ANSI version of this function is translated from Unicode to ANSI based on the default ANSI code page for the locale identifier. However, if LOCALE_USE_CP_ACP is specified, the translation is based on the system default ANSI code page.

When the ANSI version of this function is used with a Unicode-only locale identifier, the function can succeed because the operating system uses the system code page. However, characters that are undefined in the system code page appear in the string as a question mark (?).

The winnls.h header defines GetLocaleInfo as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

problems getting locale to execute on command line

If I conduct the below three steps in a English version of Windows 7, the local will execute as desired:

  1. Open the cmd
  2. Go to directory ‘C:\Windows\System32>’
  3. type ‘locale’ into the command line

However, if I do the exact same steps in a Spanish version of Windows 7, I get the following error message:

  • «»locale» no se reconoce como un comando interno o externo, programa o archivo por lotes ejecutable.»

which seems to be translated to English as:

  • ‘xyzRandom’ is not recognized as an internal or external command, operable program or batch file.

I cannot understand why locale will not execute in the Spanish OS. The file, locale.nls does exist in directory C:\Windows\System32> in the Spanish version of Windows so it is not as if the file goes by a different name when using a Spanish os.
Does anyone know why the locale command would not work on the Spanish command line?

2 Answers 2

the locale command was coming from Cygwin, not from cmd. I had Cygwin installed on my Computer and additionally had added c:\cygwin\bin to the PATH environment variable. Therefore, the cmd was picking up the locale command from the Cygwin bin, not from C:\Windows\System32. Once I installed Cygwin onto the machine with the Spanish OS, the locale command operated as expected. The picture below shows typical output from the locale command .

You can change the output of the locale command by changing the value of one of the LC_ variables as shown below .

Оцените статью