use-intl 2.9.0 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -18,6 +18,8 @@ This library is based on the premise that messages can be grouped by namespaces
|
|
|
18
18
|
|
|
19
19
|
```jsx
|
|
20
20
|
// LatestFollower.js
|
|
21
|
+
import {useTranslations} from 'use-intl';
|
|
22
|
+
|
|
21
23
|
function LatestFollower({user}) {
|
|
22
24
|
const t = useTranslations('LatestFollower');
|
|
23
25
|
|
|
@@ -42,7 +44,7 @@ function LatestFollower({user}) {
|
|
|
42
44
|
|
|
43
45
|
## Installation
|
|
44
46
|
|
|
45
|
-
1.
|
|
47
|
+
1. `npm install use-intl`
|
|
46
48
|
2. Add the provider
|
|
47
49
|
```jsx
|
|
48
50
|
import {IntlProvider} from 'use-intl';
|
|
@@ -51,20 +53,27 @@ import {IntlProvider} from 'use-intl';
|
|
|
51
53
|
// fetch them from within a component and then render the provider
|
|
52
54
|
// along with your app once you have the messages.
|
|
53
55
|
const messages = {
|
|
54
|
-
App: {
|
|
55
|
-
hello: 'Hello'
|
|
56
|
+
"App": {
|
|
57
|
+
"hello": 'Hello {username}!'
|
|
56
58
|
}
|
|
57
59
|
};
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
function Root() {
|
|
62
|
+
return (
|
|
63
|
+
<IntlProvider messages={messages} locale="en">
|
|
64
|
+
<App user={{name: 'Jane'}} />
|
|
65
|
+
</IntlProvider>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function App({user}) {
|
|
70
|
+
const t = useTranslations('App');
|
|
71
|
+
return <h1>{t('hello', {username: user.name})}</h1>;
|
|
72
|
+
}
|
|
64
73
|
```
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
|
|
75
|
+
Have a look at [the minimal setup example](https://codesandbox.io/s/use-intl-cra-example-13w917?file=/src/Root.tsx) to explore a working app.
|
|
67
76
|
|
|
68
77
|
## Usage
|
|
69
78
|
|
|
70
|
-
Please refer to the [`next-intl` usage docs](https://next-intl-docs.vercel.app/docs/usage)
|
|
79
|
+
Please refer to the [`next-intl` usage docs](https://next-intl-docs.vercel.app/docs/usage) for more advanced usage, but note that you should import from `use-intl` instead of `next-intl`.
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import createIntl from '../core/use-intl.esm3.js';
|
|
1
3
|
import useIntlContext from './use-intl.esm8.js';
|
|
2
4
|
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
+
function useIntl() {
|
|
6
|
+
var _useIntlContext = useIntlContext(),
|
|
7
|
+
formats = _useIntlContext.formats,
|
|
8
|
+
locale = _useIntlContext.locale,
|
|
9
|
+
globalNow = _useIntlContext.now,
|
|
10
|
+
onError = _useIntlContext.onError,
|
|
11
|
+
timeZone = _useIntlContext.timeZone;
|
|
12
|
+
|
|
13
|
+
return useMemo(function () {
|
|
14
|
+
return createIntl({
|
|
15
|
+
formats: formats,
|
|
16
|
+
locale: locale,
|
|
17
|
+
now: globalNow,
|
|
18
|
+
onError: onError,
|
|
19
|
+
timeZone: timeZone
|
|
20
|
+
});
|
|
21
|
+
}, [formats, globalNow, locale, onError, timeZone]);
|
|
5
22
|
}
|
|
6
23
|
|
|
7
|
-
export {
|
|
24
|
+
export { useIntl as default };
|
|
8
25
|
//# sourceMappingURL=use-intl.esm3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm3.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm3.js","sources":["../../src/react/useIntl.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport createIntl from '../core/createIntl';\nimport useIntlContext from './useIntlContext';\n\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n return useMemo(\n () =>\n createIntl({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n"],"names":["useIntl","useIntlContext","formats","locale","globalNow","now","onError","timeZone","useMemo","createIntl"],"mappings":";;;;AAIc,SAAUA,OAAV,GAAiB;AAC7B,EAAA,IAAA,eAAA,GAA6DC,cAAc,EAA3E;AAAA,MAAOC,OAAP,mBAAOA,OAAP;AAAA,MAAgBC,MAAhB,mBAAgBA,MAAhB;AAAA,MAA6BC,SAA7B,mBAAwBC,GAAxB;AAAA,MAAwCC,OAAxC,mBAAwCA,OAAxC;AAAA,MAAiDC,QAAjD,mBAAiDA,QAAjD,CAAA;;AAEA,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,UAAU,CAAC;AACTP,MAAAA,OAAO,EAAPA,OADS;AAETC,MAAAA,MAAM,EAANA,MAFS;AAGTE,MAAAA,GAAG,EAAED,SAHI;AAITE,MAAAA,OAAO,EAAPA,OAJS;AAKTC,MAAAA,QAAQ,EAARA,QAAAA;AALS,KAAD,CADZ,CAAA;AAAA,GADY,EASZ,CAACL,OAAD,EAAUE,SAAV,EAAqBD,MAArB,EAA6BG,OAA7B,EAAsCC,QAAtC,CATY,CAAd,CAAA;AAWD;;;;"}
|
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import createIntl from '../core/use-intl.esm3.js';
|
|
3
1
|
import useIntlContext from './use-intl.esm8.js';
|
|
4
2
|
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
formats = _useIntlContext.formats,
|
|
8
|
-
locale = _useIntlContext.locale,
|
|
9
|
-
globalNow = _useIntlContext.now,
|
|
10
|
-
onError = _useIntlContext.onError,
|
|
11
|
-
timeZone = _useIntlContext.timeZone;
|
|
12
|
-
|
|
13
|
-
return useMemo(function () {
|
|
14
|
-
return createIntl({
|
|
15
|
-
formats: formats,
|
|
16
|
-
locale: locale,
|
|
17
|
-
now: globalNow,
|
|
18
|
-
onError: onError,
|
|
19
|
-
timeZone: timeZone
|
|
20
|
-
});
|
|
21
|
-
}, [formats, globalNow, locale, onError, timeZone]);
|
|
3
|
+
function useLocale() {
|
|
4
|
+
return useIntlContext().locale;
|
|
22
5
|
}
|
|
23
6
|
|
|
24
|
-
export {
|
|
7
|
+
export { useLocale as default };
|
|
25
8
|
//# sourceMappingURL=use-intl.esm4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm4.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm4.js","sources":["../../src/react/useLocale.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n"],"names":["useLocale","useIntlContext","locale"],"mappings":";;AAEc,SAAUA,SAAV,GAAmB;AAC/B,EAAOC,OAAAA,cAAc,GAAGC,MAAxB,CAAA;AACD;;;;"}
|
package/dist/use-intl.esm.js
CHANGED
|
@@ -3,8 +3,8 @@ export { default as createTranslator } from './core/use-intl.esm2.js';
|
|
|
3
3
|
export { default as createIntl } from './core/use-intl.esm3.js';
|
|
4
4
|
export { default as IntlProvider } from './react/use-intl.esm.js';
|
|
5
5
|
export { default as useTranslations } from './react/use-intl.esm2.js';
|
|
6
|
-
export { default as useIntl } from './react/use-intl.
|
|
7
|
-
export { default as useLocale } from './react/use-intl.
|
|
6
|
+
export { default as useIntl } from './react/use-intl.esm3.js';
|
|
7
|
+
export { default as useLocale } from './react/use-intl.esm4.js';
|
|
8
8
|
export { default as useNow } from './react/use-intl.esm5.js';
|
|
9
9
|
export { default as useTimeZone } from './react/use-intl.esm6.js';
|
|
10
10
|
//# sourceMappingURL=use-intl.esm.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-intl",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.me>",
|
|
6
6
|
"description": "Minimal, but complete solution for managing internationalization in React apps.",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=10"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "ef170366c1b0689d969b17e70f9e70a296e86254"
|
|
64
64
|
}
|