Skip to content

Commit

Permalink
add support for HTML messages (#1664)
Browse files Browse the repository at this point in the history
  • Loading branch information
ja573 authored and Yu committed Dec 27, 2018
1 parent df8889f commit db87656
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/umi-plugin-locale/src/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ let intl = {
formatMessage: () => {
return null;
},
formatHTMLMessage: () => {
return null;
},
};

// react-intl 没有直接暴露 formatMessage 这个方法
Expand All @@ -32,6 +35,10 @@ function formatMessage() {
return intl.formatMessage.call(intl, ...arguments);
}

function formatHTMLMessage() {
return intl.formatHTMLMessage.call(intl, ...arguments);
}

export * from 'react-intl';

export { formatMessage, setLocale, getLocale, _setIntlObject };
export { formatMessage, formatHTMLMessage, setLocale, getLocale, _setIntlObject };
2 changes: 2 additions & 0 deletions packages/umi-plugin-locale/test/locale.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
formatMessage,
formatHTMLMessage,
setLocale,
getLocale,
FormattedMessage,
Expand Down Expand Up @@ -34,6 +35,7 @@ Object.defineProperty(location, 'reload', {
describe('test umi/locale', () => {
test('api exist', () => {
expect(formatMessage).toBeTruthy();
expect(formatHTMLMessage).toBeTruthy();
expect(setLocale).toBeTruthy();
expect(getLocale).toBeTruthy();
expect(FormattedMessage).toBeTruthy();
Expand Down

0 comments on commit db87656

Please sign in to comment.