UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.67 kB
{"version":3,"file":"check-locales.mjs","names":[],"sources":["../../../../src/libs/config/checks/check-locales.ts"],"sourcesContent":["import type { Config } from \"../../../types.js\";\nimport { translate } from \"../../i18n/index.js\";\n\nconst checkLocales = (\n\tlocalesConfig: Config[\"localization\"] | Config[\"i18n\"],\n) => {\n\tif (localesConfig.locales.length === 0) {\n\t\tthrow new Error(translate(\"server:core.config.locales.empty\"));\n\t}\n\tif (localesConfig.defaultLocale === undefined) {\n\t\tthrow new Error(translate(\"server:core.config.default.locale.undefined\"));\n\t}\n\n\tconst defaultLocale = localesConfig.locales.find(\n\t\t(l) => l.code === localesConfig.defaultLocale,\n\t);\n\tif (defaultLocale === undefined) {\n\t\tthrow new Error(translate(\"server:core.config.default.locale.not.found\"));\n\t}\n\n\tconst localeCodes = localesConfig.locales.map((l) => l.code);\n\tconst duplicate = localeCodes.find(\n\t\t(code, index) => localeCodes.indexOf(code) !== index,\n\t);\n\tif (duplicate !== undefined) {\n\t\tthrow new Error(\n\t\t\ttranslate(\"server:core.config.duplicate.locale\", {\n\t\t\t\tdata: { code: duplicate },\n\t\t\t}),\n\t\t);\n\t}\n};\n\nexport default checkLocales;\n"],"mappings":"qDAGA,MAAM,EACL,GACI,CACJ,GAAI,EAAc,QAAQ,SAAW,EACpC,MAAU,MAAM,EAAU,kCAAkC,CAAC,EAE9D,GAAI,EAAc,gBAAkB,IAAA,GACnC,MAAU,MAAM,EAAU,6CAA6C,CAAC,EAMzE,GAHsB,EAAc,QAAQ,KAC1C,GAAM,EAAE,OAAS,EAAc,aAEjB,IAAM,IAAA,GACrB,MAAU,MAAM,EAAU,6CAA6C,CAAC,EAGzE,IAAM,EAAc,EAAc,QAAQ,IAAK,GAAM,EAAE,IAAI,EACrD,EAAY,EAAY,MAC5B,EAAM,IAAU,EAAY,QAAQ,CAAI,IAAM,CAChD,EACA,GAAI,IAAc,IAAA,GACjB,MAAU,MACT,EAAU,sCAAuC,CAChD,KAAM,CAAE,KAAM,CAAU,CACzB,CAAC,CACF,CAEF"}