import React from 'react'; import { I18nFormatArgTypes } from './messages-types'; export type CustomHandler = (formatFn: (args: FormatFnArgs) => string) => ReturnValue; export interface FormatFunction { (namespace: string, component: string, key: string, provided: string): string; (namespace: string, component: string, key: string, provided: string | undefined): string | undefined; (namespace: string, component: string, key: string, provided: T, handler?: CustomHandler): T; } interface InternalI18nContextProps { locale: string | null; format: FormatFunction; } export declare const namespace = "cloudscape-design-components"; export declare const InternalI18nContext: React.Context; export declare function useLocale(): string | null; /** * Utility to get "keyof T" but exclude number or symbol types. * TypeScript allows those types because JS implicitly casts them to string. */ type StringKeyOf = Extract; export interface GenericI18nFormatArgTypes { [componentName: string]: { [messageKey: string]: Record | never; }; } export interface GenericI18nFormatFunction = StringKeyOf> { >(key: MessageKey, provided: string, handler?: CustomHandler): string; >(key: MessageKey, provided: string | undefined, handler?: CustomHandler): string | undefined; , ReturnValue>(key: MessageKey, provided: ReturnValue, handler: NamespaceTypes[ComponentName][MessageKey] extends never ? never : CustomHandler): ReturnValue; } export type I18nFormatFunction = StringKeyOf> = GenericI18nFormatFunction; export type ComponentFormatFunction> = I18nFormatFunction; /** * Public hook for third-party component libraries to resolve translations * through I18nProvider under their own namespace. */ export declare function useCustomI18n = StringKeyOf>(namespace: string, componentName: ComponentName): I18nFormatFunction; export declare function useInternalI18n>(componentName: ComponentName): ComponentFormatFunction; export {};