# @embedpdf/react — ./i18n I18N_DEFAULTS [VariableDeclaration] (from packages/plugin/i18n/src/contract.ts): I18N_DEFAULTS: I18nSettings ={ locale: null, fallbackLocale: 'en', locales: NO_LOCALES, loaders: NO_LOADERS, } I18nCapability [InterfaceDeclaration] (from packages/plugin/i18n/src/contract.ts): export interface I18nCapability extends SettingsApi{ t(key: string, options?: TranslateOptions): string; getTranslator(): (key: string, options?: TranslateOptions) => string; hasKey(key: string): boolean; getLocale(): string; getDirection(): TextDirection; listLocales(): readonly LocaleInfo[]; getLoadingLocale(): string | null; setLocale(code: string, options?: OperationOptions): Promise; registerLocale(locale: Locale): Unsubscribe; addTranslations(code: string, translations: TranslationDictionary): void; readonly onLocaleChanged: EventHook; readonly onLocaleLoadFailed: EventHook; } I18nConfig [TypeAliasDeclaration] (from packages/plugin/i18n/src/contract.ts): export type I18nConfig = DeepPartial; I18nSettings [InterfaceDeclaration] (from packages/plugin/i18n/src/contract.ts): export interface I18nSettings{ readonly locale: string | null; readonly fallbackLocale: string; readonly locales: readonly Locale[]; readonly loaders: Readonly>; } I18nState [InterfaceDeclaration] (from packages/plugin/i18n/src/state.ts): export interface I18nState{ readonly locale: string; readonly direction: TextDirection; readonly locales: readonly LocaleInfo[]; readonly loading: string | null; } I18nToken [VariableDeclaration] (from packages/plugin/i18n/src/token.ts): I18nToken = createCapabilityToken('i18n', { hint: `add i18nPlugin() from '@embedpdf/plugin-i18n' to your plugins list`, } ) Locale [InterfaceDeclaration] (from packages/plugin/i18n/src/contract.ts): export interface Locale{ readonly code: string; readonly name: string; readonly direction?: TextDirection; readonly translations: TranslationDictionary; } LocaleChangedEvent [InterfaceDeclaration] (from packages/plugin/i18n/src/contract.ts): export interface LocaleChangedEvent{ readonly locale: string; readonly previousLocale: string; } LocaleInfo [InterfaceDeclaration] (from packages/plugin/i18n/src/contract.ts): export interface LocaleInfo{ readonly code: string; readonly name: string; readonly direction: TextDirection; readonly loaded: boolean; } LocaleLoadFailedEvent [InterfaceDeclaration] (from packages/plugin/i18n/src/contract.ts): export interface LocaleLoadFailedEvent{ readonly locale: string; readonly error: PluginErrorInfo; } LocaleLoader [TypeAliasDeclaration] (from packages/plugin/i18n/src/contract.ts): export type LocaleLoader = () => Promise; TextDirection [TypeAliasDeclaration] (from packages/plugin/i18n/src/contract.ts): export type TextDirection = 'ltr' | 'rtl'; TranslateOptions [InterfaceDeclaration] (from packages/plugin/i18n/src/contract.ts): export interface TranslateOptions{ params?: Readonly>; fallbackKey?: string; fallback?: string; } TranslationDictionary [InterfaceDeclaration] (from packages/plugin/i18n/src/contract.ts): export interface TranslationDictionary{ readonly [key: string]: string | TranslationDictionary; } i18nPlugin [VariableDeclaration] (from packages/plugin/i18n/src/i18n.plugin.ts): i18nPlugin = (config?: I18nConfig) => definePlugin({ id: 'i18n', scope: 'workspace', token: I18nToken, state: initialI18nModel, settings:{ defaults: I18N_DEFAULTS, registered: config} , create: createI18nController, } ) i18nState [VariableDeclaration] (from packages/plugin/i18n/src/state.ts): i18nState = defineState(I18nToken, { read: (i18n): I18nState => ({ locale: i18n.getLocale(), direction: i18n.getDirection(), locales: i18n.listLocales(), loading: i18n.getLoadingLocale(), } ), empty:{ locale: 'en', direction: 'ltr', locales: [], loading: null} , } ) interpolate [FunctionDeclaration] (from packages/plugin/i18n/src/contract.ts): export function interpolate( text: string, params?: Readonly>, ): string{ if (!params) return text; return text.replace(/\{ (\w+)\} /g, (match, slot: string) => params[slot] !== undefined ? String(params[slot]) : match, ); } negotiateLocale [FunctionDeclaration] (from packages/plugin/i18n/src/negotiate.ts): export function negotiateLocale( available: readonly string[], requested: readonly string[], ): string | null{ const byCanonical = new Map(); for (const code of available){ const canonical = code.toLowerCase(); if (!byCanonical.has(canonical)) byCanonical.set(canonical, code); } const languageOf = (code: string) => code.toLowerCase().split('-')[0]; for (const wanted of requested){ const exact = byCanonical.get(wanted.toLowerCase()); if (exact !== undefined) return exact; } for (const wanted of requested){ const narrowed = byCanonical.get(languageOf(wanted)); if (narrowed !== undefined && sameScript(wanted, narrowed)) return narrowed; } for (const wanted of requested){ const language = languageOf(wanted); for (const [canonical, original] of byCanonical){ if (languageOf(canonical) === language && sameScript(wanted, original)) return original; } } return null; } useI18n [FunctionDeclaration]: export function useI18n(): I18nCapability{ return useCapability(I18nToken); } useI18nEvent [FunctionDeclaration]: export function useI18nEvent( select: (i18n: I18nCapability) => EventHook, handler: (event: T) => void, ): void{ useCapabilityEvent(I18nToken, select, handler); } useI18nSettings [VariableDeclaration]: useI18nSettings = settingsHook(I18nToken) useI18nState [VariableDeclaration]: useI18nState = stateHook(i18nState) useT [FunctionDeclaration]: export function useT(): (key: string, options?: TranslateOptions) => string{ return useSelector(I18nToken, (i18n) => i18n.getTranslator()); }