Skip to content

Commit

Permalink
feat: add umi-plugin-locale browser export (#1716)
Browse files Browse the repository at this point in the history
* feat: add umi-plugin-locale browser export

* fix package.json
  • Loading branch information
Yu authored and sorrycc committed Dec 27, 2018
1 parent db87656 commit 1796735
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/umi-plugin-locale/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
declare function setLocale(lang: string): void;
declare function getLocale(): string;
interface Params {
id: string;
defaultMessage?: string;
}
declare function formatMessage(params: Params, data?: Object): void;
declare const FormattedMessage: React.Component;

export { setLocale, getLocale, formatMessage, FormattedMessage };
6 changes: 5 additions & 1 deletion packages/umi-plugin-locale/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "2.3.0-beta.12",
"description": "A umi plugin for provide internationalization function.",
"main": "./lib/index.js",
"browser": {
"./lib/index.js": "./lib/locale.js"
},
"authors": [
"yutingzhao1991 <yutingzhao1991@sina.com> (https://github.com/yutingzhao1991)"
],
Expand All @@ -18,7 +21,8 @@
"files": [
"lib",
"src",
"template"
"template",
"index.d.ts"
],
"keywords": [
"umi"
Expand Down
2 changes: 2 additions & 0 deletions packages/umi-plugin-locale/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export default function(api, options = {}) {
...memo,
alias: {
...(memo.alias || {}),
// umi/locale is deprecated
// recommend use `import { getLocale } from 'umi-plugin-locale';` now.
'umi/locale': join(__dirname, './locale.js'),
'react-intl': dirname(require.resolve('react-intl/package.json')),
},
Expand Down
3 changes: 3 additions & 0 deletions packages/umi-plugin-react/locale/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as locale from "umi-plugin-locale";

export = locale;
1 change: 1 addition & 0 deletions packages/umi-plugin-react/locale/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('umi-plugin-locale');
4 changes: 3 additions & 1 deletion packages/umi-plugin-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
},
"files": [
"lib",
"src"
"src",
"locale/index.js",
"locale/index.d.ts"
],
"license": "MIT",
"dependencies": {
Expand Down

0 comments on commit 1796735

Please sign in to comment.