-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
22 lines (17 loc) · 806 Bytes
/
Copy pathindex.ts
File metadata and controls
22 lines (17 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { en, type Messages } from './en';
export type { Messages };
/** Supported locales. Add a code here when a sibling dictionary lands. */
export type Locale = 'en';
const dictionaries: Record<Locale, Messages> = { en };
/**
* Resolves the message catalog for a locale. This is the single seam for going
* multilingual: drop a sibling dictionary (e.g. `ur.ts`), add it to `Locale`
* and `dictionaries`, then wire locale detection (Accept-Language header,
* cookie, or a `/[locale]` route segment) and call `getMessages(detected)`.
* No component changes required.
*/
export function getMessages(locale: Locale = 'en'): Messages {
return dictionaries[locale];
}
/** The active catalog. Swap for a per-request `getMessages(locale)` when i18n lands. */
export const messages = getMessages();