UNPKG

studiocms

Version:

Astro Native CMS for AstroDB. Built from the ground up by the Astro community.

508 lines (507 loc) 19.6 kB
/** * This module handles the internationalization (i18n) config for the StudioCMS application for both the Client and Server sides. * * 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 */ /** * The default language for the StudioCMS app. */ export declare const defaultLang: UiTranslationKey; /** * Dynamically imports the base English translations for server-side internationalization. * * @remarks * This constant loads the default English translation JSON file asynchronously at runtime. * It is intended to be used as the base set of translations for the server. * * - These translations are also converted to a client-friendly format. */ export declare const baseServerTranslations: { displayName: string; translations: { "@studiocms/auth:login": { title: string; description: string; header: string; "sub-header-usernamepasswordoauth": string; "sub-header-usernamepassword": string; "sub-header-oauth": string; "sub-header-noprovider": string; "username-label": string; "password-label": string; "login-button": string; "allow-registration-noaccount": string; "allow-registration-register": string; "forgot-password": string; "forgot-password-title": string; "forgot-password-message": string; "email-label": string; "demo-mode-credentials": string; }; "@studiocms/auth:signup": { title: string; description: string; header: string; "sub-header-usernamepasswordoauth": string; "sub-header-usernamepassword": string; "sub-header-oauth": string; "sub-header-noprovider": string; "username-label": string; "email-label": string; "displayname-label": string; "password-label": string; "confirm-password-label": string; "create-account-button": string; "allow-login-haveaccount": string; "allow-login-login": string; }; "@studiocms/auth:logout": { title: string; description: string; header: string; "sub-header": string; "cancel-button-label": string; }; "@studiocms/auth:oauth-stack": { "or-login-with": string; }; "@studiocms/dashboard:index": { title: string; description: string; "welcome-title": string; "title-button:discord": string; "title-button:feedback": string; "sub-header": string; }; "@studiocms/dashboard:sidebar": { "category-1-header": string; "dashboard-link-label": string; "content-management-label": string; "category-2-header": string; "site-configuration-label": string; "user-management-label": string; "category-3-header": string; "category-3-empty-placeholder": string; "user-dropdown:settings": string; "user-dropdown:view-site": string; "user-dropdown:logout": string; "mailer-configuration-label": string; }; "@studiocms/dashboard:profile": { title: string; description: string; header: string; "basic-info-header": string; "basic-info-save-button": string; "basic-info-display-name": string; "basic-info-email": string; "basic-info-username": string; "basic-info-website": string; "user-password-header": string; "user-password-save-button": string; "user-password-no-password": string; "user-password-current": string; "user-password-new": string; "user-password-confirm": string; "social-accounts-header": string; "social-accounts-connected": string; "social-accounts-no-connected": string; "social-accounts-other": string; "social-accounts-no-other": string; "api-tokens-header": string; "api-tokens-create": string; "api-tokens-description": string; "api-tokens-delete-button": string; "api-tokens-created": string; "api-tokens-no-tokens": string; "api-tokens-modal-header": string; "api-tokens-modal-description": string; "api-tokens-modal-response-header": string; "api-tokens-modal-response-description": string; "sync-with-libravatar": string; "basic-avatar-url": string; }; "@studiocms/dashboard:password-reset": { title: string; description: string; header: string; "sub-header-start": string; "sub-header-end": string; "password-label": string; "confirm-password-label": string; "reset-button": string; }; "@studiocms/dashboard:configuration": { title: string; description: string; header: string; "save-button": string; "dashboard-grid-label": string; "login-page-preview": string; "input-site-title": string; "input-site-description": string; "input-og-image": string; "input-site-icon": string; "input-diff-tracking-limit": string; "input-custom-login-page": string; "select-page-diff-tracking": string; "select-login-page-bg": string; "select-smtp-mailer": string; "select-hide-default-index": string; "true-label": string; "false-label": string; }; "@studiocms/dashboard:smtp": { title: string; description: string; header: string; "save-button": string; "smtp-settings": string; "test-smtp": string; "smtp-host": string; "smtp-host-placeholder": string; "smtp-port": string; "smtp-port-placeholder": string; "smtp-secure": string; "smtp-proxy": string; "smtp-proxy-placeholder": string; "smtp-tls-reject-unauthorized": string; "smtp-tls-servername": string; "smtp-tls-servername-placeholder": string; "smtp-user": string; "smtp-user-placeholder": string; "smtp-password": string; "smtp-password-placeholder": string; "smtp-default-sender": string; "smtp-default-sender-placeholder": string; "test-email": string; "test-email-placeholder": string; "send-test-email": string; "site-email-settings": string; emailVerification: string; requireAdminVerification: string; requireEditorVerification: string; oAuthBypassVerification: string; "save-email-settings": string; "true-label": string; "false-label": string; "template-editor-save-failed": string; "template-editor-save-success": string; "template-editor-save-unknown": string; "template-editor-preloaded-content": string; "template-editor-not-found": string; "template-save-reset-button-error": string; "template-reset-button-confirm": string; "error-label": string; "success-label": string; notifications: string; passwordReset: string; userInvite: string; verifyEmail: string; "mail-templates": string; "available-templates": string; "template-instructions": string; "available-variables": string; "variable-global-site.title": string; "variable-global-site.description": string; "variable-global-site.icon": string; "variable-notifications-data.title": string; "variable-notifications-data.message": string; "variable-passwordReset-data.link": string; "variable-verifyEmail-data.link": string; "variable-userInvite-data.link": string; "template-save-button": string; "template-reset-button": string; "preview-button-title": string; "template-preview-button-error": string; "template-preview-modal-header": string; }; "@studiocms/dashboard:user-mngmt-sidebar": { "input-placeholder-search": string; "dropdown-create-user": string; "dropdown-create-invite": string; }; "@studiocms/dashboard:user-mngmt-index": { title: string; description: string; header: string; placeholder: string; }; "@studiocms/dashboard:user-mngmt-edit": { title: string; description: string; header: string; "header-delete-button": string; "header-save-button": string; "delete-modal-header": string; "delete-modal-desc-1": string; "delete-modal-desc-2": string; "delete-modal-warning": string; "user-info-header": string; "user-info-email": string; "user-info-username": string; "user-info-website": string; "user-info-created-at": string; "user-info-updated-at": string; "password-reset-button": string; "password-reset-modal-header": string; "password-reset-modal-desc-1": string; "password-reset-modal-desc-2": string; "password-reset-modal-link": string; "edit-role-header": string; "email-verification-status": string; "social-accounts-header": string; "social-accounts-non": string; "api-tokens-header": string; "api-tokens-delete-button": string; "api-tokens-created": string; "api-tokens-no-tokens": string; "last-edit-pages-header": string; "last-edit-pages-edited": string; "last-edit-pages-no-edits": string; owner: string; admin: string; editor: string; visitor: string; unknown: string; "email-verified": string; "email-unverified": string; }; "@studiocms/dashboard:plugin-settings": { title: string; description: string; header: string; "save-button": string; }; "@studiocms/dashboard:content-sidebar": { "input-placeholder-search": string; "dropdown-create-page": string; "dropdown-create-folder": string; "items-divider": string; }; "@studiocms/dashboard:content-header": { title: string; "edit-page-title": string; "edit-folder-title": string; "create-page-title": string; "create-folder-title": string; "delete-button": string; "save-button": string; "create-button": string; "draft-button": string; "publish-button": string; "delete-modal-header": string; "delete-modal-warning": string; "delete-modal-desc-1": string; "delete-modal-desc-2": string; "delete-folder-modal-desc-1": string; "delete-folder-modal-desc-2": string; }; "@studiocms/dashboard:content-index": { title: string; description: string; header: string; placeholder: string; }; "@studiocms/dashboard:content-diff": { "view-page": string; "page-metadata": string; "page-content": string; "revert-metadata": string; "revert-content": string; "revert-all": string; "page-title": string; "edited-by": string; "edited-on": string; "no-metadata-changes": string; }; "@studiocms/dashboard:content-folder": { "input-folder-name": string; "input-folder-parent": string; }; "@studiocms/dashboard:content-page": { "tab-label-basic-info": string; "tab-label-content": string; "tab-label-diff": string; "input-page-title": string; "input-page-slug": string; "input-page-description": string; "input-page-hero-image": string; "select-page-type": string; "select-page-show-in-nav": string; "select-page-parent-folder": string; "select-page-draft": string; "select-page-categories": string; "select-page-tags": string; "select-page-show-author": string; "select-page-show-contributors": string; "custom-page-type-fields-header": string; "custom-page-types-description-new": string; "diff-edited-by-1": string; "diff-edited-by-2": string; "diff-no-history": string; "true-label": string; "false-label": string; "requires-supported-frontend": string; "select-augments-label": string; "no-augments": string; }; "@studiocms/dashboard:404": { title: string; description: string; "sub-description": string; "back-button": string; }; "@studiocms/dashboard:unverifiedEmail": { title: string; description: string; "sub-description": string; "resend-button": string; "back-button": string; }; "@studiocms/dashboard:versionCheckModal": { "header-title": string; "current-version": string; "latest-version": string; "last-check": string; "full-changelog": string; "view-on": string; }; "@studiocms/dashboard:user-component": { admin: string; editor: string; owner: string; visitor: string; unknown: string; }; "@studiocms/dashboard:profile-notifications": { "header-title": string; "save-button": string; account_updated: string; page_updated: string; page_deleted: string; new_page: string; folder_updated: string; folder_deleted: string; new_folder: string; user_updated: string; user_deleted: string; new_user: string; }; }; }; /** * Represents a translation record for StudioCMS. * * @property displayName - The human-readable name for the translation. * @property translations - The translation data in the form of a ComponentsJSON object. */ export type StudioCMSTranslationRecord = typeof baseServerTranslations; /** * Represents a translation entry in JSON format. * Can be either a string (a translated value) or a nested object of translations. * This allows for both flat and hierarchical translation structures. */ export type TranslationJSON = string | TranslationsJSON; /** * The UI translations available in the StudioCMS app. */ export type UiTranslationKey = string; /** * Represents a collection of translation entries, where each key is a locale or identifier, * and the value is a `TranslationJSON` object containing the translations for that key. * * @remarks * This interface is typically used to store or retrieve multiple sets of translations, * organized by language or context. * * @example * ```typescript * const translations: TranslationsJSON = { * en: { greeting: "Hello" }, * fr: { greeting: "Bonjour" } * }; * ``` */ export interface TranslationsJSON { [key: string]: TranslationJSON; } /** * Represents a mapping of component names to their respective translation objects. * * @remarks * Each key in the object is a component name (as a string), and the value is a `TranslationsJSON` * object containing the translations for that component. * * @example * ```typescript * const components: ComponentsJSON = { * header: { en: "Header", fr: "En-tête" }, * footer: { en: "Footer", fr: "Pied de page" } * }; * ``` */ export type ComponentsJSON = StudioCMSTranslationRecord['translations']; /** * Represents the server-side UI translations. * * This type maps each `UiTranslationKey` to its corresponding `StudioCMSTranslationRecord`, * allowing for structured access to translation records for different UI elements. * * @see UiTranslationKey * @see StudioCMSTranslationRecord */ export type ServerUiTranslations = Record<UiTranslationKey, StudioCMSTranslationRecord>; /** * Represents a mapping of UI translation keys to their corresponding component translation JSON objects. * * @typeParam UiTranslationKey - The set of valid keys for UI translations. * @typeParam ComponentsJSON - The shape of the translation data for each component. */ export type ClientUiTranslations = Record<UiTranslationKey, ComponentsJSON>; export type LanguageFlagIdentifier = `lang-${string}`; /** * Represents an option for selecting a language in the UI. * * @property key - The translation key associated with the language option. * @property value - The display value for the language option. * @property flag - The flag associated with the language option. */ export interface LanguageSelectorOption { readonly key: UiTranslationKey; readonly displayName: string; readonly flag: LanguageFlagIdentifier; } /** * An object containing server-side UI translations for supported locales. * * - The `en` property provides the base server translations for English. * - Additional locale translations are spread from `nonBaseTranslations`. * * @remarks * This constant is typed as `ServerUiTranslations` and marked as `const` for immutability. */ export declare const serverUiTranslations: ServerUiTranslations; /** * The UI translations available in the StudioCMS app. */ export declare const uiTranslationsAvailable: UiTranslationKey[]; /** * Transforms the `serverUiTranslations` object into a `ClientUiTranslations` object * by extracting only the `translations` property for each UI translation key. * * @remarks * This reduces the server-side translation structure to a client-friendly format, * mapping each `UiTranslationKey` to its corresponding translations object. * * @type {ClientUiTranslations} */ export declare const clientUiTranslations: ClientUiTranslations; /** * Generates an array of language selector options from available translations and flags * * @returns An array of objects, each with `key`, `value`, and `flag` properties for language selection. */ export declare const languageSelectorOptions: LanguageSelectorOption[];