-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
48 lines (43 loc) · 1.36 KB
/
Program.cs
File metadata and controls
48 lines (43 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Linq;
using System.IO;
using System.Xml.Linq;
namespace LocalizationChecker
{
class Program
{
static void Main(string[] args)
{
if (!args.Any())
{
PrintUsage();
return;
}
var filePath = args[0];
ModifyResxFile(filePath);
}
private static void ModifyResxFile(string filePath)
{
XNamespace ns = @"http://www.w3.org/XML/1998/namespace";
var xml = File.ReadAllText(filePath);
var doc = XDocument.Parse(xml);
var textualDataElements = doc.Descendants("data")
.Where(d => d.Attributes(ns + "space").Any());
foreach (var dataElement in textualDataElements)
{
var newValue = BuildNewValue(dataElement);
dataElement.Element("value").SetValue(newValue);
}
File.WriteAllText(filePath, doc.ToString());
}
private static string BuildNewValue(XElement dataElement)
{
return $"[✓{dataElement.Element("value").Value}]";
}
private static void PrintUsage()
{
Console.WriteLine("usage: LocalizationChecker.exe <file>");
Console.WriteLine();
}
}
}