Home > Uncategorized > Find duplicate name values in resx files

Find duplicate name values in resx files

resx 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>
Comments to the translator
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
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: