UNPKG

@intl-t/next

Version:

A Fully-Typed Object-Based i18n Translation Library for Next.js

65 lines (64 loc) 4.22 kB
import type { TranslationSettings } from "@intl-t/core/types"; import type { Locale } from "@intl-t/locales"; import { ResolveConfig, resolvePath } from "@intl-t/tools/resolvers"; import { redirect as r, permanentRedirect as pr, RedirectType } from "next/navigation"; import type { FC } from "react"; import { LinkConfig, NL } from "./link"; import { MiddlewareConfig } from "./middleware"; import { StaticParamsConfig } from "./params"; import { RouterConfig } from "./router"; export * from "@intl-t/tools/match"; export * from "@intl-t/tools/negotiator"; export * from "@intl-t/tools/resolvers"; export * from "./link"; export * from "./middleware"; export * from "./params"; export * from "./router"; export * from "./state"; export declare function resolvedRedirect(href?: string, type?: RedirectType): never; export declare function resolvedPermanentRedirect(href?: string, type?: RedirectType): never; export declare const redirect: typeof r; export declare const permanentRedirect: typeof pr; export interface IntlConfig<L extends Locale = Locale, T extends FC<any> = NL> extends ResolveConfig<L>, StaticParamsConfig<L>, MiddlewareConfig<L>, RouterConfig<L>, LinkConfig<T> { settings?: Partial<TranslationSettings<L>>; } export declare function createNavigation<L extends Locale, LC extends FC<any>>(config?: IntlConfig<L, LC>): { config: IntlConfig<L, LC>; useRouter: typeof import("next/navigation").useRouter; Link: ({ href, locale, currentLocale, config, Link, preventDynamic, ...props }: import("./link").LinkProps<L, import("react").ForwardRefExoticComponent<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & { children?: React.ReactNode | undefined; } & import("react").RefAttributes<HTMLAnchorElement>>> & Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & { children?: React.ReactNode | undefined; } & import("react").RefAttributes<HTMLAnchorElement>, keyof import("./link").LinkProps<Locale, import("react").ForwardRefExoticComponent<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & { children?: React.ReactNode | undefined; } & import("react").RefAttributes<HTMLAnchorElement>>>>) => Promise<import("react/jsx-runtime").JSX.Element>; redirect: typeof r; permanentRedirect: typeof pr; getLocale: { (preventDynamic: true, defaultLocale?: L | undefined): L | undefined; (preventDynamic?: boolean, defaultLocale?: L | undefined): L | Promise<L> | undefined; }; setLocale: (locale: L) => string | undefined; resolvePath: typeof resolvePath; resolveHref: (href?: string, { locale, currentLocale, redirectPath, config, allowedLocales, pathPrefix, defaultLocale, getLocale, }?: import("@intl-t/tools/resolvers").LocalizedHref<L> | undefined) => (`/${string}` | `/${L}${string}`) & Promise<`/${string}` | `/${L}${string}`>; resolveLocale: (path?: string, locales?: L[] | undefined) => L | undefined; match: typeof import("@intl-t/tools/match").match; middleware: import("./middleware").Middleware & MiddlewareConfig<L> & import("next/server").MiddlewareConfig; withMiddleware: import("./middleware").MiddlewareFactory; generateStaticParams: () => Promise<{ [x: string]: Locale; }[]>; useLocale: (defaultLocale?: L | null | undefined, { hydration, path, }?: { hydration?: boolean; path?: string; }) => L & import("@intl-t/react").ReactState<L> & { locale: L; setLocale: import("@intl-t/react").ReactSetState<L>; }; usePathname: typeof import("next/navigation").usePathname; getPathname: typeof import("./headers").getHeadersRequestPathname | typeof import("next/navigation").usePathname; settings: IntlConfig<L, LC> & Partial<TranslationSettings<L, L, unknown, import("@intl-t/core/types").Values, string, import("@intl-t/core/types").Node>>; allowedLocales: L[] | readonly L[] | undefined; locales: L[] | readonly L[]; locale: L; };