在运行时更改语言
如何在 .net 运行时更改语言?有可能吗? (即英语到印地语或任何其他语言。) 在桌面应用程序中...
How to change language at run time in .net ? It is possible?
(i.e. English to Hindi or any other language.)
in desktop application...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
InitializeComponent()
之前使用以下代码:在 ASP 环境中,您可以使用
Request.UserLanguages[0]
字符串作为语言代码来自动将语言设置为用户的选择。编辑:如果表单已打开,您将必须处理并重新加载它。或者,您可以使用以下代码,这非常不舒服:
根据您组织资源文件的方式,您可以在循环中执行此操作。
edti2:另一种方法是自动重新启动应用程序。根据应用程序,这可能不合适。
edti3:
经常看到的是应用程序告诉用户重新启动应用程序以使更改的设置生效。对于许多用例来说,这与第二次编辑相结合可能是可行的方法。
Use the following code before
InitializeComponent()
:In an ASP-Environment, you may use the
Request.UserLanguages[0]
string as language code to automatically set the language to the users choice.edit: If the form is already opened, you will have to Dispose and reload it. Alternatively, you can use the following code, which is pretty uncomfortable:
Depending on how you organized your ressource files, you may do this in a loop.
edti2: an alternative approach is to restart the application automatically. depending on the application, this might not be suitable.
edti3:
what if often see is that an application tells the user to restart the application in order for the changed settings to take effect. this combined with the second edit is probably the way to go for many use cases.
当然,只有当存在该语言的卫星程序集时,这才会更改语言。
Of course this only changes the language if there are satelite assemblies in that language.