File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
packages/pydantic-forms/src Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' pydantic-forms ' : patch
3
+ ---
4
+
5
+ Sets locale for zod validation messages
Original file line number Diff line number Diff line change 8
8
*/
9
9
import React , { createContext } from 'react' ;
10
10
11
+ import { z } from 'zod/v4' ;
12
+
11
13
import { TranslationsProvider } from '@/messages/translationsProvider' ;
12
14
import {
15
+ Locale ,
13
16
PydanticFormConfig ,
14
17
PydanticFormProps ,
15
18
PydanticFormValidationErrorDetails ,
@@ -31,6 +34,19 @@ export const PydanticForm = ({
31
34
onSuccess,
32
35
title,
33
36
} : PydanticFormProps ) => {
37
+ const getLocale = ( ) => {
38
+ switch ( config . locale ) {
39
+ case Locale . enGB :
40
+ return z . locales . en ( ) ;
41
+ case Locale . nlNL :
42
+ return z . locales . nl ( ) ;
43
+ default :
44
+ return z . locales . en ( ) ;
45
+ }
46
+ } ;
47
+
48
+ z . config ( getLocale ( ) ) ;
49
+
34
50
return (
35
51
< TranslationsProvider
36
52
customTranslations = { config . customTranslations }
You can’t perform that action at this time.
0 commit comments