Mono Class Library: Mono.Unix Namespace

Mono.Unix.Catalog Class

A wrapper to the libintl library providing message translation capabilities. [Edit]

See Also: Catalog Members

public class Catalog

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

Remarks

The following example demonstrates the use of the Mono.Unix.Catalog type. See also: http://www.mono-project.com/Internationalization.

C# Example
// File: i18n.cs
using System;
using Mono.Unix;
 
public class i18n
{
    public static void Main(string[] argv)
    {
        Catalog.Init ("i18n", "./locale");
        Console.WriteLine (Catalog.GetString ("My name is") + " Enzo");
        int i = 20;
        Console.WriteLine (Catalog.GetPluralString ("I'm {0} year old.",
				    "I'm {0} years old.", i), i);
    }
}
      

To generate the translations, use:

sh Example
xgettext --from-code=UTF-8 i18n.cs -o es.po

Edit the translations in es.po, then compile the translations and copy the file so that libintl can find it:

sh Example
mkdir -p locale/es/LC_MESSAGES/
msgfmt es.po -o locale/es/LC_MESSAGES/i18n.mo

To run your example with the new translations:

sh Example
LANGUAGE=es mono i18n.exe
[Edit]

Requirements

Namespace: Mono.Unix
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0