![]() |
Languages »
C# »
How To
Beginner
License: The Code Project Open License (CPOL)
Multilingual Application Made Easier in C#By Beniton FernandoThis article focuses on how to work with a multilingual application |
C#, Windows, .NET 1.1, WinForms, VS.NET2003, VS2005, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
This article explains how to make a multilingual application.
The sample project given in this article is an example of a Multilingual application. When speaking about multilingual applications, we need to manage resources specific to each culture. In my sample project, I have supported 5 languages, English, German, Spanish, Italian and French. This sample project supports switching to any of five languages at runtime.
It is very simple to make a multilingual application in C#. I used Visual Studio .NET 2003 to create my sample application. There is also a free IDE known as SharpDevelop which looks similar to Visual Studio .NET.
FormLayout (I mean design of your application).Localizable to true and set the properties Language to whatever Language you like to use.Label, Button, Form and so on.. to the Language you have selected (isn't Limited only for Text property, you can also change layout specific to Language).Now we have done something, but how do we check this work. We have to do something with the code.
Thread.CurrentThread.CurrentUICulture=new System.Globalization.CultureInfo("de")
The above code specifies the Currentuiculture for your application. This code has to be executed before initialization of the components. The string given inside the CultureInfo constructor ("de") specifies the language name for the culture. Some of the culture names and languages are given below:
en - English de - German fr - French it - Italian es - Spanish pt - Portuguese This section is the important one. When we set the form's localizable to true and build the application, Visual Studio .NET creates resources specific to the culture specified in the Language property of the form. Visual Studio .NET creates the resource file using resgen.exe. We can also create resources by using the following syntax:
resgen mytext.en-us.txt mytext.en-us.resources
resgen mytext.en-us.resources mytext.en-us.resx
//This command reads a binary resources file mytext.en-us.resources and
//writes an XML-based output file named mytext.en-us.resx
Now the resources are created, but we need to link them to the application, so this is done by Visual Studio .NET using AL.exe (Assembly linker). We can also do it manually by doing this:
al
/t:lib
/embed:mytext.en-us.resx
/culture:en-us
/out:Myapplication.resources.dll
You can find more about resgen.exe and al.exe in MSDN documentation.
I hope this article will help you. If you have any problem or find any mistakes, please let me know. You can email me at beniton@gmail.com.
Please don't forget to rate this article.
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 16 May 2006 Editor: Deeksha Shenoy |
Copyright 2006 by Beniton Fernando Everything else Copyright © CodeProject, 1999-2009 Web22 | Advertise on the Code Project |