无法在c#中更改输入语言 [英] Unable to change input language in c#

查看:108
本文介绍了无法在c#中更改输入语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!我正在制作多语言打字导师,并希望从代码中更改输入语言,但语言不在语言栏上(它们安装在操作系统中,但我只在语言栏中显示英语)我尝试了下面的代码,但它没有'工作..

hi all! I am making Multilingual typing tutor and want to change input language from code, but the languages are NOT on the language bar (they are installed in the OS but i only have English showing in language bar) I tried the following code but it didn't work..

System.Globalization.CultureInfo my_culture = new System.Globalization.CultureInfo("fr-FR");
InputLanguage c = InputLanguage.FromCulture(my_culture);
InputLanguage.CurrentInputLanguage = c;



请注意,我不希望最终用户首先在语言栏中获取这些语言然后工作..在此case,我想输入法语但我无法这样做..请帮帮我朋友!


Note that I do not want the end-user to first get those languages in language bar and then work.. In this case, I want to type in french but I'm unable to do so.. Please help me friends!

推荐答案

它与输入语言无关。输入语言应由用户选择,并且仅由用户选择。这是由系统中的国际设置控制面板小程序完成的。用户可以添加一种或多种语言并定义切换方式。还有输入法这样的东西,对于有太多字符或多种书写系统的文化特别重要,比如日语。



背景:你明白这种Windows方法(以及几乎所有现代操作系统的方法)是完全正确的吗?使用Unicode,用户可以使用任何语言输入数据,无论应用程序的文化是什么。该文化主要用于以某种语言呈现UI(阅读与此主题相关的附属程序集),以表示日期/时间,派系数字等的不同格式。如果你从英语切换到法语,在两种情况下,什么应该阻止我用西里尔语写数据?没有。这些事情是无关的,应该是无关的。 (除非你的目的是完全搞砸用户的工作:-)。)



-SA
It has nothing to do with input languages. The input language should be chosen by the user and only by the user. This is done by International Settings Control Panel applet in the system. The user can add one or more languages and define the way they are toggles. There is also such thing as "Input method", something of particular importance for cultures with too many characters or multiple writing system, like in Japanese.

For a background: do you understand that this Windows approach (and also the approach of nearly all modern OS) is perfectly correct? With Unicode, the user can enter data in any language, no matter what is the culture of application. The culture is primarily used to present UI in certain language (read about satellite assemblies related to this topic), to represent different formats for date/time, factional numbers and so on. If you switch from English to French, what should prevent me from writing data in Cyrillic on both cases? Nothing. These things are unrelated and should be unrelated. (Unless you aim to screw up user's work completely :-).)

—SA


我认为您缺少的是设置当前线程的文化:
I think what you are missing is setting the Culture of the current Thread:
System.Threading.Thread.CurrentThread.CurrentCulture = my_culture;

查看Felipe Vaz的博客条目Localizable C#中的表单或如何以正确的方式翻译您的C#应用​​程序:[ ^ ]。

Check out Felipe Vaz' blog entry "Localizable forms in C# or How to translate your C# application in the right way:" [^].


这篇关于无法在c#中更改输入语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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