You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
655 B

  1. $ErrorActionPreference = "Stop";
  2. [Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq") | Out-Null
  3. Write-Host "Sorting .resx files...";
  4. Get-ChildItem -Include *.resx -Recurse | foreach ($_) {
  5. Write-Host $_.FullName;
  6. $doc = [System.Xml.Linq.XDocument]::Load($_.FullName);
  7. $descendants = [System.Linq.Enumerable]::ToArray($doc.Descendants("data"));
  8. [System.Xml.Linq.Extensions]::Remove($descendants);
  9. $ordered = [System.Linq.Enumerable]::OrderBy($descendants, [System.Func[System.Xml.Linq.XElement,string]] { param ($e) $e.Attribute("name").Value }, [System.StringComparer]::Ordinal);
  10. $doc.Root.Add($ordered);
  11. $doc.Save($_.FullName);
  12. }