Language adaptation

To provide a seamless user experience, the IAPMiniProgram SDK supports language adaptation, which dynamically adjusts the language displayed within the mini program based on the user's preferred language.

This topic explains how language adaptation works for the following primary categories of content that end users will see:

  • SDK-provided UI content: Built-in pages, dialogs, system messages, and other UI provided by the SDK.
  • Mini program information: Basic information managed on Mini Program Platform, including the mini program's name and description.
  • Content from mini program package: Business pages, components, text, and assets inside the mini program package.

SDK-provided UI content

SDK-provided UI content consists of interface elements provided directly by the IAPMiniProgram SDK. This content typically includes:

  • Pages within the More menu, such as Settings and About
  • JSAPI-triggered pages and components, such as the alert dialog triggered by my.alert
  • Common SDK pages, such as the splash screen and error pages

Supported languages

The following table lists the languages supported by the SDK for SDK-provided UI content:

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.0 or later

Spanish

es

LTR (left-to-right)

v2.50.2 or later

Note: If you require additional language capability for the SDK, contact our technical support.

User experience

The following images demonstrate the SDK's menu panel adapted for English and Arabic:

English

Arabic

image

image

Runtime display logic

For SDK-provided UI content, the SDK automatically determines the display language using the following logic:

  1. The SDK obtains the user's preferred language. For more information, see Logic for obtaining user's preferred language.
  2. The SDK checks if the language is supported by the SDK version (as listed in the Supported languages table).
  3. The SDK displays content as follows:
    • If supported: The SDK UI matches the user's preferred language.
    • If not supported: The SDK defaults to English.

Mini program information

Mini program information is the basic information of a mini program, including its name, description, and tagline. This information is entered by mini program owners on Mini Program Platform.

Supported languages

The supported languages for mini program information vary by mini program. They depend on two factors:

  • Languages allowed by the super app

By default, mini program developers can enter information in any language supported by Mini Program Platform. However, a super app can restrict the languages that mini programs are allowed to use for information entry at a platform level. For more information, see Customize information display languages.

  • Languages provided by the mini program

Even if multiple languages are allowed, a mini program may choose to provide information in only some of those languages.

Example

Suppose a super app only allows mini programs to enter information in the following languages:

  • English (US)
  • Chinese (China Mainland)

If a mini program only enters its information in Chinese (China Mainland), then the mini program information for that specific mini program only supports Chinese. In this case, even if the user's preferred language is English, the SDK can only display the mini program information in Chinese unless the mini program provides English information in its new versions.

Runtime display logic

For mini program information, the SDK automatically determines the display language using the following logic:

  1. The SDK obtains the user's preferred language. For more information, see Logic for obtaining user's preferred language.
  2. The SDK checks whether the mini program has information available in that language.
  3. The SDK displays the mini program information in the first matching language based on a fallback chain as follows:
    • Exact language variant match
    • Same base language, different variant match
    • Default language set by the mini program

For the complete and detailed logic, refer to Localize mini program information: Language display logic.

Content from mini program package

Mini program package content includes all user interface and business content within the mini program. It is created and packaged by mini program developers.

Supported languages

The supported languages of a mini program are entirely determined by its developers. Developers must implement internationalization (i18n) within their mini program's code and provide the corresponding language resource files.

Runtime display logic

The language adaptation logic for the mini program's content is implemented by the mini program developers. To help developers build this logic, the SDK provides the my.getSystemInfo JSAPI for mini programs to obtain the user's preferred language via the language response parameter.

Example implementation

A mini program can use the following logic:

  1. Call the my.getSystemInfo JSAPI.
  2. Read the language value from the response.
  3. Check whether the mini program supports that language:
    • If supported: Load the matching language resources.
    • If not supported: Fall back to the mini program's default language.

The exact implementation is determined by the mini program developer.