资源文件使用&多语言切换方法

 1、使用资源文件前,初始控件方法



 

2、使用资源文件后,初始控件方法

      语言切换方法:在Form的属性中,Localizable设为True,表示当前为对象生成可本地化的代码,再相应的选择Language属性,对窗体进行重新赋值为相应语言的版本,此时要注意在程序中的文本部分要获取当地语言信息,进行判断运行过程中显示哪个国家的语言。


 

3、在程序运行过程中设置语言的方法:

System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("en", False)    '设置EN环境
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en")  '设置EN环境
Dim res As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(RPG_Server))
res.ApplyResources(Me, "$this")
res.ApplyResources(Me.btnBuildUpdateLink, "btnBuildUpdateLink")
res.ApplyResources(Me.mnuSet_WriteFlashType_AMFW, "mnuSet_WriteFlashType_AMFW")
………………

4、在启动时的选择,根据系统的当前区域配置,自动适应语言:

Public Sub New()
Dim gstrAppCulture As String
Dim tenmDialogResult As DialogResult
tenmDialogResult = MessageBox.Show("请选择语言", _
MessageBoxButtons.OKCancel, MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
If tenmDialogResult = Windows.Forms.DialogResult.OK Then
    gstrAppCulture = "zh-tw"
Else
    gstrAppCulture = "en"
End If
System.Threading.Thread.CurrentThread.CurrentUICulture = _
New System.Globalization.CultureInfo(gstrAppCulture, False) ‘人为选择
‘System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture  ’自动选择,根据当前语言环境
InitializeComponent() ’在这个过程中已经调用正确的资源文件
End Sub


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值