use-intl 2.11.0-alpha.2 → 2.11.0
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/LICENSE +21 -0
- package/README.md +32 -20
- package/dist/core/createFormatter.d.ts +17 -0
- package/dist/core/createIntl.d.ts +5 -15
- package/dist/core/index.d.ts +1 -0
- package/dist/core/use-intl.esm10.js +34 -0
- package/dist/core/use-intl.esm10.js.map +1 -0
- package/dist/core/use-intl.esm2.js +2 -2
- package/dist/core/use-intl.esm3.js +10 -10
- package/dist/core/use-intl.esm3.js.map +1 -1
- package/dist/core/use-intl.esm4.js +9 -53
- package/dist/core/use-intl.esm4.js.map +1 -1
- package/dist/core/use-intl.esm5.js +56 -12
- package/dist/core/use-intl.esm5.js.map +1 -1
- package/dist/core/use-intl.esm6.js +11 -209
- package/dist/core/use-intl.esm6.js.map +1 -1
- package/dist/core/use-intl.esm7.js +29 -7
- package/dist/core/use-intl.esm7.js.map +1 -1
- package/dist/core/use-intl.esm8.js +199 -18
- package/dist/core/use-intl.esm8.js.map +1 -1
- package/dist/core/use-intl.esm9.js +5 -29
- package/dist/core/use-intl.esm9.js.map +1 -1
- package/dist/react/IntlContext.d.ts +19 -2
- package/dist/react/IntlProvider.d.ts +16 -2
- package/dist/react/index.d.ts +2 -1
- package/dist/react/use-intl.esm.js +26 -7
- package/dist/react/use-intl.esm.js.map +1 -1
- package/dist/react/use-intl.esm10.js +2 -2
- package/dist/react/use-intl.esm2.js +20 -19
- package/dist/react/use-intl.esm2.js.map +1 -1
- package/dist/react/use-intl.esm3.js +3 -21
- package/dist/react/use-intl.esm3.js.map +1 -1
- package/dist/react/use-intl.esm4.js +45 -3
- package/dist/react/use-intl.esm4.js.map +1 -1
- package/dist/react/use-intl.esm6.js +18 -43
- package/dist/react/use-intl.esm6.js.map +1 -1
- package/dist/react/use-intl.esm7.js +30 -3
- package/dist/react/use-intl.esm7.js.map +1 -1
- package/dist/react/use-intl.esm8.js +3 -30
- package/dist/react/use-intl.esm8.js.map +1 -1
- package/dist/react/use-intl.esm9.js +1 -1
- package/dist/react/useFormatter.d.ts +5 -0
- package/dist/react/useIntl.d.ts +1 -0
- package/dist/react/useIntlContext.d.ts +1 -1
- package/dist/src/core/createBaseTranslator.js +11 -8
- package/dist/src/core/createBaseTranslator.js.map +1 -1
- package/dist/src/core/createFormatter.d.ts +17 -0
- package/dist/src/core/createFormatter.js +126 -0
- package/dist/src/core/createFormatter.js.map +1 -0
- package/dist/src/core/createIntl.d.ts +5 -15
- package/dist/src/core/createIntl.js +9 -124
- package/dist/src/core/createIntl.js.map +1 -1
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/core/index.js +2 -0
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/react/IntlContext.d.ts +19 -2
- package/dist/src/react/IntlContext.js.map +1 -1
- package/dist/src/react/IntlProvider.d.ts +16 -2
- package/dist/src/react/IntlProvider.js +13 -4
- package/dist/src/react/IntlProvider.js.map +1 -1
- package/dist/src/react/index.d.ts +2 -1
- package/dist/src/react/index.js +3 -1
- package/dist/src/react/index.js.map +1 -1
- package/dist/src/react/useFormatter.d.ts +5 -0
- package/dist/src/react/useFormatter.js +14 -0
- package/dist/src/react/useFormatter.js.map +1 -0
- package/dist/src/react/useIntl.d.ts +1 -0
- package/dist/src/react/useIntl.js +6 -0
- package/dist/src/react/useIntl.js.map +1 -1
- package/dist/src/react/useIntlContext.d.ts +1 -1
- package/dist/use-intl.cjs.development.js +99 -68
- package/dist/use-intl.cjs.development.js.map +1 -1
- package/dist/use-intl.cjs.production.min.js +1 -1
- package/dist/use-intl.cjs.production.min.js.map +1 -1
- package/dist/use-intl.esm.js +7 -5
- package/dist/use-intl.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/core/createBaseTranslator.tsx +15 -12
- package/src/core/createFormatter.tsx +181 -0
- package/src/core/createIntl.tsx +12 -180
- package/src/core/index.tsx +3 -0
- package/src/react/IntlContext.tsx +20 -2
- package/src/react/IntlProvider.tsx +36 -5
- package/src/react/index.tsx +4 -1
- package/src/react/useFormatter.tsx +19 -0
- package/src/react/useIntl.tsx +10 -0
- package/CHANGELOG.md +0 -501
- package/dist/react/IntlContextValue.d.ts +0 -19
- package/dist/react/IntlProviderProps.d.ts +0 -15
- package/dist/react/getIntlContextValue.d.ts +0 -18
- package/dist/src/react/IntlContextValue.d.ts +0 -19
- package/dist/src/react/IntlContextValue.js +0 -2
- package/dist/src/react/IntlContextValue.js.map +0 -1
- package/dist/src/react/IntlProviderProps.d.ts +0 -15
- package/dist/src/react/IntlProviderProps.js +0 -2
- package/dist/src/react/IntlProviderProps.js.map +0 -1
- package/dist/src/react/getIntlContextValue.d.ts +0 -18
- package/dist/src/react/getIntlContextValue.js +0 -21
- package/dist/src/react/getIntlContextValue.js.map +0 -1
- package/src/react/IntlContextValue.tsx +0 -21
- package/src/react/IntlProviderProps.tsx +0 -17
- package/src/react/getIntlContextValue.tsx +0 -30
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Jan Amann
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
# 🌐 use-intl
|
|
2
2
|
|
|
3
|
-
 
|
|
3
|
+
  [<img src="https://img.shields.io/npm/dw/use-intl.svg" />](https://www.npmjs.com/package/use-intl)
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> Internationalization for React that gets out of your way.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
9
|
+
Internationalization is an essential part of the user experience. use-intl gives you everything you need to get language subtleties right and has always got your back whenever you need to fine-tune a translation.
|
|
10
|
+
|
|
11
|
+
- 🌟 **ICU message syntax**: Localize your messages with interpolation, plurals, ordinal pluralization, enum-based label selection and rich text.
|
|
12
|
+
- 📅 **Dates, times & numbers**: Use global formats for a consistent look & feel of your app and apply fine-tuning as necessary.
|
|
13
|
+
- ✅ **Type-safe**: Speed up development with autocompletion for message keys and catch typos early with compile-time checks.
|
|
14
|
+
- 💡 **Hooks-only API**: Learn a single API that can be used across your code base to turn translations into plain strings or rich text.
|
|
15
|
+
- ⚔️ **Standards-based**: Use the best parts of built-in JavaScript APIs and supplemental lower-level APIs from Format.JS.
|
|
14
16
|
|
|
15
17
|
## What does it look like?
|
|
16
18
|
|
|
17
19
|
This library is based on the premise that messages can be grouped by namespaces (typically a component name).
|
|
18
20
|
|
|
19
21
|
```jsx
|
|
20
|
-
//
|
|
21
|
-
import {useTranslations} from '
|
|
22
|
-
|
|
23
|
-
function
|
|
24
|
-
const t = useTranslations('
|
|
25
|
-
|
|
22
|
+
// UserDetails.tsx
|
|
23
|
+
import {useTranslations, useFormatter} from 'next-intl';
|
|
24
|
+
|
|
25
|
+
function UserDetails({user}) {
|
|
26
|
+
const t = useTranslations('UserDetails');
|
|
27
|
+
const format = useFormatter();
|
|
28
|
+
|
|
26
29
|
return (
|
|
27
|
-
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
|
|
30
|
+
<section>
|
|
31
|
+
<h2>{t('title')}</h2>
|
|
32
|
+
<p>{t('followers', {count: user.followers.length})}</p>
|
|
33
|
+
<p>{t('lastSeen', {time: format.relativeTime(user.lastSeen)})</p>
|
|
34
|
+
<Image alt={t('portrait', {username: user.name})} src={user.portrait} />
|
|
35
|
+
</section>
|
|
31
36
|
);
|
|
32
37
|
}
|
|
33
38
|
```
|
|
@@ -35,9 +40,15 @@ function LatestFollower({user}) {
|
|
|
35
40
|
```js
|
|
36
41
|
// en.json
|
|
37
42
|
{
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
43
|
+
"UserDetails": {
|
|
44
|
+
"title": "User details",
|
|
45
|
+
"followers": "{count, plural, ↵
|
|
46
|
+
=0 {No followers yet} ↵
|
|
47
|
+
=1 {One follower} ↵
|
|
48
|
+
other {# followers} ↵
|
|
49
|
+
}",
|
|
50
|
+
"lastSeen": "Last seen {time}",
|
|
51
|
+
"portrait": "Portrait of {username}"
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
54
|
```
|
|
@@ -46,6 +57,7 @@ function LatestFollower({user}) {
|
|
|
46
57
|
|
|
47
58
|
1. `npm install use-intl`
|
|
48
59
|
2. Add the provider
|
|
60
|
+
|
|
49
61
|
```jsx
|
|
50
62
|
import {IntlProvider} from 'use-intl';
|
|
51
63
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DateTimeFormatOptions from './DateTimeFormatOptions';
|
|
2
|
+
import Formats from './Formats';
|
|
3
|
+
import IntlError from './IntlError';
|
|
4
|
+
import NumberFormatOptions from './NumberFormatOptions';
|
|
5
|
+
declare type Props = {
|
|
6
|
+
locale: string;
|
|
7
|
+
timeZone?: string;
|
|
8
|
+
onError?(error: IntlError): void;
|
|
9
|
+
formats?: Partial<Formats>;
|
|
10
|
+
now?: Date;
|
|
11
|
+
};
|
|
12
|
+
export default function createFormatter({ formats, locale, now: globalNow, onError, timeZone }: Props): {
|
|
13
|
+
dateTime: (value: Date | number, formatOrOptions?: string | DateTimeFormatOptions | undefined) => string;
|
|
14
|
+
number: (value: number, formatOrOptions?: string | NumberFormatOptions | undefined) => string;
|
|
15
|
+
relativeTime: (date: number | Date, now?: number | Date | undefined) => string;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
locale: string;
|
|
7
|
-
timeZone?: string;
|
|
8
|
-
onError?(error: IntlError): void;
|
|
9
|
-
formats?: Partial<Formats>;
|
|
10
|
-
now?: Date;
|
|
11
|
-
};
|
|
12
|
-
export default function createIntl({ formats, locale, now: globalNow, onError, timeZone }: Props): {
|
|
13
|
-
formatDateTime: (value: Date | number, formatOrOptions?: string | DateTimeFormatOptions | undefined) => string;
|
|
14
|
-
formatNumber: (value: number, formatOrOptions?: string | NumberFormatOptions | undefined) => string;
|
|
1
|
+
import createFormatter from './createFormatter';
|
|
2
|
+
/** @deprecated Switch to `createFormatter` */
|
|
3
|
+
export default function createIntl(...args: Parameters<typeof createFormatter>): {
|
|
4
|
+
formatDateTime: (value: number | Date, formatOrOptions?: string | import("./DateTimeFormatOptions").default | undefined) => string;
|
|
5
|
+
formatNumber: (value: number, formatOrOptions?: string | import("@formatjs/ecma402-abstract").NumberFormatOptions | undefined) => string;
|
|
15
6
|
formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
|
|
16
7
|
};
|
|
17
|
-
export {};
|
package/dist/core/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { default as DateTimeFormatOptions } from './DateTimeFormatOptions';
|
|
|
5
5
|
export { default as NumberFormatOptions } from './NumberFormatOptions';
|
|
6
6
|
export { default as IntlError, IntlErrorCode } from './IntlError';
|
|
7
7
|
export { default as createTranslator } from './createTranslator';
|
|
8
|
+
export { default as createFormatter } from './createFormatter';
|
|
8
9
|
export { default as createIntl } from './createIntl';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { extends as _extends } from '../_virtual/use-intl.esm.js';
|
|
2
|
+
|
|
3
|
+
function setTimeZoneInFormats(formats, timeZone) {
|
|
4
|
+
if (!formats) return formats; // The only way to set a time zone with `intl-messageformat` is to merge it into the formats
|
|
5
|
+
// https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15
|
|
6
|
+
|
|
7
|
+
return Object.keys(formats).reduce(function (acc, key) {
|
|
8
|
+
acc[key] = _extends({
|
|
9
|
+
timeZone: timeZone
|
|
10
|
+
}, formats[key]);
|
|
11
|
+
return acc;
|
|
12
|
+
}, {});
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `intl-messageformat` uses separate keys for `date` and `time`, but there's
|
|
16
|
+
* only one native API: `Intl.DateTimeFormat`. Additionally you might want to
|
|
17
|
+
* include both a time and a date in a value, therefore the separation doesn't
|
|
18
|
+
* seem so useful. We offer a single `dateTime` namespace instead, but we have
|
|
19
|
+
* to convert the format before `intl-messageformat` can be used.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function convertFormatsToIntlMessageFormat(formats, timeZone) {
|
|
24
|
+
var formatsWithTimeZone = timeZone ? _extends({}, formats, {
|
|
25
|
+
dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)
|
|
26
|
+
}) : formats;
|
|
27
|
+
return _extends({}, formatsWithTimeZone, {
|
|
28
|
+
date: formatsWithTimeZone == null ? void 0 : formatsWithTimeZone.dateTime,
|
|
29
|
+
time: formatsWithTimeZone == null ? void 0 : formatsWithTimeZone.dateTime
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { convertFormatsToIntlMessageFormat as default };
|
|
34
|
+
//# sourceMappingURL=use-intl.esm10.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-intl.esm10.js","sources":["../../src/core/convertFormatsToIntlMessageFormat.tsx"],"sourcesContent":["import {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: string\n) {\n if (!formats) return formats;\n\n // The only way to set a time zone with `intl-messageformat` is to merge it into the formats\n // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15\n return Object.keys(formats).reduce(\n (acc: Record<string, DateTimeFormatOptions>, key) => {\n acc[key] = {\n timeZone,\n ...formats[key]\n };\n return acc;\n },\n {}\n );\n}\n\n/**\n * `intl-messageformat` uses separate keys for `date` and `time`, but there's\n * only one native API: `Intl.DateTimeFormat`. Additionally you might want to\n * include both a time and a date in a value, therefore the separation doesn't\n * seem so useful. We offer a single `dateTime` namespace instead, but we have\n * to convert the format before `intl-messageformat` can be used.\n */\nexport default function convertFormatsToIntlMessageFormat(\n formats: Partial<Formats>,\n timeZone?: string\n): Partial<IntlFormats> {\n const formatsWithTimeZone = timeZone\n ? {...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)}\n : formats;\n\n return {\n ...formatsWithTimeZone,\n date: formatsWithTimeZone?.dateTime,\n time: formatsWithTimeZone?.dateTime\n };\n}\n"],"names":["setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","key","convertFormatsToIntlMessageFormat","formatsWithTimeZone","dateTime","date","time"],"mappings":";;AAIA,SAASA,oBAAT,CACEC,OADF,EAEEC,QAFF,EAEkB;AAEhB,EAAA,IAAI,CAACD,OAAL,EAAc,OAAOA,OAAP,CAFE;AAKhB;;AACA,EAAA,OAAOE,MAAM,CAACC,IAAP,CAAYH,OAAZ,CAAA,CAAqBI,MAArB,CACL,UAACC,GAAD,EAA6CC,GAA7C,EAAoD;AAClDD,IAAAA,GAAG,CAACC,GAAD,CAAH,GAAA,QAAA,CAAA;AACEL,MAAAA,QAAQ,EAARA,QAAAA;AADF,KAEKD,EAAAA,OAAO,CAACM,GAAD,CAFZ,CAAA,CAAA;AAIA,IAAA,OAAOD,GAAP,CAAA;AACD,GAPI,EAQL,EARK,CAAP,CAAA;AAUD,CAAA;AAED;;;;;;AAMG;;;AACW,SAAUE,iCAAV,CACZP,OADY,EAEZC,QAFY,EAEK;AAEjB,EAAA,IAAMO,mBAAmB,GAAGP,QAAQ,GAAA,QAAA,CAAA,EAAA,EAC5BD,OAD4B,EAAA;AACnBS,IAAAA,QAAQ,EAAEV,oBAAoB,CAACC,OAAO,CAACS,QAAT,EAAmBR,QAAnB,CAAA;AADX,GAAA,CAAA,GAEhCD,OAFJ,CAAA;AAIA,EAAA,OAAA,QAAA,CAAA,EAAA,EACKQ,mBADL,EAAA;AAEEE,IAAAA,IAAI,EAAEF,mBAAF,IAAEA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,mBAAmB,CAAEC,QAF7B;AAGEE,IAAAA,IAAI,EAAEH,mBAAF,IAAA,IAAA,GAAA,KAAA,CAAA,GAAEA,mBAAmB,CAAEC,QAAAA;AAH7B,GAAA,CAAA,CAAA;AAKD;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/use-intl.esm.js';
|
|
2
|
-
import createTranslatorImpl from './use-intl.
|
|
3
|
-
import { defaultOnError, defaultGetMessageFallback } from './use-intl.
|
|
2
|
+
import createTranslatorImpl from './use-intl.esm5.js';
|
|
3
|
+
import { defaultOnError, defaultGetMessageFallback } from './use-intl.esm6.js';
|
|
4
4
|
|
|
5
5
|
var _excluded = ["onError", "getMessageFallback", "messages", "namespace"];
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { extends as _extends } from '../_virtual/use-intl.esm.js';
|
|
2
2
|
import IntlError, { IntlErrorCode } from './use-intl.esm.js';
|
|
3
|
-
import { defaultOnError } from './use-intl.
|
|
3
|
+
import { defaultOnError } from './use-intl.esm6.js';
|
|
4
4
|
|
|
5
5
|
var MINUTE = 60;
|
|
6
6
|
var HOUR = MINUTE * 60;
|
|
@@ -44,7 +44,7 @@ function getRelativeTimeFormatConfig(seconds) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
function
|
|
47
|
+
function createFormatter(_ref) {
|
|
48
48
|
var formats = _ref.formats,
|
|
49
49
|
locale = _ref.locale,
|
|
50
50
|
globalNow = _ref.now,
|
|
@@ -88,7 +88,7 @@ function createIntl(_ref) {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
function
|
|
91
|
+
function dateTime(
|
|
92
92
|
/** If a number is supplied, this is interpreted as a UTC timestamp. */
|
|
93
93
|
value,
|
|
94
94
|
/** If a time zone is supplied, the `value` is converted to that time zone.
|
|
@@ -107,13 +107,13 @@ function createIntl(_ref) {
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
function
|
|
110
|
+
function number(value, formatOrOptions) {
|
|
111
111
|
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.number, function (options) {
|
|
112
112
|
return new Intl.NumberFormat(locale, options).format(value);
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
function
|
|
116
|
+
function relativeTime(
|
|
117
117
|
/** The date time that needs to be formatted. */
|
|
118
118
|
date,
|
|
119
119
|
/** The reference point in time to which `date` will be formatted in relation to. */
|
|
@@ -123,7 +123,7 @@ function createIntl(_ref) {
|
|
|
123
123
|
if (globalNow) {
|
|
124
124
|
now = globalNow;
|
|
125
125
|
} else {
|
|
126
|
-
throw new Error(process.env.NODE_ENV !== 'production' ? "The `now` parameter wasn't provided
|
|
126
|
+
throw new Error(process.env.NODE_ENV !== 'production' ? "The `now` parameter wasn't provided and there was no global fallback configured on the provider." : undefined);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -145,11 +145,11 @@ function createIntl(_ref) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
return {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
dateTime: dateTime,
|
|
149
|
+
number: number,
|
|
150
|
+
relativeTime: relativeTime
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
export {
|
|
154
|
+
export { createFormatter as default };
|
|
155
155
|
//# sourceMappingURL=use-intl.esm3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm3.js","sources":["../../src/core/createIntl.tsx"],"sourcesContent":["import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: string;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createIntl({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function formatDateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function formatNumber(\n value: number,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function formatRelativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided to \\`formatRelativeTime\\` and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n return {formatDateTime, formatNumber, formatRelativeTime};\n}\n"],"names":["MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","Math","abs","value","unit","round","createIntl","formats","locale","globalNow","now","onError","defaultOnError","timeZone","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","error","IntlError","IntlErrorCode","MISSING_FORMAT","process","env","NODE_ENV","undefined","getFormattedValue","formatter","String","FORMATTING_ERROR","message","formatDateTime","dateTime","Intl","DateTimeFormat","format","formatNumber","number","NumberFormat","formatRelativeTime","date","Error","dateDate","Date","nowDate","getTime","RelativeTimeFormat","numeric"],"mappings":";;;;AAMA,IAAMA,MAAM,GAAG,EAAf,CAAA;AACA,IAAMC,IAAI,GAAGD,MAAM,GAAG,EAAtB,CAAA;AACA,IAAME,GAAG,GAAGD,IAAI,GAAG,EAAnB,CAAA;AACA,IAA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A3D,CAAA;;AACA,MAAsBhD,IAAAA,qBAAAA,GAAAA,2BAA2B,CAACC,OAAD,CAAjD;AAAA,UAAOK,IAAP,yBAAOA,IAAP;AAAA,UAAaD,KAAb,yBAAaA,KAAb,CAAA;;AAEA,MAAA,OAAO,IAAI+B,IAAI,CAACa,kBAAT,CAA4BvC,MAA5B,EAAoC;AACzCwC,QAAAA,OAAO,EAAE,MAAA;AADgC,OAApC,EAEJZ,MAFI,CAEGjC,KAFH,EAEUC,IAFV,CAAP,CAAA;AAGD,KAtBD,CAsBE,OAAOe,KAAP,EAAc;AACdR,MAAAA,OAAO,CACL,IAAIS,SAAJ,CAAcC,aAAa,CAACS,gBAA5B,EAA+CX,KAAe,CAACY,OAA/D,CADK,CAAP,CAAA;AAGA,MAAOF,OAAAA,MAAM,CAACY,IAAD,CAAb,CAAA;AACD,KAAA;AACF,GAAA;;AAED,EAAO,OAAA;AAACT,IAAAA,cAAc,EAAdA,cAAD;AAAiBK,IAAAA,YAAY,EAAZA,YAAjB;AAA+BG,IAAAA,kBAAkB,EAAlBA,kBAAAA;AAA/B,GAAP,CAAA;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"use-intl.esm3.js","sources":["../../src/core/createFormatter.tsx"],"sourcesContent":["import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: string;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n return {dateTime, number, relativeTime};\n}\n"],"names":["MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","Math","abs","value","unit","round","createFormatter","formats","locale","globalNow","now","onError","defaultOnError","timeZone","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","error","IntlError","IntlErrorCode","MISSING_FORMAT","process","env","NODE_ENV","undefined","getFormattedValue","formatter","String","FORMATTING_ERROR","message","dateTime","Intl","DateTimeFormat","format","number","NumberFormat","relativeTime","date","Error","dateDate","Date","nowDate","getTime","RelativeTimeFormat","numeric"],"mappings":";;;;AAMA,IAAMA,MAAM,GAAG,EAAf,CAAA;AACA,IAAMC,IAAI,GAAGD,MAAM,GAAG,EAAtB,CAAA;AACA,I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AAqBD,GAAAA,OAAO,CAACC,OAAR,EAAtB,IAA2C,IAA3D,CAAA;;AACA,MAAsB9C,IAAAA,qBAAAA,GAAAA,2BAA2B,CAACC,OAAD,CAAjD;AAAA,UAAOK,IAAP,yBAAOA,IAAP;AAAA,UAAaD,KAAb,yBAAaA,KAAb,CAAA;;AAEA,MAAA,OAAO,IAAI8B,IAAI,CAACY,kBAAT,CAA4BrC,MAA5B,EAAoC;AACzCsC,QAAAA,OAAO,EAAE,MAAA;AADgC,OAApC,EAEJX,MAFI,CAEGhC,KAFH,EAEUC,IAFV,CAAP,CAAA;AAGD,KAtBD,CAsBE,OAAOe,KAAP,EAAc;AACdR,MAAAA,OAAO,CACL,IAAIS,SAAJ,CAAcC,aAAa,CAACS,gBAA5B,EAA+CX,KAAe,CAACY,OAA/D,CADK,CAAP,CAAA;AAGA,MAAOF,OAAAA,MAAM,CAACU,IAAD,CAAb,CAAA;AACD,KAAA;AACF,GAAA;;AAED,EAAO,OAAA;AAACP,IAAAA,QAAQ,EAARA,QAAD;AAAWI,IAAAA,MAAM,EAANA,MAAX;AAAmBE,IAAAA,YAAY,EAAZA,YAAAA;AAAnB,GAAP,CAAA;AACD;;;;"}
|
|
@@ -1,59 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import IntlError, { IntlErrorCode } from './use-intl.esm.js';
|
|
3
|
-
import createBaseTranslator, { getMessagesOrError } from './use-intl.esm6.js';
|
|
4
|
-
import resolveNamespace from './use-intl.esm7.js';
|
|
1
|
+
import createFormatter from './use-intl.esm3.js';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
function createTranslatorImpl(_ref, namespacePrefix) {
|
|
8
|
-
var getMessageFallback = _ref.getMessageFallback,
|
|
9
|
-
messages = _ref.messages,
|
|
10
|
-
namespace = _ref.namespace,
|
|
11
|
-
onError = _ref.onError,
|
|
12
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
3
|
+
/** @deprecated Switch to `createFormatter` */
|
|
13
4
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
getMessageFallback: getMessageFallback,
|
|
21
|
-
messagesOrError: getMessagesOrError({
|
|
22
|
-
messages: messages,
|
|
23
|
-
namespace: namespace,
|
|
24
|
-
onError: onError
|
|
25
|
-
})
|
|
26
|
-
}));
|
|
27
|
-
var originalRich = translator.rich;
|
|
28
|
-
|
|
29
|
-
function base() {
|
|
30
|
-
return translator.apply(void 0, arguments);
|
|
31
|
-
} // Augment `t.rich` to return plain strings
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
base.rich = function (key,
|
|
35
|
-
/** Key value pairs for values to interpolate into the message. */
|
|
36
|
-
values, formats) {
|
|
37
|
-
// `chunks` is returned as a string when no React element
|
|
38
|
-
// is used, therefore it's safe to cast this type.
|
|
39
|
-
var result = originalRich(key, values, formats); // When only string chunks are provided to the parser, only strings should be returned here.
|
|
40
|
-
|
|
41
|
-
if (typeof result !== 'string') {
|
|
42
|
-
var error = new IntlError(IntlErrorCode.FORMATTING_ERROR, process.env.NODE_ENV !== 'production' ? "`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})" : undefined);
|
|
43
|
-
onError(error);
|
|
44
|
-
return getMessageFallback({
|
|
45
|
-
error: error,
|
|
46
|
-
key: key,
|
|
47
|
-
namespace: namespace
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return result;
|
|
5
|
+
function createIntl() {
|
|
6
|
+
var formatter = createFormatter.apply(void 0, arguments);
|
|
7
|
+
return {
|
|
8
|
+
formatDateTime: formatter.dateTime,
|
|
9
|
+
formatNumber: formatter.number,
|
|
10
|
+
formatRelativeTime: formatter.relativeTime
|
|
52
11
|
};
|
|
53
|
-
|
|
54
|
-
base.raw = translator.raw;
|
|
55
|
-
return base;
|
|
56
12
|
}
|
|
57
13
|
|
|
58
|
-
export {
|
|
14
|
+
export { createIntl as default };
|
|
59
15
|
//# sourceMappingURL=use-intl.esm4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm4.js","sources":["../../src/core/
|
|
1
|
+
{"version":3,"file":"use-intl.esm4.js","sources":["../../src/core/createIntl.tsx"],"sourcesContent":["import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n"],"names":["createIntl","formatter","createFormatter","formatDateTime","dateTime","formatNumber","number","formatRelativeTime","relativeTime"],"mappings":";;AAEA;;AACc,SAAUA,UAAV,GAC+B;AAE3C,EAAA,IAAMC,SAAS,GAAGC,eAAe,CAAA,KAAf,CAAlB,KAAA,CAAA,EAAA,SAAA,CAAA,CAAA;AACA,EAAO,OAAA;AACLC,IAAAA,cAAc,EAAEF,SAAS,CAACG,QADrB;AAELC,IAAAA,YAAY,EAAEJ,SAAS,CAACK,MAFnB;AAGLC,IAAAA,kBAAkB,EAAEN,SAAS,CAACO,YAAAA;AAHzB,GAAP,CAAA;AAKD;;;;"}
|
|
@@ -1,15 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/use-intl.esm.js';
|
|
2
|
+
import IntlError, { IntlErrorCode } from './use-intl.esm.js';
|
|
3
|
+
import createBaseTranslator, { getMessagesOrError } from './use-intl.esm8.js';
|
|
4
|
+
import resolveNamespace from './use-intl.esm9.js';
|
|
5
|
+
|
|
6
|
+
var _excluded = ["getMessageFallback", "messages", "namespace", "onError"];
|
|
7
|
+
function createTranslatorImpl(_ref, namespacePrefix) {
|
|
8
|
+
var getMessageFallback = _ref.getMessageFallback,
|
|
9
|
+
messages = _ref.messages,
|
|
10
|
+
namespace = _ref.namespace,
|
|
11
|
+
onError = _ref.onError,
|
|
12
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
13
|
+
|
|
14
|
+
// The `namespacePrefix` is part of the type system.
|
|
15
|
+
// See the comment in the function invocation.
|
|
16
|
+
messages = messages[namespacePrefix];
|
|
17
|
+
namespace = resolveNamespace(namespace, namespacePrefix);
|
|
18
|
+
var translator = createBaseTranslator(_extends({}, rest, {
|
|
19
|
+
onError: onError,
|
|
20
|
+
getMessageFallback: getMessageFallback,
|
|
21
|
+
messagesOrError: getMessagesOrError({
|
|
22
|
+
messages: messages,
|
|
23
|
+
namespace: namespace,
|
|
24
|
+
onError: onError
|
|
25
|
+
})
|
|
26
|
+
}));
|
|
27
|
+
var originalRich = translator.rich;
|
|
28
|
+
|
|
29
|
+
function base() {
|
|
30
|
+
return translator.apply(void 0, arguments);
|
|
31
|
+
} // Augment `t.rich` to return plain strings
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
base.rich = function (key,
|
|
35
|
+
/** Key value pairs for values to interpolate into the message. */
|
|
36
|
+
values, formats) {
|
|
37
|
+
// `chunks` is returned as a string when no React element
|
|
38
|
+
// is used, therefore it's safe to cast this type.
|
|
39
|
+
var result = originalRich(key, values, formats); // When only string chunks are provided to the parser, only strings should be returned here.
|
|
40
|
+
|
|
41
|
+
if (typeof result !== 'string') {
|
|
42
|
+
var error = new IntlError(IntlErrorCode.FORMATTING_ERROR, process.env.NODE_ENV !== 'production' ? "`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})" : undefined);
|
|
43
|
+
onError(error);
|
|
44
|
+
return getMessageFallback({
|
|
45
|
+
error: error,
|
|
46
|
+
key: key,
|
|
47
|
+
namespace: namespace
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
base.raw = translator.raw;
|
|
55
|
+
return base;
|
|
12
56
|
}
|
|
13
57
|
|
|
14
|
-
export {
|
|
58
|
+
export { createTranslatorImpl as default };
|
|
15
59
|
//# sourceMappingURL=use-intl.esm5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm5.js","sources":["../../src/core/
|
|
1
|
+
{"version":3,"file":"use-intl.esm5.js","sources":["../../src/core/createTranslatorImpl.tsx"],"sourcesContent":["import AbstractIntlMessages from './AbstractIntlMessages';\nimport {InitializedIntlConfiguration} from './IntlConfiguration';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport {RichTranslationValues, TranslationValue} from './TranslationValues';\nimport createBaseTranslator, {getMessagesOrError} from './createBaseTranslator';\nimport resolveNamespace from './resolveNamespace';\nimport NestedKeyOf from './utils/NestedKeyOf';\n\nexport type CoreRichTranslationValues = Record<\n string,\n TranslationValue | ((chunks: string) => string)\n>;\n\nexport type CreateTranslatorImplProps<Messages> =\n InitializedIntlConfiguration & {\n namespace: string;\n messages: Messages;\n };\n\nexport default function createTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(\n {\n getMessageFallback,\n messages,\n namespace,\n onError,\n ...rest\n }: CreateTranslatorImplProps<Messages>,\n namespacePrefix: string\n) {\n // The `namespacePrefix` is part of the type system.\n // See the comment in the function invocation.\n messages = messages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const translator = createBaseTranslator<Messages, NestedKey>({\n ...rest,\n onError,\n getMessageFallback,\n messagesOrError: getMessagesOrError({\n messages,\n namespace,\n onError\n }) as Messages | IntlError\n });\n\n const originalRich = translator.rich;\n\n function base(...args: Parameters<typeof translator>) {\n return translator(...args);\n }\n\n // Augment `t.rich` to return plain strings\n base.rich = (\n key: Parameters<typeof originalRich>[0],\n /** Key value pairs for values to interpolate into the message. */\n values: CoreRichTranslationValues,\n formats?: Parameters<typeof originalRich>[2]\n ): string => {\n // `chunks` is returned as a string when no React element\n // is used, therefore it's safe to cast this type.\n const result = originalRich(key, values as RichTranslationValues, formats);\n\n // When only string chunks are provided to the parser, only strings should be returned here.\n if (typeof result !== 'string') {\n const error = new IntlError(\n IntlErrorCode.FORMATTING_ERROR,\n process.env.NODE_ENV !== 'production'\n ? \"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\\n\\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})\"\n : undefined\n );\n\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n return result;\n };\n\n base.raw = translator.raw;\n\n return base;\n}\n"],"names":["createTranslatorImpl","namespacePrefix","getMessageFallback","messages","namespace","onError","rest","resolveNamespace","translator","createBaseTranslator","messagesOrError","getMessagesOrError","originalRich","rich","base","key","values","formats","result","error","IntlError","IntlErrorCode","FORMATTING_ERROR","process","env","NODE_ENV","undefined","raw"],"mappings":";;;;;;AAmBc,SAAUA,oBAAV,CAWZC,IAAAA,EAAAA,eAXY,EAWW;AAAA,EANrBC,IAAAA,kBAMqB,QANrBA,kBAMqB;AAAA,MALrBC,QAKqB,QALrBA,QAKqB;AAAA,MAJrBC,SAIqB,QAJrBA,SAIqB;AAAA,MAHrBC,OAGqB,QAHrBA,OAGqB;AAAA,MAFlBC,IAEkB,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEvB;AACA;AACAH,EAAAA,QAAQ,GAAGA,QAAQ,CAACF,eAAD,CAAnB,CAAA;AACAG,EAAAA,SAAS,GAAGG,gBAAgB,CAACH,SAAD,EAAYH,eAAZ,CAA5B,CAAA;AAEA,EAAA,IAAMO,UAAU,GAAGC,oBAAoB,CAAA,QAAA,CAAA,EAAA,EAClCH,IADkC,EAAA;AAErCD,IAAAA,OAAO,EAAPA,OAFqC;AAGrCH,IAAAA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