Language
IAPMiniProgram SDK can dynamically adjust the language display based on the user's language preference to support different languages and cultures. This language adaptation applies to all SDK-provided pages, which include:
- Pages within the more menu, such as Settings and About
- JSAPI-triggered pages, such as the alert box from my.alert
- Other common pages, such as the splash screen and error pages
This topic mainly introduces the supported languages and the underlying language display logic of the SDK.
Note: Mini programs can also dynamically adjust their language display by calling the my.getSystemInfo JSAPI to obtain the user's language preference via the language response parameter. For more information, refer to my.getSystemInfo.
Supported languages
The following table lists the languages supported by the SDK and other key information:
Supported language | LanguageTag | Layout direction | Required SDK version |
English (default) | en | LTR (left-to-right) | All versions |
Arabic | ar | RTL (right-to-left) | v2.50.2 or later |
Spanish | es | LTR (left-to-right) | v2.50.3 or later |
If you require additional language capability for the SDK, contact our technical support at overseas_support@service.alibaba.com.
User experience
The following images show a demo menu panel in English and Arabic:
English | Arabic |
Language display logic
The SDK language display can sync with the language preference in either the system settings or the per-app settings on the user's device. The display logic is automatically employed depending on how the super app implements multilingual capabilities without requiring any additional actions. Refer to the following table for the language display logic that corresponds to your app's specific implementation:
Implementation scenario | Language display logic |
Not implement multilingual capabilities. | |
Not follow Android guidelines to implement multilingual capabilities. | |
Follow Android guidelines to implement multilingual capabilities through system settings. For more information, refer to the Android documentation on Support different languages and cultures. | |
Follow the Android guidelines to implement multilingual capabilities through per-app language settings. For more information, refer to the Android documentation on Per-app language preferences. |
Sync with system settings
You can expect the following two scenarios for this display logic:
- If the system language is supported by the SDK, the SDK display language matches the system language.
- If the system language is not supported by the SDK, the SDK display language is English by default.
Sync with per-app settings
For this display logic, the SDK obtains the primary app language preference in the LocaleConfig file using the following code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return resources.getConfiguration().getLocales().get(0);
} else {
Configuration configuration = resources.getConfiguration();
return configuration.locale;
}
Depending on whether the obtained app language is supported by the SDK, you can expect the following two scenarios:
- If the app language is supported, the SDK display language matches the app language.
- If the app language is not supported, the SDK display language is English by default.
Therefore, when the LocaleConfig file is configured as follows, the obtained app language is English, which is supported by the SDK and consequently used as the SDK display language.
<?xml version="1.0" encoding="utf-8"?>
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
<locale android:name="en-US"/>
<locale android:name="en-GB"/>
<locale android:name="fr"/>
<locale android:name="ja"/>
<locale android:name="zh-Hans-MO"/>
<locale android:name="zh-Hant-MO"/>
</locale-config>