Language switching function
Function description
When using wincc to develop a project some time ago, the customer needed to add a language switching function. This function can be realized in the form of a button.
Implementation process
1. Screen configuration
Add buttons in the screen to control language switching
2. Add script
Mainly add two function scripts, the scripts are as follows
//用于切换语言时,按钮显示不同的图标
if (GetLanguage ()==0x0804)
return "矢量图库\\主页中文.svg";
else
if (GetLanguage ()==0x0409)
return "矢量图库\\主页英语.svg";
Used for button events
//判断当前系统语言,如果是中文,则切换为英语,如果时英语,则切换为中文
if (GetLanguage ()==0x0409)
{
SetLanguage(0x0804);
SetTagChar("@Language","C");
}
else
{
SetLanguage(0x0409);
SetTagChar("@Language","E");
}
3. Add text
Add the text corresponding to the text in the screen in different languages
Script extension
GetLanguage ()
Usage of the Getlanguage function in the script: It is mainly used to establish the language of the current running system.
Read out the instance of the current running system language
{
DWORD rt_language;
rt_language = GetLanguage ();//获得当前语言
//自定义代码
//在那里用户可以使用返回值做某事```
}
1). Read the current operating system language and buffer it in rt_language.
2). Execute custom code that handles the return value.
SetLanguage(DWORD dwLocaleI)
Change the language setting in the runtime system
{
SetLanguage(0x0407);//德语
}
The operating language of the system is set to German
PS: the formal parameter in the function is the system language ID, and the system language ID table is as follows