Skip to content

Commit 95b500b

Browse files
committed
Support CSP without unsafe-eval
1 parent 4707bb5 commit 95b500b

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

packages/native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
"webpack-cli": "^5.1.4"
5454
},
5555
"dependencies": {
56-
"@messageformat/core": "^3.3.0",
5756
"cross-fetch": "^4.0.0",
57+
"intl-messageformat": "^10.5.14",
5858
"md5": "^2.3.0"
5959
}
6060
}
Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
/* eslint-disable class-methods-use-this */
2-
import MessageFormat from '@messageformat/core';
3-
4-
// object to cache MessageFormat classes related to
5-
// specific locales
6-
const MF = {};
2+
import IntlMessageFormat from 'intl-messageformat';
73

84
/**
95
* MessageFormat renderer
@@ -16,18 +12,12 @@ export default class MessageFormatRenderer {
1612
// construct a MessageFormat class based on locale
1713
// to make dates and other content localizable
1814
const locale = ((localeCode || '').split('_'))[0];
19-
if (!MF[locale]) {
20-
try {
21-
MF[locale] = new MessageFormat(locale, {
22-
strictPluralKeys: false,
23-
});
24-
} catch (err) {
25-
MF[locale] = new MessageFormat('*', {
26-
strictPluralKeys: false,
27-
});
28-
}
15+
let msg;
16+
try {
17+
msg = new IntlMessageFormat(sourceString, locale, undefined, { ignoreTag: true });
18+
} catch (err) {
19+
msg = new IntlMessageFormat(sourceString, undefined, undefined, { ignoreTag: true });
2920
}
30-
const msg = MF[locale].compile(sourceString);
31-
return msg(params);
21+
return msg.format(params);
3222
}
3323
}

0 commit comments

Comments
 (0)