-
I need to merge multiple message JSON files via import enObj1 from '../../i18n/dist/en-US/main.json'
import enObj2 from '../../i18n/dist/en-US/enum.json'
import enObj3 from '../../uilib/i18n/en-US.json'
export const i18n = createI18n({
legacy: false,
globalInjection: true,
locale: 'en-US', // set locale
fallbackLocale: 'en-US',
messages: { 'en-US': enObj1 },
})
i18n.global.mergeLocaleMessage('en-US', enObj2)
i18n.global.mergeLocaleMessage('en-US', enObj3) However, when I want to access the merged locale message via |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
At last I wrote a fake ctx to feed these functions with the fake ctx... const fakeCtx = {
normalize: (x: any[] | string) => isArr(x) ? x.join('') : x,
interpolate: () => '',
list: () => '',
plural: (x: any[]) => x.join(''),
} Shameful but it works. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, we don't provide an API to get the raw string from the message functions.
This is because we are not using bundler in unit tests. |
Beta Was this translation helpful? Give feedback.
-
It's interesting. |
Beta Was this translation helpful? Give feedback.
At last I wrote a fake ctx to feed these functions with the fake ctx...
Shameful but it works.
恥ずだが役に立つ。