/** * Locale Resolution Utilities * * Provides a cascade system for resolving locale/language preferences: * 1. Component's explicit `locale` attribute (highest priority) * 2. Closest ancestor's `lang` attribute * 3. Document root's `lang` attribute * 4. Browser's language preference * 5. 'en-US' fallback (lowest priority) * * This allows developers to set locale at any level: * - Per-component: * - Per-section:
* - Per-page: * - Browser default: Uses navigator.language * * @example * ```typescript * // In a component * class TyInput extends HTMLElement { * get locale(): string { * return getEffectiveLocale(this, this.getAttribute('locale')); * } * } * ``` */ /** * Get the effective locale for an element using the resolution cascade. * * Resolution order: * 1. Explicit locale attribute on the element * 2. Closest ancestor element with a `lang` attribute * 3. Document root element's `lang` attribute * 4. Browser's navigator.language * 5. Fallback to 'en-US' * * @param element - The element to get locale for * @param explicitLocale - Optional explicit locale value (from component's locale attribute) * @returns The resolved locale string (e.g., 'en-US', 'fr-FR') * * @example * ```html * *
* * *
* * * ``` */ export declare function getEffectiveLocale(element: HTMLElement, explicitLocale?: string | null): string; /** * Create a MutationObserver to watch for lang attribute changes. * Useful for components that need to react to dynamic locale changes. * * @param element - The element to observe * @param callback - Function to call when lang changes * @returns Cleanup function to disconnect the observer * * @example * ```typescript * class TyInput extends HTMLElement { * private _localeObserver?: () => void; * * connectedCallback() { * this._localeObserver = observeLocaleChanges(this, () => { * this.render(); // Re-render when locale changes * }); * } * * disconnectedCallback() { * this._localeObserver?.(); * } * } * ``` */ export declare function observeLocaleChanges(element: HTMLElement, callback: (newLocale: string) => void): () => void; //# sourceMappingURL=locale.d.ts.map