标签:
DevExpress是一个比较有名的界面控件套件,提供了一系列的界面控件套件的DotNet界面控件。对于较老的版本(例如之前项目中遇到的dev9),对于汉化(应该说本地化Localization)支持较少。高版本接触较少,不知道后续版本(dev13之后)对于本地化的支持怎么样,所以不做讨论。
static void Main() { DevExpress.XtraEditors.Controls.Localizer.Active = new LocalizationCHS(); DevExpress.XtraGrid.Localization.GridLocalizer.Active = new XtraGrid_CN(); DevExpress.XtraBars.Localization.BarLocalizer.Active = new XtraBar_CN(); }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DevExpress.XtraGrid.Localization; using DevExpress.XtraBars.Localization; namespace RNDManagementSys { public class LocalString { public LocalString() { GridLocalizer.Active = new XtraGrid_CN(); } } #region gridcontrol本地汉化 public class XtraGrid_CN : GridLocalizer { public override string Language { get { return "简体中文"; } } public override string GetLocalizedString(GridStringId id) { switch (id) { case GridStringId.CardViewNewCard: return "新卡片"; case GridStringId.CardViewQuickCustomizationButton: return "自定义格式"; case GridStringId.CardViewQuickCustomizationButtonFilter: return "筛选"; case GridStringId.CardViewQuickCustomizationButtonSort: return "排序"; case GridStringId.ColumnViewExceptionMessage: return "是否确定修改?"; case GridStringId.CustomFilterDialog2FieldCheck: return "字段"; case GridStringId.CustomFilterDialogCancelButton: return "取消"; case GridStringId.CustomFilterDialogCaption: return "条件为:"; case GridStringId.CustomFilterDialogConditionBlanks: return "空值"; case GridStringId.CustomFilterDialogConditionEQU: return "等于="; case GridStringId.CustomFilterDialogConditionGT: return "大于>"; case GridStringId.CustomFilterDialogConditionGTE: return "大于或等于>="; case GridStringId.CustomFilterDialogConditionLike: return "包含"; case GridStringId.CustomFilterDialogConditionLT: return "小于<"; case GridStringId.CustomFilterDialogConditionLTE: return "小于或等于>="; case GridStringId.CustomFilterDialogConditionNEQ: return "不等于<>"; case GridStringId.CustomFilterDialogConditionNonBlanks: return "非空值"; case GridStringId.CustomFilterDialogConditionNotLike: return "不包含"; case GridStringId.CustomFilterDialogFormCaption: return "清除筛选条件(&L)"; case GridStringId.CustomFilterDialogOkButton: return "确定(&O)"; case GridStringId.CustomFilterDialogRadioAnd: return "和(&A)"; case GridStringId.CustomFilterDialogRadioOr: return "或者(&O)"; case GridStringId.CustomizationBands: return "分区"; case GridStringId.CustomizationCaption: return "自定义显示字段"; case GridStringId.CustomizationColumns: return "列"; case GridStringId.FileIsNotFoundError: return "文件{0}没找到!"; case GridStringId.GridGroupPanelText: return "拖曳一列页眉在此进行排序"; case GridStringId.GridNewRowText: return "单击这里新增一行"; case GridStringId.GridOutlookIntervals: return "一个月以上;上个月;三周前;两周前;上周;;;;;;;;昨天;今天;明天; ;;;;;;;下周;两周后;三周后;下个月;一个月之后;"; case GridStringId.MenuColumnBestFit: return "自动调整字段宽度"; case GridStringId.MenuColumnBestFitAllColumns: return "自动调整所有字段宽度"; case GridStringId.MenuColumnClearFilter: return "清除筛选条件"; case GridStringId.MenuColumnColumnCustomization: return "显示/隐藏字段"; case GridStringId.MenuColumnFilter: return "筛选"; case GridStringId.MenuColumnGroup: return "按此列分组"; case GridStringId.MenuColumnGroupBox: return "分组区"; case GridStringId.MenuColumnSortAscending: return "升序排序"; case GridStringId.MenuColumnSortDescending: return "降序排序"; case GridStringId.MenuColumnUnGroup: return "取消分组"; case GridStringId.MenuFooterAverage: return "平均"; case GridStringId.MenuFooterAverageFormat: return "平均={0:#.##}"; case GridStringId.MenuFooterCount: return "计数"; case GridStringId.MenuFooterCountFormat: return "{0}"; case GridStringId.MenuFooterMax: return "最大值"; case GridStringId.MenuFooterMaxFormat: return "最大值={0}"; case GridStringId.MenuFooterMin: return "最小"; case GridStringId.MenuFooterMinFormat: return "最小值={0}"; case GridStringId.MenuFooterNone: return "没有"; case GridStringId.MenuFooterSum: return "合计"; case GridStringId.MenuFooterSumFormat: return "求和={0:#.##}"; case GridStringId.MenuGroupPanelClearGrouping: return "取消所有分组"; case GridStringId.MenuGroupPanelFullCollapse: return "收缩全部分组"; case GridStringId.MenuGroupPanelFullExpand: return "展开全部分组"; case GridStringId.PopupFilterAll: return "(所有)"; case GridStringId.PopupFilterBlanks: return "(空值)"; case GridStringId.PopupFilterCustom: return "(自定义)"; case GridStringId.PopupFilterNonBlanks: return "(非空值)"; case GridStringId.PrintDesignerBandedView: return "打印设置(区域模式)"; case GridStringId.PrintDesignerBandHeader: return "区标题"; case GridStringId.PrintDesignerCardView: return "打印设置(卡片模式)"; case GridStringId.PrintDesignerDescription: return "为当前视图设置不同的打印选项."; case GridStringId.PrintDesignerGridView: return "打印设置(表格模式)"; case GridStringId.WindowErrorCaption: return "错误"; case GridStringId.MenuColumnFilterEditor: return "过滤编辑"; case GridStringId.MenuColumnRemoveColumn: return "移除列"; case GridStringId.MenuColumnResetGroupSummarySort: return "重置排序"; case GridStringId.MenuColumnClearSorting: return "清除排序"; case GridStringId.FilterBuilderApplyButton: return "应用"; case GridStringId.FilterBuilderCancelButton: return "取消"; case GridStringId.FilterBuilderOkButton: return "确定"; case GridStringId.FilterPanelCustomizeButton: return "自定义"; case GridStringId.FilterBuilderCaption: return "筛选编辑"; case GridStringId.CustomFilterDialogEmptyValue: return "空值"; case GridStringId.CustomFilterDialogEmptyOperator: return "操作"; } return base.GetLocalizedString(id); } } #endregion #region public class XtraBar_CN : BarLocalizer { public override string Language { get { return "简体中文"; } } public override string GetLocalizedString(BarString id) { switch (id) { case BarString.AddOrRemove: return "新增或删除按钮(&A)"; case BarString.CustomizeButton: return "自定义(&C)"; case BarString.CustomizeWindowCaption: return "自定义"; case BarString.MenuAnimationFade: return "减弱"; case BarString.MenuAnimationNone: return "空"; case BarString.MenuAnimationRandom: return "任意"; case BarString.MenuAnimationSlide: return "滑动"; case BarString.MenuAnimationSystem: return "(系统默认值)"; case BarString.MenuAnimationUnfold: return "展开"; case BarString.NewToolbarCaption: return "新建工具栏"; case BarString.None: return "空"; case BarString.RenameToolbarCaption: return "重新命名"; case BarString.ResetBar: return "是否确实要重置对 ‘{0}‘ 工具栏所作的修改?"; case BarString.ResetBarCaption: return "自定义"; case BarString.ResetButton: return "重设工具栏(&R)"; case BarString.ToolBarMenu: return "重设(&R)$删除(&D)$!命名(&N)$!标准(&L)$总使用文字(&T)$在菜单中只用文字(&O)$图像与文本(&A)$!开始一组(&G)$常用的(&M)"; case BarString.ToolbarNameCaption: return "工具栏名称(&T):"; case BarString.NewMenuName: return "主菜单"; //case BarString.: return ""; } return base.GetLocalizedString(id); } } #endregion }
上面是项目中针对常用的控件Grid以及Toolbar为例,进行的汉化,dev版本是dev9.15。对于其他版本,id的枚举值都会不同,所以因版本而已,但主体是相同的。根据英文,然后修改成相应中文,推荐一个比较好的网站 http://devlocalization.codeplex.com/SourceControl/latest ,上面汉化的比较完整,可以根据需要本地化相应的控件。
标签:
原文地址:http://www.cnblogs.com/kepton/p/4643988.html