Updated on 2023-03-27 GMT+08:00

Setting the Language

SetLanguage

API Description

This API is used to set the GUI language. The default language is Chinese.

Precautions

This API is an asynchronous API. The return value only indicates whether the API is successfully called. The actual service processing result is returned in the corresponding callback function.

Method Definition

1
HWM_SDK_AGENT_API hwmsdk::HwmErrCode SetLanguage(HwmLanguage language);

Callback Function

1
virtual void OnSetLanguageResult(hwmsdk::HwmErrCode ret, const char* reason) {};

Parameter Description

Table 1 Parameter description

Parameter

Mandatory

Type

Description

language

Yes

HwmLanguage

GUI language.

Table 2 Enumerated values of HwmLanguage

Enumerated Value

Description

HWM_LANGUAGE_ZH_CN

Chinese.

HWM_LANGUAGE_EN_GB

English.

HWM_LANGUAGE_CUSTOMIZED

Custom language.

Return Values

Table 3 Return values

Type

Description

HwmErrCode

If 0 is returned, the operation is successful. If other values are returned, the operation fails. For details about values returned upon failures, see Common Error Codes.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
/**
* Change the language.
*/
void demoSettingDlg::OnBnClickedButtonSetLanCode()
{
    // Set the language to Chinese.
    hwmsdkagent::HwmLanguage languageCode = hwmsdkagent::HWM_LANGUAGE_ZH_CN;
 
    int ret = hwmsdkagent::SetLanguage((hwmsdkagent::HwmLanguage)languageCode);
    if (hwmsdk::HWM_COMMON_SUCCESS != ret)
    {
        AfxMessageBox(_T("SetLanguage error"));
    }
}

SetLanguageWithCode

API Description

This API is used to customize the SDK language. The default language is Chinese.

Precautions

  1. To customize a language, create the corresponding internationalization files in \HwmSdk\sdkResources\language\. For example, create \ar\temp.js when you set the SDK language to Arabic. The language set using this API must be the same as the system language.
  2. This API is an asynchronous API. The return value only indicates whether the API is successfully called. The actual service processing result is returned in the corresponding callback function.

Method Definition

1
HWM_SDK_AGENT_API hwmsdk::HwmErrCode SetLanguageWithCode(HwmLanguage language, const char* languageCode);

Callback Function

1
virtual void OnSetLanguageResult(hwmsdk::HwmErrCode ret, const char* reason) {};

Parameter Description

Table 4 Parameter description

Parameter

Mandatory

Type

Description

language

Yes

HwmLanguage

GUI language.

languageCode

No

char[]

Language code. If the language is Chinese or English, this parameter can be left empty.

Return Values

Table 5 Return values

Type

Description

HwmErrCode

If 0 is returned, the operation is successful. If other values are returned, the operation fails. For details about values returned upon failures, see Common Error Codes.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
/**
* Change the language.
*/
void demoSettingDlg::OnBnClickedButtonSetLanCode()
{
    // Set the language to a custom language. Arabic is used as an example.
    hwmsdkagent::HwmLanguage languageCode = hwmsdkagent::HWM_LANGUAGE_CUSTOMIZED;
    CString code = "ar";
    int ret = hwmsdkagent::SetLanguageWithCode((hwmsdkagent::HwmLanguage)languageCode, CTools::UNICODE2UTF(code).c_str());
    if (hwmsdk::HWM_COMMON_SUCCESS != ret)
    {
        AfxMessageBox(_T("SetLanguageWithCode error"));
    }
}