問題描述
我需要一些關于本地化的信息.我正在使用帶有 C# 2.0 的 .net 2.0,它處理了大部分與本地化相關的問題.但是,我需要在一個特定的屏幕上手動繪制與當前文化相對應的字母表.
I need some information about localization. I am using .net 2.0 with C# 2.0 which takes care of most of the localization related issues. However, I need to manually draw the alphabets corresponding to the current culture on the screen in one particular screen.
這類似于 Microsoft Outlook 中的聯系人屏幕(聯系人下的地址卡視圖或詳細地址卡視圖),因此它需要在右端有一列按鈕,每個字母對應一個.
This would be similar to the Contacts screen in Microsoft Outlook (Address Cards view or Detailed Address Cards View under Contacts), and so it needs a the column of buttons at the right end, one for each alphabet.
我試圖模仿它,但我不想讓用戶選擇腳本.如果說現在的文化是中文,我想畫中文字母.當用戶將文化信息更改為英語時(以及當他重新啟動應用程序時),我想改為繪制英文字母.希望您了解我將使用此查詢的去向.
I am trying to emulate that, but I don't want to ask the user to choose the script. If the current culture is say, Chinese, I want to draw Chinese alphabets. When the user changes the culture info to English (and when he restarts the application) I want to draw English alphabets instead. Hope you understand where I am going with this query.
我可以確定當前用戶的文化(Application.CurrentCulture 或 System.Globalization.CultureInfo.CurrentCulture 會給出文化相關的信息).我也有所有的腳本來呈現字母.但是,問題是我不知道如何將文化信息映射到腳本的名稱.
I can determine the culture of the current user (Application.CurrentCulture or System.Globalization.CultureInfo.CurrentCulture will give the culture related information). I also have all the scripts to render the alphabets. However, the problem is that I don't know how to map the culture info to the name of a script.
換句話說,有沒有辦法確定與文化對應的腳本名稱?或者是否可以確定與文化對應的 Unicode 字符值的范圍?它們中的任何一個都可以讓我正確呈現按鈕上的字母.
In other words, is there a way to determine the script name corresponding to a culture? Or is it possible to determine the range of Unicode character values corresponding to a culture? Either of them would allow me to render the alphabets on the button properly.
非常感謝您對此提出任何建議或指導.如果我的方法(或我試圖實現的目標)存在根本性錯誤,請同時指出.謝謝你的時間.
Any suggestions or guidance regarding this is truly appreciated. If there is something fundamentally wrong with my approach (or with what I am trying to achieve), please point out that as well. Thanks for your time.
PS:我知道最簡單的解決方案是將腳本名稱配置為用戶首選項的一部分,或者顯示一個語言列表供用戶選擇(如 Outlook 2007 中的聯系人).但我只是想看看我是否可以在用戶不必做任何事情的情況下呈現與文化相對應的字母表.
PS: I know the easiest solution is to either configure the script name as part of user preferences or display a list of languages for the user to choose from (a la Contact in Outlook 2007). But I am just trying to see whether I can render the alphabets corresponding to the culture without the user having to do anything.
推薦答案
在本機代碼中,GetLocaleInfoEx()(Vista 及以上)的 LOCALE_SSCRIPTS 向您顯示語言環境需要哪些腳本..Net 目前還沒有類似的概念.
In native code there's LOCALE_SSCRIPTS for GetLocaleInfoEx() (Vista & above) that shows you what scripts are expected for a locale. There isn't a similar concept for .Net at this time.
這篇關于本地化:如何將文化信息映射到腳本名稱或 Unicode 字符范圍?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!