Home
Gettext.NET
- Quick start guide (see below)
- [Using in WinForms]
- [Useful links]
Gettext.NET quick start
1. In C# code
Add reference to GNU.Gettext.dll assembly in your project.
// Create resource manager
GettextResourceManager catalog = new GettextResourceManager();
// if satellite assemblies have another base name use
// GettextResourceManager("Examples.HelloForms.Messages") constructor
// Write out translated messages
Console.WriteLine(catalog.GetString("Hello, world!"));
Console.WriteLine(catalog.GetStringFmt(
"This program is running as process number \"{0}\".",
Process.GetCurrentProcess().Id));
2. Extract messages
Extract messages to PO template file from your *.cs source code using Xgettext.NET utility
# From project root directory
# Linux
mono GNU.Gettext.Xgettext.exe -D ./ --recursive -o ./po/Messages.pot
# Windows
GNU.Gettext.Xgettext.exe" -D .\ --recursive -o .\po\Messages.pot
3. Translate messages
With using of any PO editor (i.e. POEdit) create or update your PO translation files and then translate messages.

4. Compile
Build resources satellite assemblies from PO files using Msgfmt.NET utility
# From PO directory
# Linux
mono GNU.Gettext.Msgfmt.exe -l fr-FR -d ../bin/Debug -r Examples.Hello.Messages -L ../../Bin/Debug fr.po
# Windows
GNU.Gettext.Msgfmt.exe -l fr-FR -d ..\bin\Debug -r Examples.Hello.Messages -L ..\..\Bin/Debug fr.po
5. Run application

The wiki uses Markdown syntax.