Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

If you look for internationalization it's common to use the abbreviation i18n. Internationalization is the topic of translation of messages. If you are interested in using different units, date formats, number notations that's called Localization L10n.

Things to look at:

  • Example .NET applications available with sources where localization is implemented nicely:
    • SharpDevelop - check user interface translated to many languages
    • Paint.NET
    • MonoDevelop, source code can be checked out using the following command line: svn co svn://anonsvn.mono-project.com/source/trunk/monodevelop monodevelop

Overview Examples


Example

Localization change

Method

Architecture

SharpDevelop

runtime

  • .NET ResourceManager

Paint.NET

restart

  • .NET ResourceManager

MonoDevelop

?

  • written in C/C++
  • getText instead of Resources.
    This allows MonoDevelop to take advantage of
    GNOME translators' familiarity with getText.

?

Spring.Net

runtime
[web, just 1 page to refresh]

  • Follows Globalization Architecture .NET
  • Automatic Localization Using Localizers ("Push" Localization)
  • Working with Localizers $this (form/usercontrol) or $resource_namespace
  • Applying Resources Manually ("Pull" Localization) like getMessage("labelName");

-

MonoRail

runtime
[web, just 1 page to refresh]

  • .NET ResourceManager

Singleton versus Static Class

  • In C#, Singleton class as the name implies creates only one instance of the class and its member, whereas, static class creates a new instance of the static members every time it is being accessed.
  • Adds a level of indirection. This allows the creation of more than one instance of the class at a later date without breaking client code.
  • Encapsulates data and methods into a separate namespace, the singleton class.
  • Allows sub-classing.
  • Provides access control to the single instance.
  • Thread safe.

Overview Methods


Method

Maintenance

Remarks

Resources (.NET)

Satellite assembly: editors -Zeta Resource Editor,Resource Builder

  • Resources (.NET) not only text, also images, files etc.
  • Resources (.NET) can also be used for redesign/culture (location/Size)
  • Resources (.NET) indexed on labels or control names

gettext

kbabel gettext editor

The main differences between the common .NET resources approach and the
GNU gettext approach are:

  • In the .NET resource approach, the keys are abstract textual shortcuts. In the GNU gettext approach, the keys are the English/ASCII version of the messages.
  • In the .NET resource approach, the translation files are called "Resource.locale.resx" and are UTF-8 encoded XML files. In the GNU gettext approach, the translation files are called "Resource.locale.po" and are in the encoding the translator has chosen. There are at least three GUI translating tools (Emacs PO mode, KDE KBabel, GNOME gtranslator).
  • In the .NET resource approach, the function ResourceManager.GetString returns an empty string or throws an InvalidOperationException when no translation is found. In the GNU gettext approach, the GetString function returns the (English) message key in that case.
  • In the .NET resource approach, there is no support for plural handling.In the GNU gettext approach, we have the GetPluralString function.
  • In the .NET resource approach, there is no support for context specific translations. In the GNU gettext approach, we have the GetParticularString function.
    To compile GNU gettext message catalogs into C# assemblies, the msgfmt/msgunfmt program can be used.
  • gettext generate a indexlist at runtime

DelftLanguage

text-files(lng)

  • dll
  • parsing all controls of forms
  • indexed on content

Suggestion


Architecture
Image Added
Work method

  • Automatic Localization Using Localizers = property window Visual Studio [resource on class (Form/UserControl)s level]
  • Applying Resources Manually = resourceService.getString(indexname) for using the Lookup hierarchy.

Lookup hierarchy

  • Class (Form/UserControl) languagecode-country/regioncode
  • Class (Form/UserControl) languagecode
  • Application (Plugin) languagecode-country/regioncode
  • Application (Plugin) languagecode
  • DelftShell (DelftShell.Resource, a new project in DelftShell for all common translations like save, delete, remove etc.) languagecode-country/regioncode
  • DelftShell (DelftShell.Resource, a new project in DelftShell for all common translations like save, delete, remove etc.) languagecode

Maintenance


Conclusion

Since GNU specially offers an LPGL GNU.GetText.dll (get dll) to make a bridge between the .NET resources and gettext files we can use the .NET ResourceManager for managing localized/culture depended resources.
GNU.GetText.dll is derived from the .NET ResourceManger class and has a GettextResourceSet derived from the class ResourceSet. Image Added
The Gettext xgettext program extracts translatable strings from given input file(s) into a template (.pot) file.

Dutch translations for PACKAGE package.

Copyright (C) 2008 THE PACKAGE'S COPYRIGHT HOLDER

This file is distributed under the same license as the PACKAGE package.

koste_a <EMAIL@ADDRESS>, 2008.
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-04-25 09:48+0200\n"
"PO-Revision-Date: 2008-04-25 10:00+0100\n"
"Last-Translator: alex <alex@del.ta.res.nl>\n"
"Language-Team: Dutch\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CP1252\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: hello.cs:37
msgid "Hello, world!"
msgstr "Hallo, wereld!"

#: hello.cs:44
#, csharp-format

Wiki Markup
msgid "This program is running as process number {0}."

Wiki Markup
msgstr "Dit programma draait onder processnummer {0}."

#: Form1.cs:21
msgid "Dynamic Text by Mono-gettext"
msgstr "Dynamische text door Mono-gettext (is niet waar)"

#: Form1.cs:22
msgid "lblResources From gettext.resource"
msgstr "lblResource krijgt zijn tekst van gettext"

...

Points of interest


  • Resources and WPF: msd2 (still based on Satellite Resource.dll's]

...

Attachments
patterns.*ppt

//

Current CultureInfo/Localization

//
cultureInfoUI of the UserSettings from DelftShell.Gui (Properties.Settings which appears finally in the app.config) set the current CultureInfo/Localization to the given value of this parameter. This UI localization will be set for the DelftShell thread (Thread.CurrentThread.CultureInfoUI). For this moment all Plugins are running within this thread.
//

IApplication.Resources

//
DelfShell.GUI.DelftShellGUI sets the Properties.Resources of DelfShell.GUI to IApplication.Resources of DelfShell.Core.DelftShellApplication.
//

IPlugin.Resources

//
DelfShell.Core.DelftShellApplication initialises all plugins and sets the Properties.Resources of the plugin to IPlugin.Resources
//

Log4net

//
best idea for localization Log4Net
In DelftShell.Gui.Forms.MessageWindow.MessageWindowLogAppender we could translate the message and make a catalogue in the app.config of the plugins. Still to do some tests/research like performence/threadsafe, how to get the parameters of string.format of the message etc. It would be nice the next version of Log4Net will include a decent solution.
//

Available Languages

//
The available culture depended Resources in DelfShell.GUI.Properties.Resources are bound to the list in Menu->Tools->Options->General->Language
//

Menu

//
DelftShell.Gui.PluginConfigurator reads the plugin configuration from the app.config of the plugin. MenuItems of the plugin are added to the mainmenu. Firstly, the text of the MenuItems will be lookedup in IPlugin.Resources then in IApplication.Resources with parameter MenuItem.Name. If not found the default text in app.config will be set.
//

Build and Location resources.dll's

//
The culture depended Resources.dll will be located in bin\debug\<culture-country>\Resources.dll.
With a Post-Build script of the plugins the dll's and folder have to be copy to DelftShell.Loader\bin\plugins\<plugin>\<culture-country>\Resources.dll
//

Issues to resolve

  • Log4net and DelftShell.Gui.Forms.MessageWindow
  • Plugin can set the currentUICulture
  • Thousand and decimal points-commas of the different cultures and problems with string-double conversions etc.
    //

    Suggestions

    //
    It would be handy to centralise all resources in DelftShel.Resources and <Plugin>.Resources. It will be easier to maintenance all resources and texts and it will not be necessary to build the whole solution for a little text change. Also for a setup it will be easier to include all needed files. Designers and Translators can do there job without any knowledge of the program.
    // Maintenance