@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
53 lines • 1.86 kB
text/typescript
import { TranslatableCopy, TranslateCopyOptions, TranslationStore, Translator } from "./types.mjs";
//#region src/libs/i18n/translate.d.ts
/**
* Resolves Lucid core translations without project or plugin overrides.
*
* Use this for build-time, CLI, or low-level code that does not have a processed
* config available. For request, service, lifecycle, and plugin code that should
* respect project translations, use `createTranslator`.
*
* @example
* ```ts
* import { translate } from "@lucidcms/core";
*
* throw new Error(
* translate("server:core.config.duplicate.keys", {
* data: { builder: "collections" },
* }),
* );
* ```
*/
declare function translate(value: string | TranslatableCopy, options?: TranslateCopyOptions): string;
declare function translate(value: undefined, options?: TranslateCopyOptions): undefined;
declare function translate(value: string | TranslatableCopy | undefined, options?: TranslateCopyOptions): string | undefined;
/**
* Creates a translator bound to a translation store and locale.
*
* Use this at request, service, adapter lifecycle, cron, and job boundaries when
* text should respect project and plugin translation overrides. The returned
* translator resolves prefixed keys or any value created with `copy`.
*
* @example
* ```ts
* import { copy, createTranslator } from "@lucidcms/core";
*
* const translator = createTranslator({ store, locale: "fr" });
*
* translator("server:posts.not.found", {
* data: { id: 12 },
* defaultMessage: "Post {{id}} was not found.",
* });
*
* translator(copy("admin:collections.posts.name", {
* defaultMessage: "Posts",
* }));
* ```
*/
declare const createTranslator: (props: {
store: TranslationStore;
locale: string;
}) => Translator;
//#endregion
export { createTranslator, translate };
//# sourceMappingURL=translate.d.mts.map