studiocms
Version:
Astro Native CMS for AstroDB. Built from the ground up by the Astro community.
49 lines (48 loc) • 2.21 kB
TypeScript
/**
* This file is responsible for managing translation files.
*
* It provides utilities to work with translation keys and their corresponding
* file paths.
*
* Note: The exported function is imported and used by the main index of the integration,
* to generate the list of available translation keys and inject them into a server/client
* friendly Vite virtual module.
*
* If you are interested in contributing to the translation effort, please visit our Crowdin project:
* https://crowdin.com/project/studiocms or submit a pull request to the `translations` folder:
* `packages/studiocms/src/virtuals/i18n/translations/` on https://github.com/withstudiocms/studiocms
*/
import type { LanguageFlagIdentifier, ServerUiTranslations } from './config.js';
/**
* An array of translation file keys derived from `availableTranslationFiles`.
* Each key is generated by removing the `.json` extension from the file name.
* Falsy values are filtered out from the resulting array.
*
* @example
* // If availableTranslationFiles = ['en.json', 'fr.json']
* // availableTranslationFileKeys = ['en', 'fr']
*/
export declare const availableTranslationFileKeys: string[];
/**
* Loads and returns the available server-side UI translations, excluding English ('en').
* For each translation file key, reads the corresponding JSON file, checks its string values,
* and includes it in the results only if it passes the threshold check.
* Skips translation files with too many empty strings and logs a warning.
*
* @returns {ServerUiTranslations} An object mapping language keys to their translation records.
*/
export declare const availableTranslations: ServerUiTranslations;
/**
* An array of language flags derived from `availableTranslationsKeys`.
* Each flag is generated by mapping the key to a corresponding icon from
* the `@iconify-json/circle-flags` package. And allows overriding default flags
* using the `translationFlagKeyOverrides`.
*
* @example
* // If availableTranslationsKeys = ['en', 'fr']
* // langFlags = [{ key: 'en', flag: 'lang-en-us' }, { key: 'fr', flag: 'lang-fr' }]
*/
export declare const currentFlags: Array<{
key: string;
flag: LanguageFlagIdentifier;
}>;