public static DataTable GetAll() { DataTable retVal; DataCaching dataCaching = new DataCaching(); string cacheKey = "Main.Languages_GetAll"; retVal = (DataTable)dataCaching.GetCache(cacheKey); if (retVal == null) { retVal = LanguageDB.GetAll(); dataCaching.InsertCacheNoExpireTime(cacheKey, retVal); } return(retVal); }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { this.sLangPath = HttpContext.Current.Request.MapPath("{0}languages".FormatWith(YafForumInfo.ForumServerFileRoot)); if (this.Request.QueryString.GetFirstOrDefault("x") != null) { this.sXmlFile = this.Request.QueryString.GetFirstOrDefault("x"); this.dDLPages.Items.Clear(); LanguageDB.SaveLanguageXMLToFile(Path.Combine(this.sLangPath, this.sXmlFile)); Response.Write("<!--SaveLanguageXMLToFile: " + this.sXmlFile + "-->"); this.PopulateTranslations( Path.Combine(this.sLangPath, "english.xml"), Path.Combine(this.sLangPath, this.sXmlFile)); } if (this.IsPostBack) { return; } this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink("Administration", YafBuildLink.GetLink(ForumPages.admin_admin)); this.PageLinks.AddLink("Language Translator", string.Empty); this.dDLPages.Items.FindByText("DEFAULT").Selected = true; this.lblPageName.Text = "DEFAULT"; if (this.bUpdate) { this.lblInfo.Visible = true; this.lblInfo.Text = "Missing Translation Resources are Automatically Syncronized and Updated."; this.SaveLanguageFile(); } else { this.lblInfo.Visible = false; } this.grdLocals.DataSource = this.translations.FindAll(check => check.PageName.Equals("DEFAULT")); this.grdLocals.DataBind(); }
/// <summary> /// Save the Updated Xml File. /// </summary> private void SaveLanguageFile() { this.translations = RemoveDuplicateSections(this.translations); new XmlDocument(); var xwSettings = new XmlWriterSettings { Encoding = Encoding.UTF8, OmitXmlDeclaration = false, Indent = true, IndentChars = "\t" }; XmlWriter xw = XmlWriter.Create(Path.Combine(this.sLangPath, this.sXmlFile), xwSettings); xw.WriteStartDocument(); // <Resources> xw.WriteStartElement("Resources"); foreach (string key in this.ResourcesNamespaces.Keys) { xw.WriteAttributeString("xmlns", key, null, this.ResourcesNamespaces[key]); } foreach (string key in this.ResourcesAttributes.Keys) { xw.WriteAttributeString(key, this.ResourcesAttributes[key]); } string currentPageName = String.Empty; foreach (Translation trans in this.translations) { // <page></page> if (!trans.PageName.Equals(currentPageName, StringComparison.OrdinalIgnoreCase)) { if (currentPageName.IsSet()) { xw.WriteFullEndElement(); } currentPageName = trans.PageName; xw.WriteStartElement("page"); xw.WriteAttributeString("name", currentPageName); } xw.WriteStartElement("Resource"); xw.WriteAttributeString("tag", trans.ResourceName); xw.WriteString(this.Server.HtmlDecode(trans.LocalizedValue)); xw.WriteFullEndElement(); } // final </page> if (currentPageName.IsSet()) { xw.WriteFullEndElement(); } // </Resources> xw.WriteFullEndElement(); xw.WriteEndDocument(); xw.Close(); LanguageDB.SaveLanguageXMLToDB(Path.Combine(this.sLangPath, this.sXmlFile)); Response.Write("<!--SaveLanguageXMLToDB: " + this.sXmlFile + "-->"); }