@@ -120,16 +120,18 @@ const I18nContextProvider = ({
120120 children,
121121 defaultLoad,
122122 loadDateLocale,
123+ defaultDateLocale,
123124 defaultLocale,
124- defaultTranslations,
125- enableDefaultLocale,
126- enableDebugKey,
127- localeItemStorage,
125+ defaultTranslations = { } ,
126+ enableDefaultLocale = false ,
127+ enableDebugKey = false ,
128+ localeItemStorage = LOCALE_ITEM_STORAGE ,
128129 supportedLocales,
129130} : {
130131 children : ReactNode ,
131132 defaultLoad : LoadTranslationsFn ,
132- loadDateLocale : LoadLocaleFn ,
133+ loadDateLocale ?: LoadLocaleFn ,
134+ defaultDateLocale ?: Locale ,
133135 defaultLocale : string ,
134136 defaultTranslations : TranslationsByLocales ,
135137 enableDefaultLocale : boolean ,
@@ -142,10 +144,10 @@ const I18nContextProvider = ({
142144 )
143145 const [ translations , setTranslations ] = useState < TranslationsByLocales > ( defaultTranslations )
144146 const [ namespaces , setNamespaces ] = useState < string [ ] > ( [ ] )
145- const [ dateFnsLocale , setDateFnsLocale ] = useState < Locale > ( )
147+ const [ dateFnsLocale , setDateFnsLocale ] = useState < Locale | undefined > ( defaultDateLocale ?? undefined )
146148
147149 useEffect ( ( ) => {
148- loadDateLocale ( currentLocale === 'en' ? 'en-GB' : currentLocale )
150+ loadDateLocale ?. ( currentLocale === 'en' ? 'en-GB' : currentLocale )
149151 . then ( setDateFnsLocale )
150152 . catch ( ( ) => loadDateLocale ( 'en-GB' ) . then ( setDateFnsLocale ) )
151153 } , [ loadDateLocale , currentLocale ] )
@@ -340,21 +342,15 @@ const I18nContextProvider = ({
340342 return < I18nContext . Provider value = { value } > { children } </ I18nContext . Provider >
341343}
342344
343- I18nContextProvider . defaultProps = {
344- defaultTranslations : { } ,
345- enableDebugKey : false ,
346- enableDefaultLocale : false ,
347- localeItemStorage : LOCALE_ITEM_STORAGE ,
348- }
349-
350345I18nContextProvider . propTypes = {
351346 children : PropTypes . node . isRequired ,
347+ defaultDateLocale : PropTypes . shape ( { } ) ,
352348 defaultLoad : PropTypes . func . isRequired ,
353349 defaultLocale : PropTypes . string . isRequired ,
354350 defaultTranslations : PropTypes . shape ( { } ) ,
355351 enableDebugKey : PropTypes . bool ,
356352 enableDefaultLocale : PropTypes . bool ,
357- loadDateLocale : PropTypes . func . isRequired ,
353+ loadDateLocale : PropTypes . func ,
358354 localeItemStorage : PropTypes . string ,
359355 supportedLocales : PropTypes . arrayOf ( PropTypes . string ) . isRequired ,
360356}
0 commit comments