Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/.changeset/fuzzy-bees-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'pydantic-forms': patch
---

Sets locale for zod validation messages
16 changes: 16 additions & 0 deletions frontend/packages/pydantic-forms/src/PydanticForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
*/
import React, { createContext } from 'react';

import { z } from 'zod/v4';

import { TranslationsProvider } from '@/messages/translationsProvider';
import {
Locale,
PydanticFormConfig,
PydanticFormProps,
PydanticFormValidationErrorDetails,
Expand All @@ -31,6 +34,19 @@ export const PydanticForm = ({
onSuccess,
title,
}: PydanticFormProps) => {
const getLocale = () => {
switch (config.locale) {
case Locale.enGB:
return z.locales.en();
case Locale.nlNL:
return z.locales.nl();
default:
return z.locales.en();
}
};

z.config(getLocale());

return (
<TranslationsProvider
customTranslations={config.customTranslations}
Expand Down