/** * Locale Resolution Utilities * * Cascade for resolving locale/language preferences, so developers can set it * per-component, per-section, per-page, or fall back to the browser default. */ /** * 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;