YAFLogo

styx31
  • styx31
  • 69.2% (Friendly)
  • YAF Lover Topic Starter
9 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
9 years ago
Happy to see that this change has been integrated in the repo.

Thanks !