Windows 中的语言环境列表 [英] List of locales in Windows

查看:24
本文介绍了Windows 中的语言环境列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 *nix 系统上,您可以执行 locale -a 来获取可用语言环境的列表.

On *nix systems you can do locale -a to get a list of available locales.

Windows 中的等效命令(或操作)是什么?

What is the equivalent command (or action) in Windows?

我在 Internet 上看到过列表,但其中大多数只是区域设置标签,而不是实际的区域设置名称.另外,并非所有系统都保证安装所有系统,对吧?

I've seen lists on the Internet, but most of them are of just locale labels and not actual locale names. Plus, not all systems are guaranteed to have all of them installed, right?

请注意,我在这里对locale"的定义是locale string",即 C 的 setlocale() 的第二个参数,这将导致非 NULL 返回值.

Note that my definition of "locale" here is "locale string", i.e. a second parameter to C's setlocale() which will result in a non-NULL return value.

程序化答案也很好,我只是厌倦了暴力猜测 Windows 语言环境名称.

Programmatic answers are also fine, I'm just tired of brute force guessing Windows locale names.

推荐答案

最初,我找不到 C/Win32 API 来获取信息.(请参阅稍后的编辑.)但是,它看起来像 .NET 类 System.Globalization.CultureInfo 可以提供您需要的信息.特别是,请参阅 CultureInfo.GetCultures().此页面似乎有您正在寻找的完整示例.

Initially, I couldn't find a C/Win32 API to get the information. (See later edit.) However, it looks like the .NET class System.Globalization.CultureInfo could provide the information you need. In particular, see CultureInfo.GetCultures(). This page seems to have a complete example of what you are looking for.

如果您更喜欢 C/Win32 API,请参阅 EnumSystemLocales() 函数.

If you prefer a C/Win32 API, see EnumSystemLocales() function.

编辑 2:此示例显示了如何转换 LCID(其中你从 EnumSystemLocales()) 中得到一个可由 setlocale() 使用的字符串.

EDIT 2: This example shows how to convert an LCID (which you get from EnumSystemLocales()) into a string useable by setlocale().

这篇关于Windows 中的语言环境列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆