Alireza Noori
Alireza Noori

Reputation: 15253

.Net Library to parse PO files

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.

Upvotes: 6

Views: 5685

Answers (2)

Adam Simon
Adam Simon

Reputation: 2970

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.

Upvotes: 4

parapura rajkumar
parapura rajkumar

Reputation: 24403

You can use Mono.Unix

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

Upvotes: 2

Related Questions