Merge branch 'main' into feat/folders

This commit is contained in:
Jarrod Flesch
2025-05-20 13:35:23 -04:00
155 changed files with 2197 additions and 125 deletions

View File

@@ -17,6 +17,7 @@
"build-template-with-local-pkgs": "pnpm runts src/build-template-with-local-pkgs.ts",
"gen-templates": "pnpm runts src/generate-template-variations.ts",
"generateTranslations:core": "node --no-deprecation --import @swc-node/register/esm-register src/generateTranslations/core.ts",
"generateTranslations:plugin-import-export": "node --no-deprecation --import @swc-node/register/esm-register src/generateTranslations/plugin-import-export.ts",
"generateTranslations:plugin-multi-tenant": "node --no-deprecation --import @swc-node/register/esm-register src/generateTranslations/plugin-multi-tenant.ts",
"license-check": "pnpm runts src/license-check.ts",
"lint": "eslint .",
@@ -38,6 +39,7 @@
"payload": "workspace:*"
},
"devDependencies": {
"@payloadcms/plugin-import-export": "workspace:*",
"@payloadcms/plugin-multi-tenant": "workspace:*",
"@payloadcms/richtext-lexical": "workspace:*",
"@payloadcms/translations": "workspace:*"

View File

@@ -0,0 +1,39 @@
import type { AcceptedLanguages, GenericTranslationsObject } from '@payloadcms/translations'
import { translations } from '@payloadcms/plugin-import-export/translations/languages/all'
import { enTranslations } from '@payloadcms/plugin-import-export/translations/languages/en'
import path from 'path'
import { fileURLToPath } from 'url'
import { translateObject } from './utils/index.js'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
const allTranslations: {
[key in AcceptedLanguages]?: {
dateFNSKey: string
translations: GenericTranslationsObject
}
} = {}
for (const key of Object.keys(translations)) {
allTranslations[key as AcceptedLanguages] = {
dateFNSKey: translations[key as AcceptedLanguages]?.dateFNSKey ?? 'unknown-date-fns-key',
translations: translations[key as AcceptedLanguages]?.translations ?? {},
}
}
void translateObject({
allTranslationsObject: allTranslations,
fromTranslationsObject: enTranslations,
targetFolder: path.resolve(
dirname,
'../../../../packages/plugin-import-export/src/translations/languages',
),
tsFilePrefix: `import type { PluginDefaultTranslationsObject, PluginLanguage } from '../types.js'\n\nexport const {{locale}}Translations: PluginDefaultTranslationsObject = `,
tsFileSuffix: `\n\nexport const {{locale}}: PluginLanguage = {
dateFNSKey: {{dateFNSKey}},
translations: {{locale}}Translations,
} `,
})