Click here to Skip to main content
15,606,568 members
Articles / Desktop Programming / MFC
Posted 9 Sep 2002


20 bookmarked

IG MultiLanguage Toolkit

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
9 Sep 20022 min read
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

Written By
Web Developer
Vietnam Vietnam
I working for Twinstar Systems Inc., a semiconductor company, as Senior Software Engineer.

Comments and Discussions

QuestionHow to declare the m_IGMLCtrl in the project. Pin
gloriousgopi2-Aug-06 19:43
gloriousgopi2-Aug-06 19:43 
QuestionWhy to use an ActiveX? Pin
Nicolas Stuardo30-Sep-05 5:26
Nicolas Stuardo30-Sep-05 5:26 
Generalerror "Cannot open file mfc42u.lib in winXP Pin
inbakumar.G10-Mar-05 3:09
inbakumar.G10-Mar-05 3:09 
Generalewfgyewygfyu Pin
Anonymous7-Oct-04 18:43
Anonymous7-Oct-04 18:43 
GeneralNon practical Pin
Philippe Lhoste19-Sep-02 3:14
Philippe Lhoste19-Sep-02 3:14 
GeneralRe: Non practical Pin
Synetech1-Jun-05 13:51
Synetech1-Jun-05 13:51 
GeneralRe: Non practical Pin
CPallini29-Apr-08 1:47
mveCPallini29-Apr-08 1:47 
Generalok Pin
hspecg@163.com10-Sep-02 18:21
hspecg@163.com10-Sep-02 18:21 

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.