6

I wanted to create a translator for PO files but I thought that it's better to ask whether there is a library for .Net to parse .PO files or not.

Thanks.

Alireza Noori
  • 14,961
  • 30
  • 95
  • 179
  • 1
    I have been looking for a gettext lib for .NET too, but I was unable to find one. I have written a .po parser in php (shiver) before, it's not so hard to write one from scratch. – toong Nov 23 '11 at 11:56

2 Answers2

4

The question is rather old so my answer is mainly for those who are looking for a PO parser .NET library nowadays.

I implemented a lightweight, fully-managed, .NET Standard-compatible library which is able to parse and generate PO files. Comments and plural translations are supported, as well. The library is free and open-source (released under the MIT license).

First you need to install the NuGet package:

Install-Package Karambolo.PO.Compact

Then to parse a PO file, you just need a few lines as follows:

var parser = new POParser();

POParseResult result;
using (var reader = new StreamReader("sample.po", Encoding.UTF8))
    result = parser.Parse(reader);

if (result.Success)
{
    POCatalog catalog = result.Catalog;
    // process the parsed data...
}
else
{
    IDiagnostics diagnostics = result.Diagnostics;
    // examine diagnostics, display an error, etc...
}

For further details visit the project page.

Adam Simon
  • 2,762
  • 16
  • 22
2

You can use Mono.Unix

http://www.mono-project.com/I18N_with_Mono.Unix

parapura rajkumar
  • 24,045
  • 1
  • 55
  • 85
  • 2
    I skimmed the tutorial but it seems that it is used to make .PO files from the C# code and use .PO files to translate the software. I want to write a translator software for PO files (like POEdit). Does it have the ability to do so? – Alireza Noori May 31 '11 at 23:04
  • The Mono.Unix package is a wrapper around the C-libs. – toong Nov 23 '11 at 11:53