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.
...in 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.
int nIndex = m_IGMLCtrl.LanguageByName("English");
int nIndex = m_IGMLCtrl.LanguageByName("VietNamese");
...in 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)
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
// your initial code here...
// Translate Window into recently used language.
// VB programs
// your initial codes
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.
NativeLanguage property is the index of language in the dictionary file. You can set it directly or by
::LanguageByName(LPCTSTR lpszLanguageName) function.
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:
Lu file với tên mới
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 ....