Updated on 2024-07-30 GMT+08:00

Setting the Language

setLanguage

API Description

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

Precautions

To customize a language, create the corresponding internationalization file under /src/main/res/ of the main project. For example, to add Arabic, you can create /values-ar/string.xml. Refer to the language templates in the languagetemplates folder. The language set through this API must be the same as the system language.

Figure 1 Internationalization language templates

Method Definition

void setLanguage(LanguageType languageType, String language);

Parameter Description

Table 1 Parameter description

Parameter

Mandatory

Type

Description

languageType

Yes

LanguageType

Enumerated values of languages.

language

Yes

String

If LanguageType is set to Chinese or English, this parameter can be left empty or set to any value.

If LanguageType is set to other languages, set this parameter to the language code, for example, ar (Arabic).

Table 2 Enumerated values of LanguageType

Enumerated Value

Description

LANGUAGE_TYPE_CN_ZH

Chinese.

LANGUAGE_TYPE_EN

English.

LANGUAGE_TYPE_CUSTOMIZED

Custom language.

Return Values

None

Sample Code

// Specify the enumerated value if you set the language to Chinese or English.
HWMSdk.getOpenApi(this).setLanguage(LanguageType.LANGUAGE_TYPE_EN, "");

// If you set the language to other languages, add the language code, for example, ar for Arabic, and add the Arabic translation files to the resource folder of the main project.
HWMSdk.getOpenApi(this).setLanguage(LanguageType.LANGUAGE_TYPE_CUSTOMIZED, "ar");