c#桌面应用程序里的多语言编程

 

 

 

 

 

 

 

 

首先新建一个项目languageInfo:接着新建一个AppConfig.xml文件

 

<?xml version="1.0" encoding="utf-8" ?>

<AppConfig>

  <Area>

    <Language>ZH</Language>

    <List>

      <Item>中文[ZH]</Item>

      <Item>英文[EN]</Item>

      <Item>繁体[TH]</Item>

    </List>

  </Area>

  <Area>

    <Language>EN</Language>

    <List>

      <Item>Chinese[ZH]</Item>

      <Item>English[EN]</Item>

      <Item>Traditional[TH]</Item>

    </List>

  </Area>

  <Area>

    <Language>TH</Language>

    <List>

      <Item>中文[ZH]</Item>

      <Item>英文[EN]</Item>

      <Item>繁體[TH]</Item>

    </List>

  </Area>

</AppConfig>

 

 

接着再建一个

AppResource_EN.xml

 

<?xml version="1.0" encoding="utf-8" ?>

<Resource>

  <Form>

    <Name>frmlogon</Name>

    <Controls>

      <Control name="frmlogon" text="User logon"></Control>

      <Control name="lblusername" text="Username:"></Control>

      <Control name="lblpassword" text="Password:"></Control>

      <Control name="lbllanguage" text="Language:"></Control>

      <Control name="btnlogon" text="Logon"></Control>

      <Control name="btncancel" text="Exit"></Control>

      <Control name="btnchangepwd" text="Change Password"></Control>

    </Controls>

  </Form>

  <Form>

    <Name>FrmPasswordChange</Name>

    <Controls>

      <Control name="frmpasswordchange" text="Change

 

password"></Control>

      <Control name="lblusername" text="Username:"></Control>

      <Control name="lblpassword" text="Old Password:"></Control>

      <Control name="lblnewpassword" text="New Password:"></Control>

      <Control name="lblpasswordconfirm" text="Password

 

Confirm:"></Control>

      <Control name="btnok" text="OK"></Control>

      <Control name="btncancel" text="Return"></Control>  

    </Controls>

  </Form>

  <Form>

    <Name>SecondForm</Name>

    <Controls>

      <Control name="SecondForm" text="Second Form"></Control>

      <Control name="dgvSeconder" text="dgvSeconder"></Control>    

    </Controls>

  </Form>

  <Form>

    <Name>dgvSeconder</Name>

    <Controls>

      <Control name="ID" text="ID"></Control>

      <Control name="NAME" text="NAME"></Control>    

    </Controls>

  </Form>

</Resource>

 

AppResource_TH.xml

 

<?xml version="1.0" encoding="utf-8" ?>

<Resource>

  <Form>

    <Name>frmlogon</Name>

    <Controls>

      <Control name="frmlogon" text="登錄"></Control>

      <Control name="lblusername" text="用戶名:"></Control>

      <Control name="lblpassword" text="  :"></Control>

      <Control name="lbllanguage" text="  :"></Control>

      <Control name="btnlogon" text="  "></Control>

      <Control name="btncancel" text="退  "></Control>

      <Control name="btnchangepwd" text="更改密碼"></Control>

    </Controls>

  </Form>

  <Form>

    <Name>FrmPasswordChange</Name>

    <Controls>

      <Control name="frmpasswordchange" text="更改密码"></Control>

      <Control name="lblusername" text="用戶名:"></Control>

      <Control name="lblpassword" text="舊密碼:"></Control>

      <Control name="lblnewpassword" text="新密碼:"></Control>

      <Control name="lblpasswordconfirm" text="  "></Control>

      <Control name="btnok" text="  "></Control>

      <Control name="btncancel" text="  "></Control>

    </Controls>

  </Form>

  <Form>

    <Name>SecondForm</Name>

    <Controls>

      <Control name="SecondForm" text="第二窗體"></Control>

      <Control name="dgvSeconder" text="數據表格"></Control>    

    </Controls>

  </Form>

  <Form>

    <Name>dgvSeconder</Name>

    <Controls>

      <Control name="ID" text="序號"></Control>

      <Control name="NAME" text="姓名"></Control>

    </Controls>

  </Form>

</Resource>

 

 

AppResource_ZH.xml

 

<?xml version="1.0" encoding="utf-8" ?>

<Resource>

  <Form>

    <Name>frmlogon</Name>

    <Controls>

      <Control name="frmlogon" text="登录"></Control>

      <Control name="lblusername" text="用户名:"></Control>

      <Control name="lblpassword" text="  :"></Control>

      <Control name="lbllanguage" text="  :"></Control>

      <Control name="btnlogon" text="  "></Control>

      <Control name="btncancel" text="退  "></Control>

      <Control name="btnchangepwd" text="更改密码"></Control>

    </Controls>

  </Form>

  <Form>

    <Name>FrmPasswordChange</Name>

    <Controls>

      <Control name="frmpasswordchange" text="更改密码"></Control>

      <Control name="lblusername" text="用户名:"></Control>

      <Control name="lblpassword" text="旧密码:"></Control>

      <Control name="lblnewpassword" text="新密码:"></Control>

      <Control name="lblpasswordconfirm" text="  "></Control>

      <Control name="btnok" text="  "></Control>

      <Control name="btncancel" text="  "></Control>

    </Controls>

  </Form>

  <Form>

    <Name>SecondForm</Name>

    <Controls>

      <Control name="SecondForm" text="第二窗体"></Control>

      <Control name="dgvSeconder" text="数据表格"></Control>    

    </Controls>

  </Form>

  <Form>

    <Name>dgvSeconder</Name>

    <Controls>

      <Control name="ID" text="序号"></Control>

      <Control name="NAME" text="姓名"></Control>

    </Controls>

  </Form>

</Resource>

 

 

接着定义一个窗体

frmlogon.cs

LanguageDefine.xml

PublishClass.cs

SecondForm.cs

Test.cs

后续的类如有需要者请联系

QQ:383638323

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CPU_2

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值