Skip to main content

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.

Open in sdk-example

External references