Detect if any right-to-left language is installed

大城市里の小女人 提交于 2019-12-02 10:39:20

问题


What is the easiest way to detect whether any right-to-left language is installed on the host Windows OS?

(I need this in order to know if LTR marks will be displayed as squares, or work properly on the host OS)


回答1:


Probably unmanaged API like IsValidLanguageGroup, IsValidLocaleName (or IsValidLocale) or IsValidCodePage is what you are looking for

For example the code

if (IsValidLanguageGroup (LGRPID_ARABIC, LGRPID_INSTALLED) ||
    IsValidLanguageGroup (LGRPID_TURKIC, LGRPID_INSTALLED) || 
    IsValidLanguageGroup (LGRPID_HEBREW, LGRPID_INSTALLED)) {
    // RTL is supported 
}

can be used to test whether you have at least one from two most known right-to-left (RTL) languages installed on the windows computer. I don't know the corresponding .NET API, but probably CultureInfo.GetCultures could be used in your case.

UPDATED: I included Thai language group in the list of language groups for testing, but I am not sure, that any of this languages you really need. Typically you application supports only selected languages.



来源:https://stackoverflow.com/questions/3434234/detect-if-any-right-to-left-language-is-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!