How to use xliff or po l10n file formats in .net (C#/ASP.Net) development
Asked Answered
M

4

10

I've been researching about xliff and po i18n files formats and it seems they are widely used and supported. There are plenty of free tools to manage the translations in xliff/po files.

However, so far I could not find a good solution of how to use the xliff or po files in .net (C#/ASP.Net) projects. I would expect some sort of xliff/po => resx converter, but so far haven't found one yet.

However at the same time many tools do support the conversion of xliff/po files into java .properties format.

If you have an experience implementing l10n via xliff or po files in .Net projects - please provide advice and share the best practices on how it works.

PS: I would prefer using xliff format, since I find it cleaner and more feature-reach, but po is also an option.

Minni answered 9/12, 2011 at 19:14 Comment(2)
Any reason you can't use resource files directly?Dermoid
We want to use a single format for translations among different project our company builds - those are C# and Java projects, and share them to minimize duplication and additional cost for separate translations for different projects.Minni
B
8

PO and XLIFF files usually work differently:

  • PO files are resource files that get complied into a binary format and then accessed using gettext() libraries. Sometimes PO is used as an extraction format like XLIFF, but that is not its original purpose.

  • XLIFF are extraction files that get created by extracting your resource file (e.g. resx) into XLIFF, and then merged back into the original format.

so for XLIFF you should be looking for a tools doing resx -> xliff -> resx rather than xlif -> resx.

The tools that extract/merge XLIFF files are usually called filters. There are quite a few commercial translation tools that will accept XLIFF, and some that can also create XLIFF (Swordfish, Trados Studio, etc.).

There are also a few open-source tools that can extract/merge XLIFF: File2XLIFF4j for example (but I don't think it supports resx).

Rainbow, from the Okapi project, does support resx. The "old" .net version (Rainbow 5: Okapi on SourceForge) has a filter dedicated to resx file and can handle them very well; even with binary data. It may run into problem with third party controls though (See http://okapi.sourceforge.net/Release/Filters/Help/netres.htm for details).

The new java version (Rainbow 6: http://code.google.com/p/okapi/) support resx through its XML filter and works fine with simple resx, but if you have binary data in them the text in those entries will not be extracted.

-ys

Biradial answered 10/12, 2011 at 13:9 Comment(1)
Great answer! Thanks for clarifying that to me. I will dig further to figure out the best approach to minimize the effort on l10n for combination of .net and java projects.Minni
B
10

You could also consider the i18n package by Daniel Crenna, available from nuGet. It uses PO files as its default store for localized text.

Blowsy answered 14/3, 2012 at 6:5 Comment(0)
B
8

PO and XLIFF files usually work differently:

  • PO files are resource files that get complied into a binary format and then accessed using gettext() libraries. Sometimes PO is used as an extraction format like XLIFF, but that is not its original purpose.

  • XLIFF are extraction files that get created by extracting your resource file (e.g. resx) into XLIFF, and then merged back into the original format.

so for XLIFF you should be looking for a tools doing resx -> xliff -> resx rather than xlif -> resx.

The tools that extract/merge XLIFF files are usually called filters. There are quite a few commercial translation tools that will accept XLIFF, and some that can also create XLIFF (Swordfish, Trados Studio, etc.).

There are also a few open-source tools that can extract/merge XLIFF: File2XLIFF4j for example (but I don't think it supports resx).

Rainbow, from the Okapi project, does support resx. The "old" .net version (Rainbow 5: Okapi on SourceForge) has a filter dedicated to resx file and can handle them very well; even with binary data. It may run into problem with third party controls though (See http://okapi.sourceforge.net/Release/Filters/Help/netres.htm for details).

The new java version (Rainbow 6: http://code.google.com/p/okapi/) support resx through its XML filter and works fine with simple resx, but if you have binary data in them the text in those entries will not be extracted.

-ys

Biradial answered 10/12, 2011 at 13:9 Comment(1)
Great answer! Thanks for clarifying that to me. I will dig further to figure out the best approach to minimize the effort on l10n for combination of .net and java projects.Minni
O
4

I've used PO to manage a .Net project after .resx files started getting out of hand. I used it "as an extraction format like XLIFF" (see Yves comment). Our existing .resx files were exported/merged once into one .po file per language, which then became our authoritative language files from which all the resx files would be automatically generated.

The projects I'm on aren't ASP so I don't know about the package mentioned by mcw0933, but Mono's implementation of resgen.exe has some simple po <=> resx conversion ability. However, in order to preserve existing comments and automatically add the original text as extra comments, I extended mono's conversion tool to the point where the one I use is basically rewritten.

I put the extended .po <=> .resx converter on github.

As for choosing .po to manage the translations of a C# project, .po is simple and friendly but there are some inconveniences from using it in a way that slightly differs from its original use in gettext, and I don't have the experience to say whether it was a better choice than xliff, but being able to manage translations and automate tasks was much better than dealing with the resx files, like we had been in the past.

Minor inconveniences from using PO a little differently to its intent:

  • Because gettext uses msgid to double as the field to store the original untranslated string in, I had to make resgenEx archive the original translation string into an attached comment instead of a field designed for that purpose.
  • Some tools assume the msgid will contain the original english translation (instead of just an ID string), which could mean the automatic error checking option of that tool isn't very useful, or it might mean something that makes you choose a different tool, etc. Most tools make no assumption though.
  • Some .po tools like \n instead of \r\n

The project I originally wrote resgenEx for had two .resx files and one .isl file for every supported language, but soon I'll need to manage all the translations for a .Net project that has multiple resx files for every class in the code. When this happens I'll decide whether I should keep using .po or whether I should use xliff or something else. If I keep using .po then I'll clean up resgenEx and probably need to add more features, like the ability to automatically add assembly name and class name prefixes to the msgids.

Odilo answered 19/3, 2014 at 12:9 Comment(0)
G
0

Check out xliff-tasks. The tool generates xliff from resx and satellite assemblies from xliff.

Govern answered 27/8, 2020 at 10:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.