Click here to Skip to main content
13,252,815 members (49,906 online)
Click here to Skip to main content
Add your own
alternative version


46 bookmarked
Posted 16 Jul 2007


, 16 Jul 2007
Rate this:
Please Sign up or sign in to vote.
A simple component to aid localization of controls


I've recently been delving into some globalization (or globalisation for us Brits) and didn't particularly like .NET's way of quietly making you split your resources up.

Perhaps I'd better explain this. The Windows Forms designer includes good support for localization, you can utilise this by setting the Localizable property of the Form to true and changing the Language and simply type away. If, however, you need to include separate messages into your program, you must create a separate resource file and load things from there.

Now I'd assume (read: I haven't checked) that .NET lumps all these resources together when it compiles the application, but supposing you want someone else to translate stuff for you, you must manage several files: one for your custom messages and one for every form in the application.

So in summary, I wanted a solution in which I'd only have to manage one resource file per supported language.


Localizer is a simple Component which implements the IExtenderProvider interface. It provides a property called ResourceID. There is only one important property for the component, ResourceManager. This can be set to point to an instance of your project resource manager, wherever that may be.

By setting the ResourceManager property, you enable Localizer to lookup localized strings based on the ResourceID of each control and set the Text property of that control.


Multiple Resources

Resource Strings

To use Localizer you can simply add a reference to the assembly and drop the component onto the form. Once that is done, somewhere you must set the ResourceManager property. Once this is done, no more is required at runtime because changing the ResourceManager automatically refreshes all the Control.Text properties.

You can assign a ResourceID to each control you wish to be localized. Note: If the ResourceID is an empty string, then the text will always remain as the text specified in the designer or code.

In VS2005, perhaps the simplest solution to adding localized strings is to simply add more .resx files to the project, naming them in the pattern seen in the screenshot. Visual Studio will then perform the necessary operations to compile and embed these resources.

The final stage would be to put the translated strings / messages for each ResourceID into each of the .resx files.

Demo Application

A simple demonstration application has been included which dynamically changes the text of controls based on the CurrentUICulture. There is a textbox to change this culture while the application is running.


As usual, I welcome any suggestions for improvements, bug fixes and the usual stuff that we have to deal with in our daily lives as developers.


  • 16th July, 2007: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Engineer PooreDesign
United Kingdom United Kingdom
Ed is a student who due to a form of cancer (now clear) took a year out before going to Imperial College, London to study Electronic Engineering.

His interests include shooting (clay-pigeon (shotgun), air-rifle and rifle), playing with his three labradors (Sandy, Rosie and Tundra), programming (most experienced in C# and C, although those are not the only ones), walking (has completed Gold Duke of Edinburgh's Award), playing games and reading.

He lives in two places on a 57 acre farm in West Waleswith the rest of the family during the holidays; and Greater London during term time.

Languages and Technologies: C#, C, VB6, VB.NET, XAML, (X)HTML, CSS, XSLT, Assembler (PIC), ASP.NET, WPF, Windows.Forms, ASP, VBScript, JavaScript, Pascal / Delphi, XML

Current Stuff:
1st Year MEng Electronics Engineering (Imperial College, London)

You may also be interested in...

Comments and Discussions

GeneralHave a Look at this Component Pin
Patrick Blackman10-Jun-09 4:04
memberPatrick Blackman10-Jun-09 4:04 
QuestionWhat about design time support? Pin
Kanangra27-Jul-07 16:28
memberKanangra27-Jul-07 16:28 
AnswerRe: What about design time support? Pin
Ed.Poore28-Jul-07 9:59
memberEd.Poore28-Jul-07 9:59 
GeneralRe: What about design time support? Pin
Kanangra28-Jul-07 15:04
memberKanangra28-Jul-07 15:04 
GeneralRe: What about design time support? Pin
Ed.Poore28-Jul-07 21:59
memberEd.Poore28-Jul-07 21:59 
Generaldoesn't work with several controls Pin
XDG24-Jul-07 0:37
memberXDG24-Jul-07 0:37 
GeneralRe: doesn't work with several controls Pin
Ed.Poore24-Jul-07 0:52
memberEd.Poore24-Jul-07 0:52 
GeneralRe: doesn't work with several controls Pin
XDG24-Jul-07 0:59
memberXDG24-Jul-07 0:59 
GeneralRe: doesn't work with several controls Pin
forcesoul8-Dec-15 23:46
memberforcesoul8-Dec-15 23:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171114.1 | Last Updated 16 Jul 2007
Article Copyright 2007 by Ed.Poore
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid