Question

Comment puis-je comparer le contenu de deux (ou plus) gros fichiers .resx? Avec des centaines de paires Nom / Valeur dans chaque fichier, il serait très utile de visualiser une version combinée. Je suis particulièrement intéressé par les paires Nom / Valeur qui sont présentes dans la culture neutre mais ne sont pas également spécifiées dans une version spécifique à la culture.

Était-ce utile?

La solution

Il existe un excellent outil gratuit pour éditer les fichiers resx où vous pouvez voir plusieurs langues à la fois et voir clairement ce qui manque ou ce qui est extra - Éditeur de ressources Zeta

Autres conseils

Bien que ce ne soit pas un outil de différenciation en soi, le Synchroniseur RESX peut vous aider. Son utilisation principale est de mettre à jour les fichiers .resx localisés avec les nouvelles entrées de la langue neutre et de supprimer les éléments supprimés.

La sortie générée en l’utilisant avec le commutateur de ligne de commande / v sera peut-être ce dont vous avez besoin. Sinon, il est fourni avec le code source complet C #, vous pouvez donc éventuellement l'adapter à vos besoins.

Pour les versions plus récentes de Visual Studio (2010+), il existe désormais une extension Visual Studio appelée ResXManager (créé par tomenglert ), ce qui est remarquable pour cela.

Il vous permet de visualiser côte à côte chaque ressource de chaque langue et de mettre en évidence les ressources manquantes. (L'exemple ci-dessous provient de la page de téléchargement d'extension.)

 Exemple de page de téléchargement d'extension

L'utilisation d'un simple diff sur des fichiers XML peut être totalement inutile si les éléments correspondants n'apparaissent pas dans le même ordre dans les deux fichiers. Je recherchais également un outil de différenciation spécifique à XML, sans succès jusqu'à présent.

En attendant, la solution que j'utilise est la suivante:

  • Ouvrez les fichiers .resx dans Visual Studio.
  • Sélectionnez tous les [ Ctrl + A ] et coupez [ Ctrl + X ] (cela peut prendre alors que pour les gros fichiers - soyez patient)
  • Collez [ Ctrl + V ] et enregistrez (cela recréera les fichiers .resx triés par clé)

Lorsque les deux fichiers sont ainsi réorganisés, la diffusion normale devient beaucoup plus facile. Vous pouvez localiser rapidement les clés manquantes en parcourant le diff maintenant.

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top