转换页面的语言 [英] Convert the language of the page

查看:141
本文介绍了转换页面的语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道我的代码无法正常工作?我到处都是英文字符串。



注意,这不是一个ASP.NET项目,而是一个真正的WinForms项目。



我已经设置了一个Windows窗体项目来使用本地化,以便它支持阿拉伯语和英语。



Does anyone have an idea why my code is not working? I get English strings everywhere.

Note that is not an ASP.NET project but an actual WinForms project.

I have set up a windows forms project to use localization so that it will support Arabic and English languages.

Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

       Admin admin = new Admin();
       this.Close();
       admin.Show();

Thread.CurrentThread.CurrentUICulture = new CultureInfo("ar-KW");

       Admin admin = new Admin();
       this.Close();
       admin.Show();





我的尝试:





What I have tried:

Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
       this.Controls.Clear();
       this.RightToLeftLayout = false;
       InitializeComponent();
       Properties.Settings.Default["lang"] = "en-US";
       Properties.Settings.Default.Save();

           Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-KW");
       this.Controls.Clear();
       InitializeComponent();
       Properties.Settings.Default["lang"] = "ar-KW";
       Properties.Settings.Default.Save();











and

var ChangLanuguage = new Changelanguage();
           ChangLanuguage.Updateconfig("language", "ar-KW");
           Application.Restart();







private void ChangeLanguage(string lang)
        {
            foreach (Control c in this.Controls)
            {
                ComponentResourceManager resources = new ComponentResourceManager(typeof(Admin));
                resources.ApplyResources(c, c.Name, new CultureInfo(lang));
            }
        }














and

private void metroTile58_Click(object sender, EventArgs e)
       {
           switch(Thread.CurrentThread.CurrentUICulture.IetfLanguageTag)
           {
               case "ar-KW":Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");break;

               case "en-US": Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-KW"); break;
           }
           this.Controls.Clear();
           InitializeComponent();
       }





当我通过开始调试但我设置时测试它是有效的当程序被提取时,它停止工作的应用程序。

推荐答案

Winforms为您更改表单设计的各种语言创建资源文件(更改了字符串和布局等。)



如果你的应用程序在调试模式下运行并且你可以切换语言,那么检查bin\debug文件夹并复制/部署语言文件夹ar或ar-KW以及其他机器上的EXE文件
Winforms creates resource files for various languages you have changed your forms design for (changed the strings and layout etc.).

If your application works in debug mode and you can switch languages, then check the "bin\debug" folder and copy/deploy the language folder "ar" or "ar-KW" along with your EXE file on other machines


这篇关于转换页面的语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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