Home
> Uncategorized > Find duplicate name values in resx files
Find duplicate name values in resx files
A Resx file is used to define localized text in a .NET application. It is an XML file, which is primarily in the form:
<data name=”Whatever”>
<value>Some Translation</value>
<comment>
Comments to the translator
</comment>
</data>
The data name attribute is supposed to be unique, since the code uses it to determine what translation to use. However, if a duplicate has crept in, then it can be awkward to find this in a large file.
Here was a quick solution using javascript, Drag the rex file into Chrome, and open up the developer console, and copy and paste in the code:
var datanodes = document.getElementsByTagName(“data”);var strNames = [];for(i=0;i<datanodes.length;i++){strNames.push(datanodes[i].getAttribute(“name”));};strNames = strNames.sort();var results = []; for (var i = 0; i < strNames.length – 1; i++) { if (strNames[i + 1] == strNames[i]) { results.push(strNames[i]); }}; console.log(results);
It will then list any duplicate name vales.
Categories: Uncategorized
Comments (0)
Trackbacks (0)
Leave a comment
Trackback