UNPKG

@adyen/kyc-components

Version:

This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.

52 lines (50 loc) 2.22 kB
import type { Namespace, NsTranslatable, NsTranslationKey, NsTranslationObject, TFunction, Translations } from '../../types'; import type { CountryCode } from '../types/datasets/country-code'; /** * Matches a string with one of the locales * @example * matchLocale('en-GB'); * // 'en-US' */ export declare const matchLocale: (locale: string, supportedLocales: string[]) => string | null; /** * Returns a locale with the proper format * * @example * formatLocale('En_us'); * // 'en-US' */ export declare function formatLocale(localeParam: string): string | null; /** * Checks the locale format. * Also checks if it's on the locales array. * If it is not, tries to match it with one. */ export declare function parseLocale(locale: string, supportedLocales?: string[]): string | null; export declare const replaceTranslationValues: (translation: string, values?: Record<string, string | number | undefined>) => string; export interface GetTranslationOptions { localizeFor?: CountryCode; values?: Record<string, string | number | undefined>; } /** * Returns a translation string by key */ export declare const getTranslationByKey: (translations: Translations, key: NsTranslationKey<"common">, options?: GetTranslationOptions) => string | null; /** * Returns a LanguageCode from locale * @param locale - The locale the user wants to use * * @example for getLanguageCode('en-US') * // returns 'en' */ export declare const getLanguageCode: (locale: string) => string; export declare const isTranslationObject: <Ns extends Namespace>(value: unknown) => value is NsTranslationObject<Ns>; /** * A helper function to translate a `Translatable` type, which can be either a simple string key * or an object with a key and values for interpolation. It uses the provided `i18next` `t` function. * * @param t - The `i18next` translation function. * @param translatable - The string or object to translate. * @returns The translated string. */ export declare const translateTranslatable: <Ns extends Namespace, tNs extends Ns>(t: TFunction<Ns extends readonly Namespace[] ? Ns[0] : Ns>, translatable: NsTranslatable<tNs extends readonly Namespace[] ? tNs[0] : tNs> | undefined) => string | undefined;