@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
162 lines (161 loc) • 7.28 kB
TypeScript
import { AnyString, Dict, Path, Value } from "../../utils/index.js";
import { TextDirection } from "../../core/system/index.types.js";
import "../../core/index.js";
import { IcuArgs } from "./icu.types.js";
import _default, { DefaultIntlData } from "./intl/index.js";
import * as react73 from "react";
import { FC, ReactNode } from "react";
import { Formats, Options } from "intl-messageformat";
//#region src/providers/i18n-provider/i18n-provider.d.ts
interface Language {
dir: TextDirection;
locale: string;
}
declare const LOCALES: readonly Locale[];
declare function getLanguage(locale?: string, dir?: TextDirection): Language;
type IntlData = DefaultIntlData;
type IntlKey = keyof IntlData;
type IntlPath = Path<IntlData>;
type Locale = keyof typeof _default;
type Translation<Y extends object = IntlData, M extends string = IntlPath> = <D extends M>(path: D, ...args: IcuArgs<Value<Y, D>> extends never ? [replaceValues?: IcuArgs<Value<Y, D>, IntlPath | M>] : [replaceValues: IcuArgs<Value<Y, D>, IntlPath | M>]) => string;
interface I18nContext<Y extends object = IntlData, M extends string = IntlPath> extends Language {
changeLanguage: (locale?: string, dir?: TextDirection) => void;
getTranslation: (key?: IntlKey) => Translation<Y, M>;
t: Translation<Y, M>;
}
declare const I18nContext: react73.Context<I18nContext<{
readonly autocomplete: {
readonly "Clear value": "Clear value";
readonly "No results found": "No results found";
};
readonly avatar: {
readonly "Avatar Icon": "Avatar Icon";
};
readonly breadcrumb: {
readonly Breadcrumb: "Breadcrumb";
readonly Ellipsis: "Ellipsis";
};
readonly calendar: {
readonly "Choose the month": "Choose the month";
readonly "Choose the year": "Choose the year";
readonly "Go to the next month": "Go to the next month";
readonly "Go to the previous month": "Go to the previous month";
readonly Today: "Today";
};
readonly carousel: {
readonly "Go to next slide": "Go to next slide";
readonly "Go to previous slide": "Go to previous slide";
readonly "Go to {page} slide": "Go to {page} slide";
readonly Slides: "Slides";
readonly "{page} of {total}": "{page} of {total}";
};
readonly closeButton: {
readonly Close: "Close";
};
readonly colorPicker: {
readonly "Pick a color": "Pick a color";
};
readonly colorSelector: {
readonly "Pick a color": "Pick a color";
};
readonly datePicker: {
readonly "Clear value": "Clear value";
};
readonly hueSlider: {
readonly Blue: "Blue";
readonly Cyan: "Cyan";
readonly Green: "Green";
readonly Magenta: "Magenta";
readonly Red: "Red";
readonly Yellow: "Yellow";
};
readonly modal: {
readonly "Close modal": "Close modal";
readonly "Open modal": "Open modal";
};
readonly numberInput: {
readonly Decrease: "Decrease";
readonly Increase: "Increase";
};
readonly pagination: {
readonly "Go to first page": "Go to first page";
readonly "Go to last page": "Go to last page";
readonly "Go to next page": "Go to next page";
readonly "Go to page {value}": "Go to page {value}";
readonly "Go to previous page": "Go to previous page";
readonly Pagination: "Pagination";
readonly "{value} / {total}": "{value} / {total}";
readonly "{value} of {total}": "{value} of {total}";
};
readonly passwordInput: {
readonly "Password strength meter": "Password strength meter";
readonly "Toggle password visibility": "Toggle password visibility";
};
readonly progress: {
readonly "Loading...": "Loading...";
readonly "{value} percent": "{value} percent";
};
readonly saturationSlider: {
readonly "Saturation and brightness thumb": "Saturation and brightness thumb";
readonly "Saturation {saturation}%, Brightness {brightness}%": "Saturation {saturation}%, Brightness {brightness}%";
};
readonly select: {
readonly "Clear value": "Clear value";
};
readonly slider: {
readonly "Slider thumb": "Slider thumb";
};
readonly stat: {
readonly "Decreased by": "Decreased by";
readonly "Increased by": "Increased by";
};
readonly table: {
readonly "Clear sorting": "Clear sorting";
readonly "Page size": "Page size";
readonly "Select all rows": "Select all rows";
readonly "Select row": "Select row";
readonly "Sort ascending": "Sort ascending";
readonly "Sort descending": "Sort descending";
};
readonly tag: {
readonly "Close tag": "Close tag";
};
readonly toggle: {
readonly "Toggle button": "Toggle button";
};
}, "progress.Loading..." | "progress.{value} percent" | "select.Clear value" | "table.Clear sorting" | "table.Page size" | "table.Select all rows" | "table.Select row" | "table.Sort ascending" | "table.Sort descending" | "toggle.Toggle button" | "modal.Close modal" | "modal.Open modal" | "slider.Slider thumb" | "calendar.Choose the month" | "calendar.Choose the year" | "calendar.Go to the next month" | "calendar.Go to the previous month" | "calendar.Today" | "autocomplete.Clear value" | "autocomplete.No results found" | "avatar.Avatar Icon" | "breadcrumb.Breadcrumb" | "breadcrumb.Ellipsis" | "carousel.Go to next slide" | "carousel.Go to previous slide" | "carousel.Go to {page} slide" | "carousel.Slides" | "carousel.{page} of {total}" | "closeButton.Close" | "colorPicker.Pick a color" | "colorSelector.Pick a color" | "datePicker.Clear value" | "hueSlider.Blue" | "hueSlider.Cyan" | "hueSlider.Green" | "hueSlider.Magenta" | "hueSlider.Red" | "hueSlider.Yellow" | "numberInput.Decrease" | "numberInput.Increase" | "pagination.Go to first page" | "pagination.Go to last page" | "pagination.Go to next page" | "pagination.Go to page {value}" | "pagination.Go to previous page" | "pagination.Pagination" | "pagination.{value} / {total}" | "pagination.{value} of {total}" | "passwordInput.Password strength meter" | "passwordInput.Toggle password visibility" | "saturationSlider.Saturation and brightness thumb" | "saturationSlider.Saturation {saturation}%, Brightness {brightness}%" | "stat.Decreased by" | "stat.Increased by" | "tag.Close tag">>;
interface I18nProviderProps {
children?: ReactNode;
/**
* The text direction to apply to the application.
*
* If not provided, the direction will be determined by the locale.
*/
dir?: TextDirection;
/**
* The formats to pass to the `intlMessageFormat` instance.
*/
formats?: Formats;
/**
* The internationalization messages to apply to the application.
*
* This prop expects a dictionary object where the keys are locale strings (e.g., "en-US").
*/
intl?: Dict;
/**
* The options to pass to the `intlMessageFormat` instance.
*/
intlMessageFormatOptions?: Options;
/**
* The locale to apply to the application.
*
* If not provided, the locale will be determined by the browser.
*/
locale?: AnyString | Locale;
}
declare const I18nProvider: FC<I18nProviderProps>;
declare function useI18n(): I18nContext;
declare function useI18n<Y extends IntlKey>(key: Y): I18nContext<IntlData[Y], Path<IntlData[Y]>>;
//#endregion
export { I18nContext, I18nProvider, I18nProviderProps, LOCALES, Language, Locale, getLanguage, useI18n };
//# sourceMappingURL=i18n-provider.d.ts.map