import { Language } from '@automattic/languages'; /** * This regex is defined as a string so that it can be combined with other regexes. * * a locale can consist of three component * aa: language code * -bb: regional code * _cc: variant suffix * while the language code is mandatory, the other two are optional. */ export declare const localeRegexString = "[a-zA-Z]{2,3}(-[a-zA-Z]{2,3})?(_[a-zA-Z]{2,6})?"; export declare function getPathParts(path: string): string[]; /** * Checks if provided locale is a default one. * @param {string} locale - locale slug (eg: 'fr') * @returns {boolean} true when the default locale is provided */ export declare function isDefaultLocale(locale: string | null): boolean; /** * Checks if provided locale has a parentLangSlug and is therefore a locale variant * @param {string} locale - locale slug (eg: 'fr') * @returns {boolean} true when the locale has a parentLangSlug */ export declare function isLocaleVariant(locale: string): boolean; export declare function isLocaleRtl(locale: string): boolean | null; /** * Checks against a list of locales that don't have any GP translation sets * A 'translation set' refers to a collection of strings to be translated see: * https://glotpress.blog/the-manual/translation-sets/ * @param {string} locale - locale slug (eg: 'fr') * @returns {boolean} true when the locale is NOT a member of the exception list */ export declare function canBeTranslated(locale: string): boolean; /** * To be used with the same parameters as i18n-calpyso's translate(): * Check whether the user would be exposed to text not in their language. * * Since the text is in English, this is always true in that case. Otherwise * We check whether a translation was provided for this text. * @returns {boolean} true when a user would see text they can read. */ export declare function translationExists(phrase: string): boolean; /** * Return a list of all supported language slugs * @returns A list of all supported language slugs */ export declare function getLanguageSlugs(): string[]; /** * Map provided language slug to supported slug if applicable. * @param {string} langSlug Locale slug for the language * @returns {string} Mapped language slug */ export declare function getMappedLanguageSlug(langSlug: string | undefined): string | undefined; /** * Return a specifier for page.js/Express route param that enumerates all supported languages. * @param {string} name of the parameter. By default it's `lang`, some routes use `locale`. * @param {boolean} optional whether to put the `?` character at the end, making the param optional * @returns {string} Router param specifier that looks like `:lang(cs|de|fr|pl)` */ export declare function getLanguageRouteParam(name?: string, optional?: boolean): string; /** * Return a specifier for a route param to match anything that looks like a language code, whether it is valid or not. * This is useful for routes that need to match any language, including unsupported ones. * @returns {string} Router param specifier string */ export declare function getAnyLanguageRouteParam(): string; /** * Matches and returns language from config.languages based on the given localeSlug * @param {string} langSlug locale slug of the language to match * @returns {Object | undefined} An object containing the locale data or undefined. */ export declare function getLanguage(langSlug: string | undefined): Language | undefined; /** * Assuming that locale is adding at the end of path, retrieves the locale if present. * @param {string} path - original path * @returns {string|undefined} The locale slug if present or undefined */ export declare function getLocaleFromPath(path: string): string | undefined; /** * Adds a locale slug to the current path. * * Will replace existing locale slug, if present. * @param path - original path * @param locale - locale slug (eg: 'fr') * @returns original path with new locale slug */ export declare function addLocaleToPath(path: string, locale: string): string; /** * Removes the trailing locale slug from the path, if it is present. * '/start/en' => '/start', '/start' => '/start', '/start/flow/fr' => '/start/flow', '/start/flow' => '/start/flow' * @param path - original path * @returns original path minus locale slug */ export declare function removeLocaleFromPath(path: string): string; /** * Filter out unexpected values from the given language revisions object. * @param {Object} languageRevisions A candidate language revisions object for filtering. * @returns valid language revisions object derived from the given one. */ export declare function filterLanguageRevisions(languageRevisions: Record): { [k: string]: string; }; /** * Checks if provided locale is one of the magnificenet non-english locales. * @param locale Locale slug * @returns true when provided magnificent non-english locale. */ export declare function isMagnificentLocale(locale: string): boolean; /** * Checks if provided locale is translated incompletely (is missing essential translations). * @param {string} locale Locale slug * @returns {boolean} Whether provided locale is flagged as translated incompletely. */ export declare function isTranslatedIncompletely(locale: string): boolean; /** * Adds a locale slug infront of the current path. * * Will replace existing locale slug, if present. * @param path - original path * @param locale - the locale to add to the path (Optional) * @returns original path with new locale slug */ export declare function addLocaleToPathLocaleInFront(path: string, locale?: string): string; /** * Removes the locale slug in the start of the path, if it is present. * '/en/themes' => '/themes', '/themes' => '/themes', '/fr/plugins' => '/plugins' * @param path - original path * @returns original path minus locale slug */ export declare function removeLocaleFromPathLocaleInFront(path: string): string; /** * Retrieve the locale slug in the start of the path, if it is present. * '/en/themes' => 'en', '/themes' => 'en', '/fr/plugins' => 'fr' * @param path - original path * @returns locale */ export declare function retrieveLocaleFromPathLocaleInFront(path: string): string; //# sourceMappingURL=utils.d.ts.map