@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
61 lines (59 loc) • 2.07 kB
TypeScript
/// <reference types="react" />
import { h } from 'preact';
/**
* Matches a string with one of the locales
* @param locale -
* @param supportedLocales -
* @example
* matchLocale('en-GB');
* // 'en-US'
*/
export declare function matchLocale(locale: string, supportedLocales: any): string;
/**
* Returns a locale with the proper format
* @param localeParam -
*
* @example
* formatLocale('En_us');
* // 'en-US'
*/
export declare function formatLocale(localeParam: string): string;
/**
* Checks the locale format.
* Also checks if it's on the locales array.
* If it is not, tries to match it with one.
* @param locale -
* @param supportedLocales -
*/
export declare function parseLocale(locale: string, supportedLocales?: string[]): string;
/**
* Formats the locales inside the customTranslations object against the supportedLocales
* @param customTranslations -
* @param supportedLocales -
*/
export declare function formatCustomTranslations(customTranslations: object, supportedLocales: string[]): object;
/**
* Returns a translation string by key
* @param translations -
* @param key -
* @param options -
*
* @internal
*/
export declare const getTranslation: (translations: object, key: string, options?: {
[key: string]: any;
}) => string;
/**
* Returns an Object which contains all the key/values of the translation labels
*
* @param locale - The locale the user wants to use
* @param customTranslations - Custom translations provided by the merchant
*/
export declare const loadTranslations: (locale: string, customTranslations?: object) => Promise<Record<string, string>>;
/**
* Injects JSX elements in a middle of a translation and returns a JSX array
* The input string should use %# as the token to know where to insert the component
* @param translation - Translation string
* @param renderFunctions - An array function that renders JSX elements
*/
export declare const interpolateElement: (translation: string, renderFunctions: ((translation: string) => h.JSX.Element | string)[]) => (string | h.JSX.Element)[];