以前的开发平台里,是用xml语言包实现了多语言功能,现在新的平台里进行了调整,把多语言包资源放在数据库表里实现了。
我们系统预留了多语言的配置全局变量、可以通过配置这个参数达到切换多语言的目的
我们在选项管理里增加一个多语言选择的选项目,然后有哪些语言资源就加上去
下面的表是多语言的数据库设计表结构
下面图是多语言的数据库里的资源设置情况
这个是多语言的设置管理界面参考
下面是多语言的管理窗体位置
多语言例子程序参考:
/// <summary> /// 获取多语言 /// </summary> public void GetLanguage() { this.grbLanguage.Text = this.GetLanguage(this.grbLanguage); this.lblLanguageCode.Text = this.GetLanguage(this.lblLanguageCode) + ":"; this.lblMessageCode.Text = this.GetLanguage(this.lblMessageCode) + ":"; this.lblCaption.Text = this.GetLanguage(this.lblCaption) + ":"; this.btnAdd.Text = this.GetLanguage(this.btnAdd); this.btnSave.Text = this.GetLanguage(this.btnSave); this.btnCancel.Text = this.GetLanguage(this.btnCancel); } public string GetLanguage(Control control) { string result = string.Empty; string key = this.Name + "." + control.Name; string caption = control.Text; result = ClientCache.Instance.GetLanguage(this.UserInfo, key, BaseSystemInfo.CurrentLanguage, caption); return result; }
多语言接口程序参考:
//----------------------------------------------------------------- // All Rights Reserved , Copyright (C) 2015 , Hairihan TECH, Ltd. //----------------------------------------------------------------- using System.Data; using System.ServiceModel; using System.Collections.Generic; namespace DotNet.IService { using DotNet.Utilities; using DotNet.Model; /// <summary> /// ILanguageService /// 多语言接口 /// /// 修改纪录 /// /// 2015.02.24 版本:1.0 JiRiGaLa 创建主键。 /// /// <author> /// <name>JiRiGaLa</name> /// <date>2015.02.24</date> /// </author> /// </summary> [ServiceContract] public interface ILanguageService { /// <summary> /// 获取实体 /// </summary> /// <param name="userInfo">用户</param> /// <param name="id">主键</param> /// <returns>实体</returns> [OperationContract] BaseLanguageEntity GetObject(BaseUserInfo userInfo, string id); /// <summary> /// 添加 /// </summary> /// <param name="userInfo">用户</param> /// <param name="entity">实体</param> /// <param name="statusCode">返回状态码</param> /// <param name="statusMessage">返回状态信息</param> /// <returns>主键</returns> [OperationContract] string Add(BaseUserInfo userInfo, BaseLanguageEntity entity, out string statusCode, out string statusMessage); /// <summary> /// 编辑 /// </summary> /// <param name="userInfo">用户</param> /// <param name="entity">实体</param> /// <param name="statusCode">返回状态码</param> /// <param name="statusMessage">返回状态信息</param> /// <returns>影响行数</returns> [OperationContract] int Update(BaseUserInfo userInfo, BaseLanguageEntity entity, out string statusCode, out string statusMessage); /// <summary> /// 设置多语言 /// </summary> /// <param name="userInfo">用户</param> /// <param name="messageCode">语言编号</param> /// <param name="enUS">英文</param> /// <param name="zhCN">简体中文</param> /// <param name="zhTW">繁体中文</param> /// <returns>影响行数</returns> [OperationContract] int SetLanguage(BaseUserInfo userInfo, string messageCode, string enUS, string zhCN, string zhTW); /// <summary> /// 按编号获取多语言 /// </summary> /// <param name="userInfo">用户</param> /// <param name="messageCode">语言编号</param> /// <returns>列表</returns> List<BaseLanguageEntity> GetLanguageByMessageCode(BaseUserInfo userInfo, string messageCode); /// <summary> /// 批量打删除标志 /// </summary> /// <param name="userInfo">用户</param> /// <param name="ids">主键数组</param> /// <returns>影响行数</returns> [OperationContract] int SetDeleted(BaseUserInfo userInfo, string[] ids); /// <summary> /// 批量保存 /// </summary> /// <param name="userInfo">用户</param> /// <param name="list">列表</param> /// <returns>影响行数</returns> [OperationContract] int BatchSave(BaseUserInfo userInfo, List<BaseLanguageEntity> list); } }