Frage

Wie kann ich vergleiche den Inhalt von zwei (oder mehr) großen RESX-Dateien? Mit Hunderten von Namen / Wert-Paare in jeder Datei, wäre es sehr hilfreich sein, eine kombinierte Version zu betrachten. Ich bin besonders interessiert in Namen / Wert-Paare, die in der neutralen Kultur vorhanden sind, aber nicht auch in einer kulturspezifischen Version angegeben.

War es hilfreich?

Lösung

Es gibt ein großes Freeware-Tool resx-Dateien zu bearbeiten, wo Sie mehrere Sprachen auf einmal sehen können und deutlich sehen, was fehlt oder Extra - Zeta Resource Editor

Andere Tipps

Obwohl es nicht ein Diff-Tool per se, RESX Synchronizer helfen können hier. Seine Hauptaufgabe ist es, die lokalisierte RESX-Dateien mit neuen Einträgen aus der neutralen Sprache ein zu aktualisieren, und entfernen Sie alle gelöschten Elemente.

Möglicherweise erzeugt die Ausgabe, indem sie es mit der Option / v Befehlszeilenoption wird das sein, was Sie brauchen. Ansonsten ist es kommt mit voller C # Quellcode, so möglicherweise können Sie es für Ihre Bedürfnisse anpassen.

Für neuere Versionen von Visual Studio (2010+) gibt es jetzt eine Visual Studio-Erweiterung namens ResXManager (erstellt von tomenglert ), die ist erstaunlich, hierfür.

Es ermöglicht Ihnen, jede Ressource in jeder Sprache nebeneinander und Highlights fehlenden Ressourcen anzuzeigen. (Das folgende Beispiel ist von der Erweiterung Download-Seite.)

 Beispiel von der Extension Download-Seite

ein einfaches diff auf XML-Dateien verwenden kann völlig nutzlos sein, wenn die passenden Elemente in der gleichen Reihenfolge in beiden Dateien nicht angezeigt werden. Ich habe für ein XML-spezifische Diff-Tool suche auch bisher ohne Erfolg.

In der Zwischenzeit die Abhilfe, die ich verwendet habe, ist dies:

  • Öffnen Sie die .resx Dateien in Visual Studio.
  • Wählen Sie alle [ Strg + A ] und schneiden [ Strg + X ] (Dies kann ein während für große Dateien - sein Patient)
  • Einfügen [ Strg + V ] und speichern
  • (dies wird die .resx Dateien durch Schlüssel sortiert neu erstellen)

Wenn beide Dateien werden so neu geordnet, normal diff'ing wird so viel einfacher. Sie können die fehlenden Tasten schnell lokalisieren, indem er nun durch die diff Skimming.

I've tried several XMl diff tools. Here's the summary (the requirement that drove me to evaluate it was to diff the Visual Studio generated .resx resource files, which I think is a big fault that Microsoft made - the order of the elements is random, and Windows Forms always re-write the ImageStream if you just change a button's location and do nothing with the imageList).

  1. XmlDiff
  2. Araxis
  3. Altova DiffDog
  4. XML Notepad
  5. ExamXML
  6. Liquid XML Studio 2009 (there's an XML diff menu, but only a license version can use it. So I have no chance to give it a try)

First of all, all the normal diff tools should not be considered because they know nothing of XML, they treat text files as just lines of text.

  1. XmlDiff is the first tool I tried. It looks that it can do want I need, but after downloading the source code (Visual Studio 2003) and compiled with Visual Studio 2005 (with a successful auto upgrade) I can compile the small project smoothly. But when I compare two real .resx files (1295 lines) it crashed. Debuging into the code does not give me a clue about what happened because I have no source code of the xmldiffpatch.dll XmlDiffPatch.View.dll.

    And the reason did I not try to dig more into this tool was the output format, or GUI design. It outputs an HTML file with differences highlighted in a Internet Explorer-hosted window. For a large XML file diff, it's not easy to use.

  2. XML Notepad has a simple built-in XML diff. According to the output window I think it internally uses XmlDiff's component. And the output is same as XmlDiff. I'll uninstall it.

  3. Araxis is much more a traditional text diff tool, it can also compares binary file, image file, folder, and word files. I like it very much for any diff task except XML, because it has not XML-aware diff options support.

  4. Altova DiffDog looks like a complicated commercial product, and it did contain an option to ignore the element order, which is the key feature for me.

    But after trying it with the same real .resx file (1295 lines, not a big one in my experience), I found that the "ignore element order" just does not work well if the two elements are located at very different places in the two files.

  5. ExamXML looks like a commercial product, but it is a small product. But after trying it, I found it's the most ideal tool at present for my expectations.

There's also a disappointing side: it crashed when I pressed F10 to navigate to the next difference. The ignore order of elements option works well. There's one pitty that the customization of ignored element is not so much flexible.

label1.Size
label1.Location
label1.Width

I want to ignore all the differences on these elements whose name contains ".Size" or ".Location" or ".Width", but it's not possible to define such a condition at the same time. The customization does not support regular expressions.

Anyway, I'll use ExamXML (with careful) to compare XML files.

UPDATE 1: years passed, now I use VS2017 and winform did not change since my initial answer of this question. When work need to break down to different people, this issue popped again and again, boring me.

Actually I forgotten this answer, google brought me here.

I started a new investigate session, and have some good findings: https://www.codeproject.com/Articles/37022/Solving-the-resx-Merge-Problem shows that how eaisly we can sort the resx file by data/@name attribute by LINQ. It's amazing. The core code is only one statement composed of several LINQ.

Then I also found that ResXResourceManager, which is pointed out by another answer in this thread, the author replied to the above code project article and add the feature to ResXResourceManager, in ResxResourceManager, you can config the plugin to automatically sort the resx file when(before) you save it in the configuration tab. There's even a sorting option you can choose: CurrentCulture, Ordinal or IgnoreCase etc.

Unfortunately the code-project solution and the ResXResourceManager solution produce different result, source is available, I found out that the code-project solution treat the ">>" attribute value as normal text so semantically related widgets are separated. This can be easily fixed by adding a TrimStart('>') to the LINQ.

However, after fixing this the two tool still produce different result. The culprint is the LINQ by default using CurrentCulture to sort string, and I totally ignore the revelant sort option in resXResourceManager, for this problem, I think the best sort option is "Ordinal". After adding the sort option to the code project solution, and setting the same sort option in ResXResourceManager, finally they produce exactly same result!

Although resxResourceManager is great to centrally manage the resource and fix the resx element order issue, the code-project tool is still invaluable to me, since it's standalone so it can be used in a broader cases; plus, the code is very terse and elegant.

I would add another note at the end of my update, I use tortoise git, I use Araxis to compare different versions, it's almost non-sense to compare two resx file revision, however, Araxis support to custom a filter to transform the input file before the compare engine seeing it. For compare, Araxis calls the filter by the following command: sortresx.exe -f C:\Users\ADMINI~1\AppData\Local\Temp\mrg.8032.3.resx C:\Users\ADMINI~1\AppData\Local\Temp\mrg.8032.2 C:\Users\ADMINI~1\AppData\Local\Temp\mrg.8032.4

-f means foward, the first file name is the input file, the second file name is the output file the filter should written, the third one can be safely ignored. After making a little change to the code-project code, I can now compile a filter program, configed it in Araxis, and do a reasonable resx revision comparison even on old, messed up resx files.

You could code something up using XML Diff. See Using the XML Diff and Patch Tool in Your Applications.

You can use a tool like TortoiseSVN's diff (if you're using Windows). Just select both files, right click and then select "diff" from the TortoiseSVN submenu.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top