Files
zeekay 09c5e16c5c feat: rebrand all packages to @hanzo/cms scope (Payload v3.85.2 fork)
- payload -> @hanzo/cms (core), bin payload -> hanzo-cms
- create-payload-app -> @hanzo/create-cms-app
- @payloadcms/<x> -> @hanzo/cms-<x> across the whole dependency graph
- 3545 files, 72 package.json, 4419 scoped refs, 3852 core import specifiers, 82 scss imports
- MIT attribution to Payload CMS Inc. preserved (LICENSE.md, author emails)

Upstream: github.com/payloadcms/payload @ v3.85.2 (MIT)
2026-07-01 17:56:00 -07:00

126 lines
3.3 KiB
TypeScript

/**
* This test suites primarily tests the i18n types (in this config.ts, the ComponentWithCustomI18n.tsx and ComponentWithDefaultI18n.tsx) and the i18n functionality in the admin UI.
*
* Thus, please do not remove any ts-expect-error comments in this test suite. This test suite will eventually have to be compiled to ensure there are no type errors.
*/
import type {
DefaultTranslationKeys,
NestedKeysStripped,
TFunction,
} from '@hanzo/cms-translations'
import { fileURLToPath } from 'node:url'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
import path from 'path'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
import { devUser } from '../credentials.js'
const customTranslationsObject = {
en: {
general: {
test: 'My custom translation',
},
},
}
export type CustomTranslationsObject = typeof customTranslationsObject.en
export type CustomTranslationsKeys = NestedKeysStripped<CustomTranslationsObject>
export default buildConfigWithDefaults({
admin: {
importMap: {
baseDir: path.resolve(dirname),
},
components: {
afterDashboard: [
'/ComponentWithDefaultI18n.js#ComponentWithDefaultI18n',
'/ComponentWithCustomI18n.js#ComponentWithCustomI18n',
],
},
},
collections: [
{
slug: 'collection1',
labels: {
singular: {
en: 'EN Collection 1',
es: 'ES Collection 1',
},
plural: {
en: 'EN Collection 1s',
es: 'ES Collection 1s',
},
},
fields: [
{
name: 'i18nFieldLabel',
type: 'text',
label: {
en: 'en-label',
es: 'es-label',
},
},
{
name: 'fieldDefaultI18nValid',
type: 'text',
label: ({ t }) => t('fields:addLabel'),
},
{
name: 'fieldDefaultI18nInvalid',
type: 'text',
// @ts-expect-error // Keep the ts-expect-error comment. This NEEDS to throw an error
label: ({ t }) => t('fields:addLabel2'),
},
{
name: 'fieldCustomI18nValidDefault',
type: 'text',
label: ({ t }: { t: TFunction<CustomTranslationsKeys | DefaultTranslationKeys> }) =>
t('fields:addLabel'),
},
{
name: 'fieldCustomI18nValidCustom',
type: 'text',
label: ({ t }: { t: TFunction<CustomTranslationsKeys | DefaultTranslationKeys> }) =>
t('general:test'),
},
{
name: 'fieldCustomI18nInvalid',
type: 'text',
label: ({ t }: { t: TFunction<CustomTranslationsKeys | DefaultTranslationKeys> }) =>
// @ts-expect-error // Keep the ts-expect-error comment. This NEEDS to throw an error
t('fields:addLabel2'),
},
],
},
],
globals: [
{
slug: 'global',
label: {
en: 'EN Global',
es: 'ES Global',
},
fields: [{ name: 'text', type: 'text' }],
},
],
i18n: {
translations: customTranslationsObject,
},
onInit: async (payload) => {
await payload.create({
collection: 'users',
data: {
email: devUser.email,
password: devUser.password,
},
})
},
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
})