YAFLogo

styx31
  • styx31
  • 69.2% (Friendly)
  • YAF Lover Topic Starter
11 years ago
When you use the embedded resource editor, the xml elements are not sorted by page key then by name.

When merging xml language files with source code, it could be problematic (when you use a diff/comparison tool such as winmerge).

This little patch will ensure ressources sorting by page key then by resource name, as used in english.xml.

It also uses the same indent settings as current xml resources files (two spaces instead of tab).

See code below (based on changeset d6869ac69b3c), applied on yafsrc/YetAnotherForum.NET/pages/admin/editlanguage.ascx.cs :



@@ -485,7 +485,7 @@
 
       var xwSettings = new XmlWriterSettings
         {
-           Encoding = Encoding.UTF8, OmitXmlDeclaration = false, Indent = true, IndentChars = "\t" 
+           Encoding = Encoding.UTF8, OmitXmlDeclaration = false, Indent = true, IndentChars = "  " 
         };
 
       XmlWriter xw = XmlWriter.Create(Path.Combine(this.sLangPath, this.sXmlFile), xwSettings);
@@ -506,7 +506,7 @@
 
       string currentPageName = String.Empty;
 
-      foreach (Translation trans in this.translations)
+      foreach (Translation trans in this.translations.OrderBy(t => t.PageName).ThenBy(t => t.ResourceName))
       {
         // <page></page>
         if (!trans.PageName.Equals(currentPageName, StringComparison.OrdinalIgnoreCase))

Sponsor

styx31
  • styx31
  • 69.2% (Friendly)
  • YAF Lover Topic Starter
11 years ago
Happy to see that this change has been integrated in the repo.

Thanks !
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button