Esempio n. 1
0
        private void LanguageTransform(Control control, string parentName)
        {
            string controlName = parentName + "." + control.Name;
            Type   type        = control.GetType();
            string typeName    = type.Name;

            if (control is Form)
            {
                typeName = "Form";
            }
            string text = string.Empty;

            switch (typeName)
            {
            case "Form":
            case "Button":
            case "CheckBox":
            case "Label":
            case "LabelControl":
            case "RadioButton":
            case "GroupBox":
            case "SimpleButton":
            case "GroupControl":
            case "XtraTabPage":
            case "LockCheckButton":
            case "StateButton":
            case "CheckEdit":
            case "LinkLabel":
                text = LanguageHelper.GetText(controlName, control.Text);
                if (text != null)
                {
                    control.Text = text;
                }
                break;

            case "GridControl":
                GridControl grid = control as GridControl;
                GridView    gv   = grid.MainView as GridView;
                foreach (GridColumn column in gv.Columns)
                {
                    var columnName = controlName + "." + column.Name;
                    text = LanguageHelper.GetText(columnName, column.Caption);
                    if (text != null)
                    {
                        column.Caption = text;
                    }
                }
                break;

            case "RadioGroup":
                RadioGroup rg = control as RadioGroup;
                for (int i = 0; i < rg.Properties.Items.Count; i++)
                {
                    RadioGroupItem item       = rg.Properties.Items[i];
                    var            columnName = controlName + ".item" + i;
                    text = LanguageHelper.GetText(columnName, item.Description);
                    if (text != null)
                    {
                        item.Description = text;
                    }
                }
                break;

            default:
                break;
            }
            foreach (Control item in control.Controls)
            {
                LanguageTransform(item, parentName);
            }
        }
Esempio n. 2
0
 public static string R(string key, string defaultValue)
 {
     return(LanguageHelper.GetText(key, defaultValue));
 }