This project is read-only.
Windows forms custom localizer is a small .NET library which can be used to provide custom localization mechanism which can replace standard .NET resource based localization which is commonly used in .NET windows forms projects.
I've written a blog post at which describes how this project came to be and how it actually works so please go ahead and read that post in order to better understand how the library works.

Inside the source code there are two projects
  • OP.Localizer - the actual library containing the localizer code
  • OP.Localizer.Demo - small demo application which uses SqlCe database to perform translations.

In essence the localizer is a component which replaces the standard resource manager component which gets added to any Form or UserControl which is marked as Localizable. This component then uses a OP.Localizer.Localizer class to provide translated text instead of the one provided by the standard resource manager. The OP.Localizer.Localizer class in turn uses a custom OP.Localizer.ITranslationProvider to read and update translations. With the library itself I've provided two such providers OP.Localizer.SqlTranslationProvider for MS SQL database and OP.Localizer.SqlCeTranslationProvider for Sql CE compact database.

Each translation is defined by a key which is in the form of form/usercontrolfulltypename.controlname.controlproperty. So if you have a form which is ExampleProject.Forms.MainForm and on that form you have a label called Label1 then the Text property of that control can be translated by using translation key ExampleProject.Forms.MainForm.Label1.Text.

The best way to get the feeling of the library is to check out the demo project but if you are too lazy to do that then here are the basic steps to get your forms localizable:
  • Create either MSSQL or SqlCE database with table which will contain translations table (lets call it Translations)
    • Add following fields in the table:
    • Key nvarchar(1000), -- this will contain the key as described above
    • LanguageID int, -- this will contain language ID
    • Text nvarchar(1000), -- this will contain the actual translation
    • UserDefined bit -- this flag gets set if the user modifies the translation via built-in translation dialog
  • Add reference to OP.Localizer.dll in your project (either download the demo and use the DLL from the demo or get the source code and compile it yourself
  • Have your forms inherit from OP.Localizer.FormTranslatable (this will also add user interface for editing translations directly to the form) or add Op.Localizer.LocalizerComponent component to your Form/UserControl (you have to manually invoke the translation dialog or perform your own translations)
  • Initialize the Localizer framework before creating forms or user controls affected by translations - here is an example:
    • OP.Localizer.Localizer.SetDefaults(1, "English", New OP.Localizer.SqlCeTranslationProvider(System.Configuration.ConfigurationManager.ConnectionStrings("nls").ConnectionString)

This is it. Whichever form was inherited from OP.Localizer.FormTranslatable will have a custom System menu for translations. ScreenShot00124.jpg

Once the menu is invoked you will get a dialog where the translations for that form are available and can be changed. ScreenShot00125.jpg

Again feel free to check out my blog post where I have written in length how to library works and what it actually does. The reason why I say this is not to make your read my blog but its because I dislike duplicating what I've written there.

Last edited Nov 21, 2013 at 9:53 PM by dcarapic, version 2