Click here to Skip to main content
13,598,834 members
Click here to Skip to main content
Add your own
alternative version


20 bookmarked
Posted 9 Sep 2002

IG MultiLanguage Toolkit

, 9 Sep 2002
Rate this:
Please Sign up or sign in to vote.
A multilanguage control.


There are many programs that are used by many people who have different mother languages. In that case, English is the most commonly used, so the ones who do not know English well could get in troubles. To solve the problem, I've built an ActiveX control that is useful for programmers. Programmers only have to add the control to their project and provide a dictionary that is used by the control to translate their program's user interface to the required language.

How to use the control...

It is very simple to use the control in your program. There is two ways described here, the first is used for VC++ programs and the other is for VB programs. VC++ programs

With VC++ programs, control has exposed BOOL CIGMultiLangCtrl::TranslateWindow(OLE_HANDLE hWnd) function for that purpose. Suppose you have two menu items: English and Vietnamese. The English menu item is used to translate your program's user interface into English and the other into Vietnamese. You only have to add these lines to your program.

void CTestSDIView::OnLanguageEnglish() 
       int nIndex = m_IGMLCtrl.LanguageByName("English");

void CTestSDIView::OnLanguageVietNamese()
       int nIndex = m_IGMLCtrl.LanguageByName("VietNamese");
} VB programs

For programs that are written in VB, the control has exposed BOOL CIGMultiLangCtrl::TranslateWindow(LPDISPATCH lpDispatch) function to solve the problem. Because the base of almost all VB programs is on COM technique, the control has to do the task in a different way. In that case, you add these lines to your project :

Private Sub MenuItem_Click0
        IGMLCtrl.ActiveLanguage = IGMLCtrl.LanguageByName("English")
        bResult = IGMLCtrl.TranslateObject(Me)
End Sub

An important thing

One thing you should remember is to load the dictionary file before any translation. To load a specified dictionary, you can do this:

// VC++ programs
void CTestSDIView::OnInitialUpdate()
        // your initial code here...
    if (m_IGMLCtrl.LoadDictionary("Dictionary.dic"))
        // Translate Window into recently used language.

// VB programs
Sub Form_Load(..)
      // your initial codes
      IGMLCtrl.LoadDictionary "Dictionary.dic"
End Sub

In this example, I load the file Dictionary.dic from the location where the program is started.

Switching between languages

If you want to switch between languages at run-time, you must first set active language index and then call ::TranslateWindow(...)or TranslateObject(...) function. ActiveLanguage or NativeLanguage property is the index of language in the dictionary file. You can set it directly or by ::LanguageByName(LPCTSTR lpszLanguageName) function.

Dictionary file

Dictionary file is very important in making sure that control is working properly. It normally is a text file, so it is easier for both programmers and end-users. Its structure is described as shown:

  Active Language=VietNamese 
  Native Language=English 
  Tập tin 
  Tạo mới 
  Mở file 
  Lưu file
Lưu file với tên mới

The Active Language key is the key that specifies the current language that is used by the program. The Native Language key specifies the language that is used by programmers at design-time.

Note: You must make sure that the number of text between languages is equal, otherwise there will be errors.

Update later ....


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


About the Author

Truong Pham Dang Khoa
Web Developer
Vietnam Vietnam
I working for Twinstar Systems Inc., a semiconductor company, as Senior Software Engineer.

You may also be interested in...

Comments and Discussions

GeneralNon practical Pin
Philippe Lhoste19-Sep-02 3:14
memberPhilippe Lhoste19-Sep-02 3:14 
Making an OCX is a good idea, but the structure of your dictionary file isn't very practical.

Instead of having one big dictionary with all supported languages, you should provide a file for each language.
As a French user, I want to download (or keep on disk) only the small French dictionary, not the huge (if many languages are supported) multilanguage file.

Also having strings in separate section is very impractical: translator must check he hasn't lost synch, must count lines, etc.
Having a structure like:
English Sentence < tab > Phrase française
where <tab> is the control character, would be easier to translate.

Allowing comments, like where is located a set of sentences (a dialog box, one menu, etc.) would also help translators to test their translation (does it fit the label sizes?).

Of course, the other languages must have their own shortcuts.

Do you manage parameters inside sentences, like "File '^0' is ^1 bytes long,\nlarger than the ^2 bytes limit set in the properties.", knowing that the order of parameters may vary in other languages?

Well, I hope these suggestions will help you to make a better component. Seems good so far.

Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist

GeneralRe: Non practical Pin
Synetech1-Jun-05 13:51
memberSynetech1-Jun-05 13:51 
GeneralRe: Non practical Pin
CPallini29-Apr-08 1:47
mvp CPallini29-Apr-08 1:47 

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 | Cookies | Terms of Use | Mobile
Web02-2016 | 2.8.180621.3 | Last Updated 10 Sep 2002
Article Copyright 2002 by Truong Pham Dang Khoa
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid