問題描述
我需要一個 .NET 3.5 支持的文化列表,無論使用什么操作系統.這似乎很難獲得,雖然我不知道為什么!
I need a list of cultures that are supported by .NET 3.5, regardless of the OS used. This seems to be quite a struggle to obtain, though I am not sure why!
啊,我不知道它依賴于操作系統,這可以解釋缺乏文檔.關于 Mac/Linux 操作系統也支持什么的任何想法?
Arghh, I was not aware that it is dependent on the OS, that would explain the lack of documentation. Any ideas on what is supported by Mac/Linux OS as well?
謝謝:)
推薦答案
不幸的是,它依賴于操作系統.查看此處了解每個操作系統的默認語言支持.
Unfortunately, it is OS dependent. Check here for default language support per OS.
請注意,CultureInfo 文檔 警告:
Windows 版本或服務包可以更改可用的文化.
Windows versions or service packs can change the available cultures.
在 ASP.NET 中,與操作系統相比,重要的是瀏覽器.它可以通過 Accept-Language (第 14.4 節)請求標頭.如果您將應用的 全球化 配置設置為 enableClientBasedCulture="true", ASP.NET 將嘗試自動將 UICulture 和 Culture 設置為瀏覽器提供的值.或者,您可以通過檢查 Request.UserLanguages 手動設置文化 屬性:
In ASP.NET, it's the browser that's important versus the OS. It can tell you which language the user prefers via the Accept-Language (Section 14.4) request header. If you set your app's globalization configuration to enableClientBasedCulture="true", ASP.NET will try to automatically set the UICulture and Culture to the value provided by the browser. Alternatively, you can set Culture manually by inspecting the Request.UserLanguages property:
- 如何:設置 ASP.NET 網頁全球化的文化和 UI 文化
- Rick Strahl 顯示手動檢測和設置
很遺憾,無法從操作系統或瀏覽器生成詳盡的可能語言列表.最接近的是 IANA 語言子標簽注冊表.這是 RFC 4646 中描述的語言注冊表 - 定義 .NET 的 CultureInfo 標記的文檔.
Unfortunately, there's no way to generate an exhaustive list of possible languages from an OS or browser. The closest thing is the IANA Language Subtag Registry. This is the language registry described in RFC 4646 - the document that defines .NET's CultureInfo tags.
請記住,Request.UserLanguages 中的語言標簽不保證有效.你會想要檢查它們.HTTP 1.1 對 語言標簽 使用較舊的建議,并且有沒有什么能阻止某人在語言標題中發送亂碼.
Keep in mind, language tags in Request.UserLanguages are not guaranteed to be valid. You'll want to check them. HTTP 1.1 uses an older recommendation for language tags and there's nothing stopping someone from sending gibberish in the language header.
這篇關于.NET 3.5 中的 CultureInfo 類支持哪些文化?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!