public IEnumerable <object> GetAllLocaleIds(string resourceSet) { var ids = Manager.GetAllLocaleIds(resourceSet); if (ids == null) { throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "LocaleIdsFailedToLoad") + ":" + Manager.ErrorMessage); } var list = new List <object>(); foreach (string localeId in ids) { CultureInfo ci = CultureInfo.GetCultureInfo(localeId.Trim()); string language = "Invariant"; if (!string.IsNullOrEmpty(localeId)) { language = ci.DisplayName + " (" + ci.Name + ")"; } list.Add(new { LocaleId = localeId, Name = language }); } return(list); }
public JsonResult GetAllLocaleIds(string resourceSet) // public IEnumerable<object> GetAllLocaleIds(string resourceSet) { var ids = Manager.GetAllLocaleIds(resourceSet); if (ids == null) throw new ApplicationException(DbIRes.T("LocaleIdsFailedToLoad", STR_RESOURCESET) + ":" + Manager.ErrorMessage); var list = new List<object>(); foreach (string localeId in ids) { CultureInfo ci = CultureInfo.GetCultureInfo(localeId.Trim()); string language = "Invariant"; if (!string.IsNullOrEmpty(localeId)) language = ci.DisplayName + " (" + ci.Name + ")"; list.Add(new { LocaleId = localeId, Name = language }); } return Json(list,jsonSettings); }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (!User.Identity.IsAuthenticated) { Response.Redirect("/", true); } if (!User.IsInRole("Admin")) { Response.Redirect("/", true); } // *** On callbacks we don't need to populate any data since they are // *** raw method calls. Callback routes to parser from here if (Callback.IsCallback) { return; } Response.Expires = 0; if (!Manager.IsLocalizationTable(null)) { ErrorDisplay.ShowError(WebUtils.LRes("ResourceTableDoesntExist")); btnCreateTable.Visible = true; return; } GetResourceSet(); ListItem[] items = Manager.GetAllResourceIdsForHtmlDisplay(ResourceSet); lstResourceIds.Items.AddRange(items); //DataTable dt = Manager.GetAllResourceIds(ResourceSet); //if (dt == null) //{ // this.ErrorDisplay.ShowError("Couldn't load resources: " + Manager.ErrorMessage); // return; //} //this.lstResourceIds.DataSource = dt; //this.lstResourceIds.DataValueField = "ResourceId"; //this.lstResourceIds.DataBind(); if (lstResourceIds.Items.Count > 0) { lstResourceIds.SelectedIndex = 0; } DataTable dt = Manager.GetAllLocaleIds(ResourceSet); if (dt == null) { ErrorDisplay.ShowError("Couldn't load resources: " + Manager.ErrorMessage); return; } foreach (DataRow row in dt.Rows) { string Code = row["LocaleId"] as string; CultureInfo ci = CultureInfo.GetCultureInfo(Code.Trim()); if (Code != "") { row["Language"] = ci.DisplayName + " (" + ci.Name + ")"; } else { row["Language"] = "Invariant"; } } lstLanguages.DataSource = dt; lstLanguages.DataValueField = "LocaleId"; lstLanguages.DataTextField = "Language"; lstLanguages.DataBind(); if (lstLanguages.Items.Count > 0) { lstLanguages.SelectedIndex = 0; } else { lstLanguages.Items.Add(new ListItem("Invariant", "")); } }