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

    Class LocaleModule

    JSBridge module for accessing device locale settings.

    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/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>

      The user's preferred language locale string (e.g., 'en-SG', 'id-ID').

      Simple usage

      import { LocaleModule, isSuccess, isErrorResponse } 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 (isErrorResponse(response)) {
      console.error(`Error ${response.status_code}: ${response.error}`);
      } else {
      console.error('Unhandled response');
      }