Language
Overview
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 following supported languages and the underlying language display logic of the SDK.
Supported languages
The following table lists the languages supported by the SDK and other key information.
Note: If you require additional language capability for the SDK, contact our technical support at overseas_support@service.alibaba.com.
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 |
SDK provides the my.getSystemInfo JSAPI to mini programs. The mini program can obtain the super app language via the language response parameter and then adjust its language display.
User experience
The following images show a demo menu panel in different languages:
English | Arabic | Spanish |
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.
The SDK also provides a way to customize application resources (Resources
) for super app to configure its language flexibly.
Refer to the following table for the various 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(Support different languages and cultures) to implement multilingual capabilities through system settings. | |
Follow the Android guidelines (Per-app language preferences) to implement multilingual capabilities through per-app language settings. | |
Customize application resources ( | Sync with customization by using the AppSystemResourcesExtension interface |
Sync with system settings
The mini program can switch the system language in the system settings, and the SDK automatically adopts this system language as its default language. This system language is obained by calling the my.getSystemInfo JSAPI via the language response parameter.
Follow the Android official guidelines (Support different languages and cultures) to implement multilingual capabilities through system settings. The SDK dynamically matches the system language without any additional SDK configurations.
The following scenarios are supported 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.
System language | Language returned by the my.getSystemInfo JSAPI | Language used in SDK |
English (default) | English | English |
Arabic | Arabic | Arabic |
Spanish | Spanish | Spanish |
Other language | Other language | English (default) |
Sync with per-app settings
Follow the Android guidelines (Per-app language preferences) to implement multilingual capabilities through per-app language settings.
The SDK dynamically matches the language based on the language order in the LocaleConfig file. The first language in the locale-config
list is the primary language chosen for SDK (see the following code samples).
Similar to the "Sync with system settings" way, it also does not need any additional SDK configurations.
Code samples
Depending on whether the obtained app language is supported by the SDK, the following scenarios are supported:
- 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>
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return resources.getConfiguration().getLocales().get(0);
} else {
Configuration configuration = resources.getConfiguration();
return configuration.locale;
}
Sync with customization by using the AppSystemResourcesExtension interface
IAPMiniProgram SDK can customize application resources (Resources
) for super app to configure its language flexibly. For details, see the AppSystemResourcesExtension topic.