getLocale
Synchronously returns the user's locale. Falls back to 'ko-KR' when the locale cannot be read from the native module. Use it for app localization, date/currency formatting, and language branching logic.
Signature
import { getLocale } from '@apps-in-toss/web-framework';
declare function getLocale(): string;
Parameters
None.
Returns
string— a BCP 47 locale tag (e.g.'ko-KR','en-US'). Returns'ko-KR'if the native module cannot provide a value.
Permission
No permission required — getLocale is not bound to a PermissionName. For the typical permission flow used by other namespaces, see Guides — Permissions pattern.
Examples
Minimal
import { getLocale } from '@apps-in-toss/web-framework';
const locale = getLocale();
console.log('User locale:', locale); // e.g. 'ko-KR'
Realistic — locale-aware date formatting
import { getLocale } from '@apps-in-toss/web-framework';
import { useState, useEffect } from 'react';
function LocalizedDatePage() {
const [formattedDate, setFormattedDate] = useState('');
useEffect(() => {
const locale = getLocale();
const now = new Date();
const formatted = new Intl.DateTimeFormat(locale, {
year: 'numeric',
month: 'long',
day: 'numeric',
}).format(now);
setFormattedDate(formatted);
}, []);
return (
<div>
<p>Today (locale format): {formattedDate}</p>
</div>
);
}
Try it live
Open the Environment page in sdk-example and run the getLocale card to inspect the result.
Related APIs
getPlatformOS— returns the current platform OS.getNetworkStatus— returns the current network status.getOperationalEnvironment— returns the current execution environment.
Related guides
- Guides — Permissions pattern — permission flow used by other namespaces (reference only;
getLocaledoesn't require a permission). - Recipes — Locale-based localization (date / currency / language)
External references
@apps-in-toss/web-framework— SDK package. The actual exports are re-exported from@apps-in-toss/web-bridge.- Web standard counterpart:
navigator.language— returns the browser's language setting, which may differ from the native locale in a mini-app runtime.getLocale()provides a more reliable value in the mini-app context.