Click here to Skip to main content
15,881,588 members
Articles / Programming Languages / C#
Article

Multilingual TextBox

Rate me:
Please Sign up or sign in to vote.
1.67/5 (4 votes)
7 Jul 20051 min read 53.6K   1.8K   17   4
This textbox enables us to write text in diffrent languages. It supports Unicode text.

Sample Image

Introduction

This is a kind of textbox with multilingual support and it is Unicode compliant. In order to display text in different languages, we must have language.xml files in the bin\language directory for each language, which is kind of the key mapping and it is very easy to prepare the XML files.

Background

In my project, I was in the need of a textbox in which we can have text of different languages with out setting the font each time?

Using the code

In the languageTextBox class file, there is a method ProcessDialogKey(Keys keyData), I am overriding that method in order to trap the keyboard interrupt and to modify the display of the interrupt.

C#
protected override bool ProcessDialogKey(Keys keyData)
{
    ..
    ..
    ..
    _reader=new XmlTextReader("..\\language\\"+lan_name+".xml");
    while(_reader.Read())
    {
        if(_reader.Name ==keyData.ToString().Replace(",","").Replace(" ",""))
        {
            valid=true;
            break;
        }
        _reader.Read();
    }
    ..
    ..

In order to map the keys, I am reading configuration data from an XML file. If it does not find the particular language.xml in its bin\language directory, it works for English as default. <_reader> is the variable to read from the XML file: _reader = new XmlTextReader("..\\language\\"+lan_name+".xml").

Points of Interest

During the coding of this function I realized that we could trap any interrupt generated by the keyboard. An interesting feature of this is it just needs to compile once. That is for different languages, we just need to provide the XML of that language and it works for that language. All the glyphs related matter is taken care of by the Unicode font. In this control, I have used Arial Unicode MS true type.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
i am mahesh mishra working with IIT Kanpur as a project associate.

Comments and Discussions

 
QuestionMultilingual TextBox Pin
ssvinodh3-Apr-08 19:42
ssvinodh3-Apr-08 19:42 
GeneralPlease help Pin
sreejith ss nair18-Sep-05 21:28
sreejith ss nair18-Sep-05 21:28 
Good Article.

I have a small doubt regarding Globalization/Localization. Hope you can help me out.
I have a web form application where i need to provide more than 50 different localized resource supports. Apart from this, my application supports rich use of stored data (Sql Server Database) and obviously have few list of Listing controls (Repeater , Grid etc).

My requirement comes like this,

a) I need to provide full localized language support in all data which is displaying in each and every page. Regardless of, the name of controls, content of controls etc. To be concise, which ever text that i am displaying through page, need to be localized based on user selected language.

b) Each and every setup needs to contain all supported languages. So user can switch and view content of site in different language.

I stuck in,

1) I am not sure how to localize stored data in database.
2) How will I give or from where i generate localized information for all supported language.

It would be grate if you can help me out through your valid comments.


Sreejith Nair
[ My Articles ]
GeneralMalayalam Key mapping Pin
Veeran Kutty9-Aug-05 5:41
Veeran Kutty9-Aug-05 5:41 
GeneralRe: Malayalam Key mapping Pin
mahesh.mishra22-Sep-05 0:24
mahesh.mishra22-Sep-05 0:24 

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.