public static void WebControlsLocalization(System.Web.SessionState.HttpSessionState session, ControlCollection ctrls) { //System.Globalization.CultureInfo ci = GetSessionUICultureInfo(session); //System.Threading.Thread.CurrentThread.CurrentUICulture;//HROne.Common.WebUtility.GetSessionCultureInfo(session); //WebControlsLocalization(ctrls, ci); ////initLanguage(session); LocalizationProcess localizationProcess = new LocalizationProcess(GetDatabaseConnection(session), GetSessionUICultureInfo(session)); localizationProcess.WebControlsLocalization(ctrls); }
//private static void WebControlsLocalization(ControlCollection ctrls, System.Globalization.CultureInfo ci) //{ // foreach (Control ctrl in ctrls) // { // if (ctrl is WebControl) // { // WebControlLocalization((WebControl)ctrl, ci); // } // if (ctrl.Controls != null) // if (ctrl.Controls.Count > 0) // WebControlsLocalization(ctrl.Controls, ci); // } //} //private static void WebControlLocalization(WebControl ctrl, System.Globalization.CultureInfo ci) //{ // System.Resources.ResourceManager rm = AppUtils.getResourceManager(); // if (ctrl is ListControl) // { // foreach (ListItem item in ((ListControl)ctrl).Items) // { // string originalString = item.Attributes["OriginalText"]; // if (string.IsNullOrEmpty(originalString)) // { // originalString = item.Text; // } // //else // //{ // // // Dummy, for adding breakpoint only // // originalString = originalString; // //} // if (!string.IsNullOrEmpty(originalString.Trim())) // { // string newString = rm.GetString(originalString, ci); // if (!string.IsNullOrEmpty(newString)) // item.Text = newString; // else // { // newString = rm.GetString(originalString.Trim(), ci); // if (!string.IsNullOrEmpty(newString)) // item.Text = newString; // else // { // // temporily unuse or will change debug mode by config file since multiple database issue // //if (HROne.Lib.Entities.ESystemParameter.getParameter("DebugMode").Equals("Y")) // // CreateUnTranslateRecord(originalString, ci.Name); // //continue; // } // } // item.Attributes.Add("OriginalText", originalString); // } // } // } // //else if (ctrl is Repeater) // //{ // // Repeater repeaterControl = (Repeater)ctrl; // // foreach (RepeaterItem item in repeaterControl.Items) // // WebControlsLocalization(session, item.Controls); // //} // else if (!(ctrl is TextBox)) // { // System.Reflection.PropertyInfo propInfo = ctrl.GetType().GetProperty("Text"); // if (propInfo == null) // propInfo = ctrl.GetType().GetProperty("ToolTip"); // if (propInfo != null) // { // string originalString = ((WebControl)ctrl).Attributes["OriginalText"]; // if (string.IsNullOrEmpty(originalString)) // { // originalString = propInfo.GetValue(ctrl, null).ToString(); // } // //else // //{ // // // Dummy, for adding breakpoint only // // originalString = originalString; // //} // if (!string.IsNullOrEmpty(originalString.Trim())) // { // string newString = rm.GetString(originalString, ci); // if (!string.IsNullOrEmpty(newString)) // propInfo.SetValue(ctrl, newString, null); // else // { // newString = rm.GetString(originalString.Trim(), ci); // if (!string.IsNullOrEmpty(newString)) // propInfo.SetValue(ctrl, newString, null); // else // { // // temporily unuse or will change debug mode by config file since multiple database issue // //if (HROne.Lib.Entities.ESystemParameter.getParameter("DebugMode").Equals("Y")) // // CreateUnTranslateRecord(originalString, ci.Name); // //return; // } // } // ((WebControl)ctrl).Attributes.Add("OriginalText", originalString); // } // } // } //} public static void MenuLocalization(Menu menu) { //CultureInfo ci = GetSessionUICultureInfo(menu.Page.Session); //foreach (MenuItem menuItem in menu.Items) // MenuItemLocalization(menuItem, ci); LocalizationProcess localizationProcess = new LocalizationProcess(GetDatabaseConnection(menu.Page.Session), GetSessionUICultureInfo(menu.Page.Session)); localizationProcess.MenuLocalization(menu); }