Formuliermeldingen van cms-client uit het taalbestand (blok cmsClient.contact), pakket houdt eigen standaardteksten als terugval; pariteitstest
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
type SubjectOption,
|
type SubjectOption,
|
||||||
type TokenResult,
|
type TokenResult,
|
||||||
} from '../../../cms-client/contact';
|
} from '../../../cms-client/contact';
|
||||||
|
import { contactMessages } from '../../../i18n/cmsClientMessages';
|
||||||
import { trackEvent } from '../../../shared/analytics/trackEvent';
|
import { trackEvent } from '../../../shared/analytics/trackEvent';
|
||||||
import { useContactPreselect } from '../../../shared/contact/useContactPreselect';
|
import { useContactPreselect } from '../../../shared/contact/useContactPreselect';
|
||||||
import { buildSubjectOptions, subjectForSlug } from '../../../shared/contact/subjects';
|
import { buildSubjectOptions, subjectForSlug } from '../../../shared/contact/subjects';
|
||||||
@@ -62,6 +63,7 @@ export function ContactFormView({ client, token, refreshToken }: ContactFormView
|
|||||||
|
|
||||||
const form = useContactForm({
|
const form = useContactForm({
|
||||||
idPrefix: 'contact',
|
idPrefix: 'contact',
|
||||||
|
messages: contactMessages,
|
||||||
subjectOptions,
|
subjectOptions,
|
||||||
preselect: { subject: subjectForSlug(packages, preselect.subject), key: preselect.key },
|
preselect: { subject: subjectForSlug(packages, preselect.subject), key: preselect.key },
|
||||||
initialSubject: subjectForSlug(packages, preselect.subject),
|
initialSubject: subjectForSlug(packages, preselect.subject),
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { messagesNl } from '../cms-client/contact/messages.nl';
|
||||||
|
import { contactMessages } from './cmsClientMessages';
|
||||||
|
|
||||||
|
describe('cms-client contact texts from the language file', () => {
|
||||||
|
it('match the package defaults exactly', () => {
|
||||||
|
expect(contactMessages.fieldErrors).toEqual(messagesNl.fieldErrors);
|
||||||
|
expect(contactMessages.fallbackFieldError).toBe(messagesNl.fallbackFieldError);
|
||||||
|
expect(contactMessages.tooLarge).toBe(messagesNl.tooLarge);
|
||||||
|
expect(contactMessages.captchaRequired).toBe(messagesNl.captchaRequired);
|
||||||
|
expect(contactMessages.sendingLabel).toBe(messagesNl.sendingLabel);
|
||||||
|
expect(contactMessages.rateLimited(1)).toBe(messagesNl.rateLimited(1));
|
||||||
|
expect(contactMessages.rateLimited(5)).toBe(messagesNl.rateLimited(5));
|
||||||
|
expect(contactMessages.failed('info@example.nl')).toBe(messagesNl.failed('info@example.nl'));
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import type { ContactMessages } from '../cms-client/contact/messages.nl';
|
||||||
|
import { t } from './index';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Texts of the cms-client package, taken from the site language file (block `cmsClient`:
|
||||||
|
* package -> component -> texts). The package keeps its own Dutch defaults (messages.nl.ts) as a
|
||||||
|
* fallback for sites that pass nothing; this site overrides them with the texts below.
|
||||||
|
*/
|
||||||
|
export const contactMessages: ContactMessages = {
|
||||||
|
fieldErrors: {
|
||||||
|
name: {
|
||||||
|
required: t('cmsClient.contact.fieldErrors.name.required'),
|
||||||
|
tooLong: t('cmsClient.contact.fieldErrors.name.tooLong'),
|
||||||
|
invalid: t('cmsClient.contact.fieldErrors.name.invalid'),
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
required: t('cmsClient.contact.fieldErrors.email.required'),
|
||||||
|
tooLong: t('cmsClient.contact.fieldErrors.email.tooLong'),
|
||||||
|
invalid: t('cmsClient.contact.fieldErrors.email.invalid'),
|
||||||
|
},
|
||||||
|
subject: {
|
||||||
|
required: t('cmsClient.contact.fieldErrors.subject.required'),
|
||||||
|
tooLong: t('cmsClient.contact.fieldErrors.subject.tooLong'),
|
||||||
|
invalid: t('cmsClient.contact.fieldErrors.subject.invalid'),
|
||||||
|
},
|
||||||
|
message: {
|
||||||
|
required: t('cmsClient.contact.fieldErrors.message.required'),
|
||||||
|
tooLong: t('cmsClient.contact.fieldErrors.message.tooLong'),
|
||||||
|
invalid: t('cmsClient.contact.fieldErrors.message.invalid'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fallbackFieldError: t('cmsClient.contact.fallbackFieldError'),
|
||||||
|
rateLimited: (minutes) =>
|
||||||
|
minutes === 1
|
||||||
|
? t('cmsClient.contact.rateLimited.one', { minutes })
|
||||||
|
: t('cmsClient.contact.rateLimited.other', { minutes }),
|
||||||
|
tooLarge: t('cmsClient.contact.tooLarge'),
|
||||||
|
captchaRequired: t('cmsClient.contact.captchaRequired'),
|
||||||
|
failed: (address) => t('cmsClient.contact.failed', { address }),
|
||||||
|
sendingLabel: t('cmsClient.contact.sendingLabel'),
|
||||||
|
};
|
||||||
@@ -196,5 +196,40 @@
|
|||||||
"subjectPlaceholder": "-- KIES --",
|
"subjectPlaceholder": "-- KIES --",
|
||||||
"honeypot": "Laat dit veld leeg"
|
"honeypot": "Laat dit veld leeg"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"cmsClient": {
|
||||||
|
"contact": {
|
||||||
|
"fieldErrors": {
|
||||||
|
"name": {
|
||||||
|
"required": "Vul je naam in.",
|
||||||
|
"tooLong": "De naam is te lang.",
|
||||||
|
"invalid": "Deze naam is ongeldig."
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"required": "Vul je e-mailadres in.",
|
||||||
|
"tooLong": "Het e-mailadres is te lang.",
|
||||||
|
"invalid": "Dit e-mailadres is ongeldig."
|
||||||
|
},
|
||||||
|
"subject": {
|
||||||
|
"required": "Kies een onderwerp.",
|
||||||
|
"tooLong": "Dit onderwerp is te lang.",
|
||||||
|
"invalid": "Kies een onderwerp."
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"required": "Schrijf hier je vraag.",
|
||||||
|
"tooLong": "Het bericht is te lang.",
|
||||||
|
"invalid": "Dit bericht bevat ongeldige tekens."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fallbackFieldError": "Controleer dit veld.",
|
||||||
|
"rateLimited": {
|
||||||
|
"one": "Je hebt net al een bericht gestuurd. Probeer het over {minutes} minuut opnieuw.",
|
||||||
|
"other": "Je hebt net al een bericht gestuurd. Probeer het over {minutes} minuten opnieuw."
|
||||||
|
},
|
||||||
|
"tooLarge": "Je bericht is te groot.",
|
||||||
|
"captchaRequired": "Bevestig eerst dat je geen robot bent.",
|
||||||
|
"failed": "Versturen lukte niet. Probeer het later nog eens of mail naar {address}.",
|
||||||
|
"sendingLabel": "Versturen…"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
import { contactForm, contactInfo } from '../../features/landing/data/content';
|
import { contactForm, contactInfo } from '../../features/landing/data/content';
|
||||||
import { usePackagesQuery } from '../../features/landing/hooks/usePackagesQuery';
|
import { usePackagesQuery } from '../../features/landing/hooks/usePackagesQuery';
|
||||||
import { t } from '../../i18n';
|
import { t } from '../../i18n';
|
||||||
|
import { contactMessages } from '../../i18n/cmsClientMessages';
|
||||||
import { trackEvent } from '../../shared/analytics/trackEvent';
|
import { trackEvent } from '../../shared/analytics/trackEvent';
|
||||||
import { useContactPreselect } from '../../shared/contact/useContactPreselect';
|
import { useContactPreselect } from '../../shared/contact/useContactPreselect';
|
||||||
import { buildSubjectOptions, subjectForSlug } from '../../shared/contact/subjects';
|
import { buildSubjectOptions, subjectForSlug } from '../../shared/contact/subjects';
|
||||||
@@ -65,6 +66,7 @@ export function TerminalForm({ client, token, refreshToken }: TerminalFormProps)
|
|||||||
|
|
||||||
const form = useContactForm({
|
const form = useContactForm({
|
||||||
idPrefix: 'contact',
|
idPrefix: 'contact',
|
||||||
|
messages: contactMessages,
|
||||||
subjectOptions,
|
subjectOptions,
|
||||||
preselect: { subject: subjectForSlug(packages, preselect.subject), key: preselect.key },
|
preselect: { subject: subjectForSlug(packages, preselect.subject), key: preselect.key },
|
||||||
initialSubject: subjectForSlug(packages, preselect.subject),
|
initialSubject: subjectForSlug(packages, preselect.subject),
|
||||||
|
|||||||
Reference in New Issue
Block a user