@grabjs/superapp-sdk
    Preparing search index...

    Class LocaleModule

    SDK module for accessing device locale settings via JSBridge.

    Provides the user's preferred language and region settings from the native device. This code must run on the Grab SuperApp's WebView to function correctly.

    ES Module:

    import { LocaleModule } from '@grabjs/superapp-sdk';
    const locale = new LocaleModule();

    CDN (UMD):

    <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk@x.y.z/dist/index.js"></script>
    <script>
    const locale = new SuperAppSDK.LocaleModule();
    </script>

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Retrieves the current language locale identifier from the device.

      Returns Promise<GetLanguageLocaleIdentifierResponse>

      This method can return the following status_code values:

      • 200 (OK): Locale identifier retrieved successfully.
      • 204 (No Content): Locale identifier not available.
      • 400 (Bad Request): Invalid request parameters.
      • 500 (Internal Server Error): An unexpected error occurred.
      • 501 (Not Implemented): Requires Grab app environment.
      import { LocaleModule, isSuccess, isError } from '@grabjs/superapp-sdk';

      // Initialize the locale module
      const locale = new LocaleModule();

      // Get the current locale
      const response = await locale.getLanguageLocaleIdentifier();

      // Handle the response
      if (isSuccess(response)) {
      console.log('Current locale:', response.result);
      } else if (isError(response)) {
      console.error(`Error ${response.status_code}: ${response.error}`);
      } else {
      console.error('Unhandled response');
      }