I18N in wx.NET

As wxWidgets, wx.NET uses the GNU GetText standard to provide translations for text strings in the source code.

Use wx.Object._() or wx.Object.__() to mark text strings for translations. Method wx.Object._() will return a translation.

 string result__ = wx.Object.__("A text string that shall be translated.");
 // result__ is "A text string that shall be translated.".
 string result_ = wx.Object._("A text string that shall be translated.");
 // result_ is the translation of "A text string that shall be translated.".
Use xgettext to extract strings to be translated directly from the source code.
 * xgettext -o aPotFile.pot -k_ -k__ -C aSourceFile.cs aSecondSourceFile.cs ...
Then, you may use text editors or poEdit to type in translations.

Additionally, wx.NET offers additional capabilites to attach translations to enumeration values and classes using EnumValueTranslationsAttribute or TypeNameTranslationsAttribute respectively. You can use these attributes to provide translations directly in the code. Translations provided by these attributes will also be returned by wx.Object._().

What is the motivation for providing translations to classes and enumeration values? Well, the purpose of many object-oriented system is to represent a small portion of the real world as program code in such a way, that classes or enumeration values refer directly to an entity of the real world - software engineers call something like this cohesion. In such systems, a way to provide human readable names for cohesive portions of code - and humans read things in many different languages.

 [TypeNameTranslationsAttribute("human", "de", "Mensch")]
 public class Human
    public string Name { get; }
 [TypeNameTranslationsAttribute("driver", "de", "Fahrer")]
 public class Driver : Human

[TypeNameTranslationsAttribute("car", "de", "Auto")] public class Car { ...

public Driver TheDriver { get; }

public override string ToString() { return _("A {0} drives this {1}.", _(this.Driver.GetType()), _(this.GetType())); } } Calling ToString() of a car will return something like this in the US or Britain:

 A driver drives this car.
In Germany, the print out will look like the following (if the program does not load additional translations from a MO repository):
 A Fahrer drives this Auto.

Thus, you can have translation of class names and enumeration values in the code and translations of string constants in MO archives created by GNU GetText tools. GetText has the advantage that this tool allows the provision of translations independently from the program code. Specialist can be employed to translate texts.

As a consequence, this namespace provides class ExtractTranslationsOfTypesAndEnumValues to produce GetText POT files to translate class names and enumeration values. This class is used by getwxtext. The following line in the command shell

 * > getwxtext Assembly.dll
will produce a file Assembly.pot containing Gettext entries for any class name or enumeration value that has been marked by a EnumValueTranslationsAttribute or TypeNameTranslationsAttribute.
Manual of the wx.NET   (c) 2003-2011 the wx.NET project at   Get wx.NET at SourceForge.net. Fast, secure and Free Open Source software downloads