Retrieves the current language locale identifier from the device.
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');
}
JSBridge module for accessing device locale settings.
Remarks
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.
Example
ES Module:
Example
CDN (UMD):