Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Library to parse PO files

Tags:

c#

.net

po

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.

like image 709
Alireza Noori Avatar asked May 31 '11 22:05

Alireza Noori


2 Answers

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.

like image 143
Adam Simon Avatar answered Oct 19 '22 19:10

Adam Simon


You can use Mono.Unix

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

like image 33
parapura rajkumar Avatar answered Oct 19 '22 17:10

parapura rajkumar