diff --git a/packages/native/package.json b/packages/native/package.json index e2d07ae1..d9d8703e 100644 --- a/packages/native/package.json +++ b/packages/native/package.json @@ -53,8 +53,8 @@ "webpack-cli": "^5.1.4" }, "dependencies": { - "@messageformat/core": "^3.3.0", "cross-fetch": "^4.0.0", + "intl-messageformat": "^10.5.14", "md5": "^2.3.0" } } diff --git a/packages/native/src/renderers/MessageFormatRenderer.js b/packages/native/src/renderers/MessageFormatRenderer.js index 88d70ad5..9ce33b45 100644 --- a/packages/native/src/renderers/MessageFormatRenderer.js +++ b/packages/native/src/renderers/MessageFormatRenderer.js @@ -1,9 +1,5 @@ /* eslint-disable class-methods-use-this */ -import MessageFormat from '@messageformat/core'; - -// object to cache MessageFormat classes related to -// specific locales -const MF = {}; +import IntlMessageFormat from 'intl-messageformat'; /** * MessageFormat renderer @@ -16,18 +12,12 @@ export default class MessageFormatRenderer { // construct a MessageFormat class based on locale // to make dates and other content localizable const locale = ((localeCode || '').split('_'))[0]; - if (!MF[locale]) { - try { - MF[locale] = new MessageFormat(locale, { - strictPluralKeys: false, - }); - } catch (err) { - MF[locale] = new MessageFormat('*', { - strictPluralKeys: false, - }); - } + let msg; + try { + msg = new IntlMessageFormat(sourceString, locale, undefined, { ignoreTag: true }); + } catch (err) { + msg = new IntlMessageFormat(sourceString, undefined, undefined, { ignoreTag: true }); } - const msg = MF[locale].compile(sourceString); - return msg(params); + return msg.format(params); } }