UNPKG

@intlayer/core

Version:

Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.

1 lines 1.4 kB
{"version":3,"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type LanguageContent,\n type TypedNodeModel,\n} from '../../types/index';\n\nexport type TranslationContent<\n Content = unknown,\n RecordContent extends LanguageContent<Content> = LanguageContent<Content>,\n> = TypedNodeModel<NodeType.Translation, RecordContent>;\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nconst translation = <\n Content = unknown,\n ContentRecord extends LanguageContent<Content> = LanguageContent<Content>,\n>(\n content: ContentRecord\n) =>\n formatNodeType(NodeType.Translation, content) satisfies TranslationContent<\n Content,\n ContentRecord\n >;\n\nexport { translation as t };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAKO;AA2BP,MAAM,cAAc,CAIlB,gBAEA,6BAAe,sBAAS,aAAa,OAAO;","names":[]}