Easily develop multilingual programs

zhaozj2021-02-16  52

There are three ways to develop multilingual interfaces on the Windows platform.

1. Publish separate versions for each language (such as Microsoft Windows)

2. Includes executables that are not only a language resource, or a separate DLL file. (Such as Isobuster) This is also our most ways.

3. External language package executable. Like Netants, Flashget, Tweak-XP, PatchWise Free, etc. In support multiple languages ​​(* .ini or * .lng) to replace DLL files when supporting multi-language. Since language packs can be dynamically modified, the recomparation of software is not necessary. Moreover, this is easy to change the language and maintain an independence of external language packs.

Here, let's take a look at the third method. Because it is the easiest, the simplest solution.

1. The first step is the most important. You must add files Langini.h and Langini.cpp in your project.

2. Then add variables in your C **** App class.

3. In your c **** dlg :: () function, initialize your button / text. Add the following code:

Void C **** DLG :: OnNitdialog (Void)

{

Setdlgitemtext (IDOK,

THEAPP.M_LANGINI.GETVALUE ("Button",

"Ok"));

Setdlgitemtext (IDCANCEL,

THEAPP.M_LANGINI.GETVALUE ("Button",

"Cancel"));

Setdlgitemtext (IDC_PROMPT,

THEAPP.M_LANGINI.GETVALUE ("Prompt",

"PROMPT"));

Setdlgitemtext (IDC_PROMPT_ENGLISH,

THEAPP.M_LANGINI.GETVALUE ("Prompt",

"Lang1")));

Setdlgitemtext (IDC_PROMPT_CHINESE,

THEAPP.M_LANGINI.GETVALUE ("Prompt",

"Lang2"));

}

4. Then, add a handle for the ON_BN_CLICKED event of the radio button:

Void Cuilangdlg :: OnBnclickedPRomptenglish ()

{

// Todo: Add Your Control Notification Handler

// Code Here

THEAPP.M_LANGINI.LOADFILE ("English.ini");

INITCONTROLS ();

}

Void Cuilangdlg :: OnBnclickedPromptChinese ()

{

// Todo: Add Your Control Notification Handler

// Code Here

THEAPP.M_LANGINI.LOADFILE ("chinese.ini");

INITCONTROLS ();

}

This completes the basic work. Then. What are the contents of the file in INI?

In the Ini file, you only need to enter the content you want to change according to your menu. As in the example, the program needs to take the value from the button, then we enter the content in the Button one. The contents of the Chinese.ini file in the example are as follows:

[Button]

OK = determined

Cancel = cancellation

[Prompt]

PROMPT = Select language

LANG1 = English

LANG2 = Chinese This is just an example of a dialog. For a software, INI files will not be very complicated. You need to enter the corresponding menu in the Notepad file. Generally, an application contains menus, and title, status bar, etc. Then you need to be as follows:

[Application]

Title = example

[Dialog]; dialog

About Title = About Example

LANG Title = Select language

Lang prompt = Please select a language

OK = determined

Cancel = cancellation

[File Menu]

1000 = & File

1001 = & new; change the content on the post menu

......

1001 = "Open file% new"; change the content of the language status bar,% new means the mapping toolbar

......

What is it, is it relatively simple. And this method has been used more and more software, we might want to try!

转载请注明原文地址:https://www.9cbs.com/read-27774.html

New Post(0)