Antom, leading provider of tailored payment solutions

Customize the language that returns in my.getSystemInfo JSAPI

Customize the language that returns in my.getSystemInfo JSAPI

To return app language but not the system language in my.getSystemInfo JSAPI, implement the GriverAppLanguageExtension.

Note that the format of return value in getAppLanguage is "language-country(region)", where language must follow the ISO 639-1 specification, and country(region) must follow the ISO 3166-1 specification, such as "zh-CN", "en-US".

/**
 * An extension for getting the language of application
 */
public interface GriverAppLanguageExtension extends GriverExtension {

    /**
     * Get the language of application
     *
     * @return The language of the application, use system default language as default If the
     * language of application is different with system, this method should be modified
     */
    String getAppLanguage();
}

Sample Code

GriverAppLanguageExtension

public class CustomAppLanguageExtensionImpl implements GriverAppLanguageExtension {
    @Override
    public String getAppLanguage() {
        return Locale.getDefault().getLanguage() + "-" + Locale.getDefault().getCountry();
    }
}

Register the Extension after Griver is initialized

Griver.registerExtension(new GriverExtensionManifest(
            GriverAppLanguageExtension.class, new CustomAppLanguageExtensionImpl()));