File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -65,13 +65,21 @@ export const addI18nKeyToPrefix = (
6565 return `${ i18nKeyPrefix } .${ key } ` ;
6666} ;
6767
68- export const createTranslator = (
69- fn : (
70- id : string ,
71- defaultMessage : string | undefined ,
72- values ?: any
73- ) => string | undefined
74- ) : Translator => fn as Translator ;
68+ export const createTranslator =
69+ (
70+ fn : (
71+ id : string ,
72+ defaultMessage : string | undefined ,
73+ values ?: any
74+ ) => string | undefined
75+ ) : Translator =>
76+ ( id : string , defaultMessage ?: string , values ?: any ) => {
77+ const translation = fn ( id , defaultMessage , values ) ;
78+ if ( translation === undefined ) {
79+ return defaultMessage ;
80+ }
81+ return translation ;
82+ } ;
7583
7684export const defaultTranslator : Translator = createTranslator (
7785 ( _id , defaultMessage ) => defaultMessage
You can’t perform that action at this time.
0 commit comments