use-intl 0.0.0-package-boundaries.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 +91 -0
- package/core.d.ts +1 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.esm.js +102 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -0
- package/dist/_virtual/use-intl.esm.js +102 -0
- package/dist/_virtual/use-intl.esm.js.map +1 -0
- package/dist/core/AbstractIntlMessages.d.ts +9 -0
- package/dist/core/DateTimeFormatOptions.d.ts +73 -0
- package/dist/core/Formats.d.ts +8 -0
- package/dist/core/IntlConfig.d.ts +54 -0
- package/dist/core/IntlError.d.ts +13 -0
- package/dist/core/IntlError.esm.js +33 -0
- package/dist/core/IntlError.esm.js.map +1 -0
- package/dist/core/NumberFormatOptions.d.ts +2 -0
- package/dist/core/TimeZone.d.ts +2 -0
- package/dist/core/TranslationValues.d.ts +6 -0
- package/dist/core/convertFormatsToIntlMessageFormat.d.ts +11 -0
- package/dist/core/convertFormatsToIntlMessageFormat.esm.js +32 -0
- package/dist/core/convertFormatsToIntlMessageFormat.esm.js.map +1 -0
- package/dist/core/createBaseTranslator.d.ts +21 -0
- package/dist/core/createBaseTranslator.esm.js +201 -0
- package/dist/core/createBaseTranslator.esm.js.map +1 -0
- package/dist/core/createFormatter.d.ts +19 -0
- package/dist/core/createFormatter.esm.js +138 -0
- package/dist/core/createFormatter.esm.js.map +1 -0
- package/dist/core/createIntl.d.ts +7 -0
- package/dist/core/createIntl.esm.js +14 -0
- package/dist/core/createIntl.esm.js.map +1 -0
- package/dist/core/createTranslator.d.ts +47 -0
- package/dist/core/createTranslator.esm.js +37 -0
- package/dist/core/createTranslator.esm.js.map +1 -0
- package/dist/core/createTranslatorImpl.d.ts +13 -0
- package/dist/core/createTranslatorImpl.esm.js +50 -0
- package/dist/core/createTranslatorImpl.esm.js.map +1 -0
- package/dist/core/defaults.d.ts +11 -0
- package/dist/core/defaults.esm.js +15 -0
- package/dist/core/defaults.esm.js.map +1 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/initializeConfig.d.ts +13 -0
- package/dist/core/initializeConfig.esm.js +29 -0
- package/dist/core/initializeConfig.esm.js.map +1 -0
- package/dist/core/resolveNamespace.d.ts +5 -0
- package/dist/core/resolveNamespace.esm.js +10 -0
- package/dist/core/resolveNamespace.esm.js.map +1 -0
- package/dist/core/use-intl.esm.js +33 -0
- package/dist/core/use-intl.esm.js.map +1 -0
- package/dist/core/use-intl.esm10.js +28 -0
- package/dist/core/use-intl.esm10.js.map +1 -0
- package/dist/core/use-intl.esm11.js +10 -0
- package/dist/core/use-intl.esm11.js.map +1 -0
- package/dist/core/use-intl.esm2.js +201 -0
- package/dist/core/use-intl.esm2.js.map +1 -0
- package/dist/core/use-intl.esm3.js +14 -0
- package/dist/core/use-intl.esm3.js.map +1 -0
- package/dist/core/use-intl.esm4.js +138 -0
- package/dist/core/use-intl.esm4.js.map +1 -0
- package/dist/core/use-intl.esm5.js +37 -0
- package/dist/core/use-intl.esm5.js.map +1 -0
- package/dist/core/use-intl.esm6.js +29 -0
- package/dist/core/use-intl.esm6.js.map +1 -0
- package/dist/core/use-intl.esm7.js +15 -0
- package/dist/core/use-intl.esm7.js.map +1 -0
- package/dist/core/use-intl.esm8.js +32 -0
- package/dist/core/use-intl.esm8.js.map +1 -0
- package/dist/core/use-intl.esm9.js +50 -0
- package/dist/core/use-intl.esm9.js.map +1 -0
- package/dist/core/utils/MessageKeys.d.ts +5 -0
- package/dist/core/utils/NamespaceKeys.d.ts +5 -0
- package/dist/core/utils/NestedKeyOf.d.ts +4 -0
- package/dist/core/utils/NestedValueOf.d.ts +2 -0
- package/dist/core/validateMessages.d.ts +3 -0
- package/dist/core/validateMessages.esm.js +28 -0
- package/dist/core/validateMessages.esm.js.map +1 -0
- package/dist/core.cjs.development.js +93 -0
- package/dist/core.cjs.development.js.map +1 -0
- package/dist/core.cjs.production.min.js +2 -0
- package/dist/core.cjs.production.min.js.map +1 -0
- package/dist/core.d.ts +1 -0
- package/dist/core.esm.js +7 -0
- package/dist/core.esm.js.map +1 -0
- package/dist/core.js +8 -0
- package/dist/createIntl-8a2b87eb.js +579 -0
- package/dist/createIntl-8a2b87eb.js.map +1 -0
- package/dist/createIntl-f7979de1.js +2 -0
- package/dist/createIntl-f7979de1.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/react/IntlContext.d.ts +4 -0
- package/dist/react/IntlContext.esm.js +6 -0
- package/dist/react/IntlContext.esm.js.map +1 -0
- package/dist/react/IntlProvider.d.ts +7 -0
- package/dist/react/IntlProvider.esm.js +16 -0
- package/dist/react/IntlProvider.esm.js.map +1 -0
- package/dist/react/getInitializedConfig.d.ts +1 -0
- package/dist/react/index.d.ts +8 -0
- package/dist/react/use-intl.esm.js +16 -0
- package/dist/react/use-intl.esm.js.map +1 -0
- package/dist/react/use-intl.esm10.js +13 -0
- package/dist/react/use-intl.esm10.js.map +1 -0
- package/dist/react/use-intl.esm11.js +36 -0
- package/dist/react/use-intl.esm11.js.map +1 -0
- package/dist/react/use-intl.esm2.js +8 -0
- package/dist/react/use-intl.esm2.js.map +1 -0
- package/dist/react/use-intl.esm3.js +8 -0
- package/dist/react/use-intl.esm3.js.map +1 -0
- package/dist/react/use-intl.esm4.js +26 -0
- package/dist/react/use-intl.esm4.js.map +1 -0
- package/dist/react/use-intl.esm5.js +45 -0
- package/dist/react/use-intl.esm5.js.map +1 -0
- package/dist/react/use-intl.esm6.js +30 -0
- package/dist/react/use-intl.esm6.js.map +1 -0
- package/dist/react/use-intl.esm7.js +8 -0
- package/dist/react/use-intl.esm7.js.map +1 -0
- package/dist/react/use-intl.esm8.js +24 -0
- package/dist/react/use-intl.esm8.js.map +1 -0
- package/dist/react/use-intl.esm9.js +6 -0
- package/dist/react/use-intl.esm9.js.map +1 -0
- package/dist/react/useFormatter.d.ts +6 -0
- package/dist/react/useFormatter.esm.js +24 -0
- package/dist/react/useFormatter.esm.js.map +1 -0
- package/dist/react/useIntl.d.ts +6 -0
- package/dist/react/useIntl.esm.js +30 -0
- package/dist/react/useIntl.esm.js.map +1 -0
- package/dist/react/useIntlContext.d.ts +1 -0
- package/dist/react/useIntlContext.esm.js +13 -0
- package/dist/react/useIntlContext.esm.js.map +1 -0
- package/dist/react/useLocale.d.ts +1 -0
- package/dist/react/useLocale.esm.js +8 -0
- package/dist/react/useLocale.esm.js.map +1 -0
- package/dist/react/useMessages.d.ts +1 -0
- package/dist/react/useMessages.esm.js +8 -0
- package/dist/react/useMessages.esm.js.map +1 -0
- package/dist/react/useNow.d.ts +23 -0
- package/dist/react/useNow.esm.js +45 -0
- package/dist/react/useNow.esm.js.map +1 -0
- package/dist/react/useTimeZone.d.ts +1 -0
- package/dist/react/useTimeZone.esm.js +8 -0
- package/dist/react/useTimeZone.esm.js.map +1 -0
- package/dist/react/useTranslations.d.ts +44 -0
- package/dist/react/useTranslations.esm.js +26 -0
- package/dist/react/useTranslations.esm.js.map +1 -0
- package/dist/react/useTranslationsImpl.d.ts +8 -0
- package/dist/react/useTranslationsImpl.esm.js +36 -0
- package/dist/react/useTranslationsImpl.esm.js.map +1 -0
- package/dist/react.cjs.development.js +184 -0
- package/dist/react.cjs.development.js.map +1 -0
- package/dist/react.cjs.production.min.js +2 -0
- package/dist/react.cjs.production.min.js.map +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.esm.js +9 -0
- package/dist/react.esm.js.map +1 -0
- package/dist/react.js +8 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/use-intl.cjs.development.js +823 -0
- package/dist/use-intl.cjs.development.js.map +1 -0
- package/dist/use-intl.cjs.production.min.js +2 -0
- package/dist/use-intl.cjs.production.min.js.map +1 -0
- package/dist/use-intl.esm.js +15 -0
- package/dist/use-intl.esm.js.map +1 -0
- package/package.json +78 -0
- package/react.d.ts +1 -0
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
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# 🌐 use-intl
|
|
2
|
+
|
|
3
|
+
  [<img src="https://img.shields.io/npm/dw/use-intl.svg" />](https://www.npmjs.com/package/use-intl)
|
|
4
|
+
|
|
5
|
+
> Internationalization for React that gets out of your way.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
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**: Apply appropriate formatting without worrying about server/client differences like time zones.
|
|
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.
|
|
16
|
+
|
|
17
|
+
## What does it look like?
|
|
18
|
+
|
|
19
|
+
This library is based on the premise that messages can be grouped by namespaces (typically a component name).
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
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
|
+
|
|
29
|
+
return (
|
|
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>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
// en.json
|
|
42
|
+
{
|
|
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}"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
1. `npm install use-intl`
|
|
59
|
+
2. Add the provider
|
|
60
|
+
|
|
61
|
+
```jsx
|
|
62
|
+
import {IntlProvider} from 'use-intl';
|
|
63
|
+
|
|
64
|
+
// You can get the messages from anywhere you like. You can also
|
|
65
|
+
// fetch them from within a component and then render the provider
|
|
66
|
+
// along with your app once you have the messages.
|
|
67
|
+
const messages = {
|
|
68
|
+
"App": {
|
|
69
|
+
"hello": 'Hello {username}!'
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
function Root() {
|
|
74
|
+
return (
|
|
75
|
+
<IntlProvider messages={messages} locale="en">
|
|
76
|
+
<App user={{name: 'Jane'}} />
|
|
77
|
+
</IntlProvider>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function App({user}) {
|
|
82
|
+
const t = useTranslations('App');
|
|
83
|
+
return <h1>{t('hello', {username: user.name})}</h1>;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
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.
|
|
88
|
+
|
|
89
|
+
## Usage
|
|
90
|
+
|
|
91
|
+
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`.
|
package/core.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/core';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
3
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
4
|
+
var source = arguments[i];
|
|
5
|
+
for (var key in source) {
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
+
target[key] = source[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
return _extends.apply(this, arguments);
|
|
14
|
+
}
|
|
15
|
+
function _inheritsLoose(subClass, superClass) {
|
|
16
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
17
|
+
subClass.prototype.constructor = subClass;
|
|
18
|
+
_setPrototypeOf(subClass, superClass);
|
|
19
|
+
}
|
|
20
|
+
function _getPrototypeOf(o) {
|
|
21
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
22
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
23
|
+
};
|
|
24
|
+
return _getPrototypeOf(o);
|
|
25
|
+
}
|
|
26
|
+
function _setPrototypeOf(o, p) {
|
|
27
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
28
|
+
o.__proto__ = p;
|
|
29
|
+
return o;
|
|
30
|
+
};
|
|
31
|
+
return _setPrototypeOf(o, p);
|
|
32
|
+
}
|
|
33
|
+
function _isNativeReflectConstruct() {
|
|
34
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
35
|
+
if (Reflect.construct.sham) return false;
|
|
36
|
+
if (typeof Proxy === "function") return true;
|
|
37
|
+
try {
|
|
38
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
39
|
+
return true;
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function _construct(Parent, args, Class) {
|
|
45
|
+
if (_isNativeReflectConstruct()) {
|
|
46
|
+
_construct = Reflect.construct.bind();
|
|
47
|
+
} else {
|
|
48
|
+
_construct = function _construct(Parent, args, Class) {
|
|
49
|
+
var a = [null];
|
|
50
|
+
a.push.apply(a, args);
|
|
51
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
52
|
+
var instance = new Constructor();
|
|
53
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
54
|
+
return instance;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return _construct.apply(null, arguments);
|
|
58
|
+
}
|
|
59
|
+
function _isNativeFunction(fn) {
|
|
60
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
61
|
+
}
|
|
62
|
+
function _wrapNativeSuper(Class) {
|
|
63
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
64
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
65
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
66
|
+
if (typeof Class !== "function") {
|
|
67
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
68
|
+
}
|
|
69
|
+
if (typeof _cache !== "undefined") {
|
|
70
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
71
|
+
_cache.set(Class, Wrapper);
|
|
72
|
+
}
|
|
73
|
+
function Wrapper() {
|
|
74
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
75
|
+
}
|
|
76
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
77
|
+
constructor: {
|
|
78
|
+
value: Wrapper,
|
|
79
|
+
enumerable: false,
|
|
80
|
+
writable: true,
|
|
81
|
+
configurable: true
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
85
|
+
};
|
|
86
|
+
return _wrapNativeSuper(Class);
|
|
87
|
+
}
|
|
88
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
89
|
+
if (source == null) return {};
|
|
90
|
+
var target = {};
|
|
91
|
+
var sourceKeys = Object.keys(source);
|
|
92
|
+
var key, i;
|
|
93
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
94
|
+
key = sourceKeys[i];
|
|
95
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
96
|
+
target[key] = source[key];
|
|
97
|
+
}
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { _construct as construct, _extends as extends, _getPrototypeOf as getPrototypeOf, _inheritsLoose as inheritsLoose, _isNativeFunction as isNativeFunction, _isNativeReflectConstruct as isNativeReflectConstruct, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose, _setPrototypeOf as setPrototypeOf, _wrapNativeSuper as wrapNativeSuper };
|
|
102
|
+
//# sourceMappingURL=_rollupPluginBabelHelpers.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_rollupPluginBabelHelpers.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
3
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
4
|
+
var source = arguments[i];
|
|
5
|
+
for (var key in source) {
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
+
target[key] = source[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
return _extends.apply(this, arguments);
|
|
14
|
+
}
|
|
15
|
+
function _inheritsLoose(subClass, superClass) {
|
|
16
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
17
|
+
subClass.prototype.constructor = subClass;
|
|
18
|
+
_setPrototypeOf(subClass, superClass);
|
|
19
|
+
}
|
|
20
|
+
function _getPrototypeOf(o) {
|
|
21
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
22
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
23
|
+
};
|
|
24
|
+
return _getPrototypeOf(o);
|
|
25
|
+
}
|
|
26
|
+
function _setPrototypeOf(o, p) {
|
|
27
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
28
|
+
o.__proto__ = p;
|
|
29
|
+
return o;
|
|
30
|
+
};
|
|
31
|
+
return _setPrototypeOf(o, p);
|
|
32
|
+
}
|
|
33
|
+
function _isNativeReflectConstruct() {
|
|
34
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
35
|
+
if (Reflect.construct.sham) return false;
|
|
36
|
+
if (typeof Proxy === "function") return true;
|
|
37
|
+
try {
|
|
38
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
39
|
+
return true;
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function _construct(Parent, args, Class) {
|
|
45
|
+
if (_isNativeReflectConstruct()) {
|
|
46
|
+
_construct = Reflect.construct.bind();
|
|
47
|
+
} else {
|
|
48
|
+
_construct = function _construct(Parent, args, Class) {
|
|
49
|
+
var a = [null];
|
|
50
|
+
a.push.apply(a, args);
|
|
51
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
52
|
+
var instance = new Constructor();
|
|
53
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
54
|
+
return instance;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return _construct.apply(null, arguments);
|
|
58
|
+
}
|
|
59
|
+
function _isNativeFunction(fn) {
|
|
60
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
61
|
+
}
|
|
62
|
+
function _wrapNativeSuper(Class) {
|
|
63
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
64
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
65
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
66
|
+
if (typeof Class !== "function") {
|
|
67
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
68
|
+
}
|
|
69
|
+
if (typeof _cache !== "undefined") {
|
|
70
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
71
|
+
_cache.set(Class, Wrapper);
|
|
72
|
+
}
|
|
73
|
+
function Wrapper() {
|
|
74
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
75
|
+
}
|
|
76
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
77
|
+
constructor: {
|
|
78
|
+
value: Wrapper,
|
|
79
|
+
enumerable: false,
|
|
80
|
+
writable: true,
|
|
81
|
+
configurable: true
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
85
|
+
};
|
|
86
|
+
return _wrapNativeSuper(Class);
|
|
87
|
+
}
|
|
88
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
89
|
+
if (source == null) return {};
|
|
90
|
+
var target = {};
|
|
91
|
+
var sourceKeys = Object.keys(source);
|
|
92
|
+
var key, i;
|
|
93
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
94
|
+
key = sourceKeys[i];
|
|
95
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
96
|
+
target[key] = source[key];
|
|
97
|
+
}
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { _construct as construct, _extends as extends, _getPrototypeOf as getPrototypeOf, _inheritsLoose as inheritsLoose, _isNativeFunction as isNativeFunction, _isNativeReflectConstruct as isNativeReflectConstruct, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose, _setPrototypeOf as setPrototypeOf, _wrapNativeSuper as wrapNativeSuper };
|
|
102
|
+
//# sourceMappingURL=use-intl.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-intl.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A generic type that describes the shape of messages.
|
|
2
|
+
*
|
|
3
|
+
* Optionally `IntlMessages` can be provided to get type safety for message
|
|
4
|
+
* namespaces and keys. See https://next-intl-docs.vercel.app/docs/usage/typescript
|
|
5
|
+
*/
|
|
6
|
+
type AbstractIntlMessages = {
|
|
7
|
+
[id: string]: AbstractIntlMessages | string;
|
|
8
|
+
};
|
|
9
|
+
export default AbstractIntlMessages;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import TimeZone from './TimeZone';
|
|
2
|
+
/**
|
|
3
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
|
|
4
|
+
*/
|
|
5
|
+
type DateTimeFormatOptions = Intl.DateTimeFormatOptions & {
|
|
6
|
+
/**
|
|
7
|
+
* Examples:
|
|
8
|
+
* - numeric: "2021"
|
|
9
|
+
* - 2-digit: "21"
|
|
10
|
+
*/
|
|
11
|
+
year?: 'numeric' | '2-digit';
|
|
12
|
+
/** Examples:
|
|
13
|
+
* - numeric: "3"
|
|
14
|
+
* - 2-digit: "03"
|
|
15
|
+
* - long: "March"
|
|
16
|
+
* - short: "Mar"
|
|
17
|
+
* - narrow: "M"
|
|
18
|
+
*/
|
|
19
|
+
month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow';
|
|
20
|
+
/** Examples:
|
|
21
|
+
* - numeric: "2"
|
|
22
|
+
* - 2-digit: "02"
|
|
23
|
+
*/
|
|
24
|
+
day?: 'numeric' | '2-digit';
|
|
25
|
+
/** Examples:
|
|
26
|
+
* - numeric: "2"
|
|
27
|
+
* - 2-digit: "02"
|
|
28
|
+
*/
|
|
29
|
+
hour?: 'numeric' | '2-digit';
|
|
30
|
+
/** Examples:
|
|
31
|
+
* - numeric: "2"
|
|
32
|
+
* - 2-digit: "02"
|
|
33
|
+
*/
|
|
34
|
+
minute?: 'numeric' | '2-digit';
|
|
35
|
+
/** Examples:
|
|
36
|
+
* - numeric: "2"
|
|
37
|
+
* - 2-digit: "02"
|
|
38
|
+
*/
|
|
39
|
+
second?: 'numeric' | '2-digit';
|
|
40
|
+
/** Examples:
|
|
41
|
+
* - long: "Thursday"
|
|
42
|
+
* - short: "Thu"
|
|
43
|
+
* - narrow: "T"
|
|
44
|
+
*/
|
|
45
|
+
weekday?: 'long' | 'short' | 'narrow';
|
|
46
|
+
/** Examples:
|
|
47
|
+
* - long: "Anno Domini"
|
|
48
|
+
* - short: "AD", narrow "A"
|
|
49
|
+
*/
|
|
50
|
+
era?: 'long' | 'short' | 'narrow';
|
|
51
|
+
/** If this is set to `true`, a 12-hour am/pm format is used. Otherwise a 24-hour time.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
hour12?: boolean;
|
|
55
|
+
/** Examples:
|
|
56
|
+
* - long: "Pacific Daylight Time"
|
|
57
|
+
* - short: "PDT"
|
|
58
|
+
*/
|
|
59
|
+
timeZoneName?: 'long' | 'short';
|
|
60
|
+
/**
|
|
61
|
+
* One of the [database names from the TZ database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List).
|
|
62
|
+
*/
|
|
63
|
+
timeZone?: TimeZone;
|
|
64
|
+
localeMatcher?: 'best fit' | 'lookup';
|
|
65
|
+
formatMatcher?: 'best fit' | 'basic';
|
|
66
|
+
dateStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
67
|
+
timeStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
68
|
+
calendar?: 'buddhist' | 'chinese' | 'coptic' | 'ethiopia' | 'ethiopic' | 'gregory' | 'hebrew' | 'indian' | 'islamic' | 'iso8601' | 'japanese' | 'persian' | 'roc';
|
|
69
|
+
dayPeriod?: 'narrow' | 'short' | 'long';
|
|
70
|
+
numberingSystem?: 'arab' | 'arabext' | 'bali' | 'beng' | 'deva' | 'fullwide' | 'gujr' | 'guru' | 'hanidec' | 'khmr' | 'knda' | 'laoo' | 'latn' | 'limb' | 'mlym' | 'mong' | 'mymr' | 'orya' | 'tamldec' | 'telu' | 'thai' | 'tibt';
|
|
71
|
+
hourCycle?: 'h11' | 'h12' | 'h23' | 'h24';
|
|
72
|
+
};
|
|
73
|
+
export default DateTimeFormatOptions;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import DateTimeFormatOptions from './DateTimeFormatOptions';
|
|
2
|
+
import NumberFormatOptions from './NumberFormatOptions';
|
|
3
|
+
type Formats = {
|
|
4
|
+
number: Record<string, NumberFormatOptions>;
|
|
5
|
+
dateTime: Record<string, DateTimeFormatOptions>;
|
|
6
|
+
list: Record<string, Intl.ListFormatOptions>;
|
|
7
|
+
};
|
|
8
|
+
export default Formats;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import Formats from './Formats';
|
|
2
|
+
import IntlError from './IntlError';
|
|
3
|
+
import TimeZone from './TimeZone';
|
|
4
|
+
import { AbstractIntlMessages, RichTranslationValues } from '.';
|
|
5
|
+
/**
|
|
6
|
+
* Should be used for entry points that configure the library.
|
|
7
|
+
*/
|
|
8
|
+
type IntlConfig<Messages = AbstractIntlMessages> = {
|
|
9
|
+
/** A valid Unicode locale tag (e.g. "en" or "en-GB"). */
|
|
10
|
+
locale: string;
|
|
11
|
+
/** Global formats can be provided to achieve consistent
|
|
12
|
+
* formatting across components. */
|
|
13
|
+
formats?: Partial<Formats>;
|
|
14
|
+
/** A time zone as defined in [the tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) which will be applied when formatting dates and times. If this is absent, the user time zone will be used. You can override this by supplying an explicit time zone to `formatDateTime`. */
|
|
15
|
+
timeZone?: TimeZone;
|
|
16
|
+
/** This callback will be invoked when an error is encountered during
|
|
17
|
+
* resolving a message or formatting it. This defaults to `console.error` to
|
|
18
|
+
* keep your app running. You can customize the handling by taking
|
|
19
|
+
* `error.code` into account. */
|
|
20
|
+
onError?(error: IntlError): void;
|
|
21
|
+
/** Will be called when a message couldn't be resolved or formatting it led to
|
|
22
|
+
* an error. This defaults to `${namespace}.${key}` You can use this to
|
|
23
|
+
* customize what will be rendered in this case. */
|
|
24
|
+
getMessageFallback?(info: {
|
|
25
|
+
error: IntlError;
|
|
26
|
+
key: string;
|
|
27
|
+
namespace?: string;
|
|
28
|
+
}): string;
|
|
29
|
+
/**
|
|
30
|
+
* Providing this value will have two effects:
|
|
31
|
+
* 1. It will be used as the default for the `now` argument of
|
|
32
|
+
* `useIntl().formatRelativeTime` if no explicit value is provided.
|
|
33
|
+
* 2. It will be returned as a static value from the `useNow` hook. Note
|
|
34
|
+
* however that when `updateInterval` is configured on the `useNow` hook,
|
|
35
|
+
* the global `now` value will only be used for the initial render, but
|
|
36
|
+
* afterwards the current date will be returned continuously.
|
|
37
|
+
*/
|
|
38
|
+
now?: Date;
|
|
39
|
+
/** All messages that will be available. */
|
|
40
|
+
messages?: Messages;
|
|
41
|
+
/** Global default values for translation values and rich text elements.
|
|
42
|
+
* Can be used for consistent usage or styling of rich text elements.
|
|
43
|
+
* Defaults will be overidden by locally provided values. */
|
|
44
|
+
defaultTranslationValues?: RichTranslationValues;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* A stricter set of the configuration that should be used internally
|
|
48
|
+
* once defaults are assigned to `IntlConfiguration`.
|
|
49
|
+
*/
|
|
50
|
+
export type InitializedIntlConfig<Messages = AbstractIntlMessages> = IntlConfig<Messages> & {
|
|
51
|
+
onError: NonNullable<IntlConfig<Messages>['onError']>;
|
|
52
|
+
getMessageFallback: NonNullable<IntlConfig<Messages>['getMessageFallback']>;
|
|
53
|
+
};
|
|
54
|
+
export default IntlConfig;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum IntlErrorCode {
|
|
2
|
+
MISSING_MESSAGE = "MISSING_MESSAGE",
|
|
3
|
+
MISSING_FORMAT = "MISSING_FORMAT",
|
|
4
|
+
INSUFFICIENT_PATH = "INSUFFICIENT_PATH",
|
|
5
|
+
INVALID_MESSAGE = "INVALID_MESSAGE",
|
|
6
|
+
INVALID_KEY = "INVALID_KEY",
|
|
7
|
+
FORMATTING_ERROR = "FORMATTING_ERROR"
|
|
8
|
+
}
|
|
9
|
+
export default class IntlError extends Error {
|
|
10
|
+
readonly code: IntlErrorCode;
|
|
11
|
+
readonly originalMessage: string | undefined;
|
|
12
|
+
constructor(code: IntlErrorCode, originalMessage?: string);
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { inheritsLoose as _inheritsLoose, wrapNativeSuper as _wrapNativeSuper } from '../_virtual/_rollupPluginBabelHelpers.esm.js';
|
|
2
|
+
|
|
3
|
+
var IntlErrorCode;
|
|
4
|
+
(function (IntlErrorCode) {
|
|
5
|
+
IntlErrorCode["MISSING_MESSAGE"] = "MISSING_MESSAGE";
|
|
6
|
+
IntlErrorCode["MISSING_FORMAT"] = "MISSING_FORMAT";
|
|
7
|
+
IntlErrorCode["INSUFFICIENT_PATH"] = "INSUFFICIENT_PATH";
|
|
8
|
+
IntlErrorCode["INVALID_MESSAGE"] = "INVALID_MESSAGE";
|
|
9
|
+
IntlErrorCode["INVALID_KEY"] = "INVALID_KEY";
|
|
10
|
+
IntlErrorCode["FORMATTING_ERROR"] = "FORMATTING_ERROR";
|
|
11
|
+
})(IntlErrorCode || (IntlErrorCode = {}));
|
|
12
|
+
var IntlError = /*#__PURE__*/function (_Error) {
|
|
13
|
+
_inheritsLoose(IntlError, _Error);
|
|
14
|
+
function IntlError(code, originalMessage) {
|
|
15
|
+
var _this;
|
|
16
|
+
var message = code;
|
|
17
|
+
if (originalMessage) {
|
|
18
|
+
message += ': ' + originalMessage;
|
|
19
|
+
}
|
|
20
|
+
_this = _Error.call(this, message) || this;
|
|
21
|
+
_this.code = void 0;
|
|
22
|
+
_this.originalMessage = void 0;
|
|
23
|
+
_this.code = code;
|
|
24
|
+
if (originalMessage) {
|
|
25
|
+
_this.originalMessage = originalMessage;
|
|
26
|
+
}
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
return IntlError;
|
|
30
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
31
|
+
|
|
32
|
+
export { IntlErrorCode, IntlError as default };
|
|
33
|
+
//# sourceMappingURL=IntlError.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlError.esm.js","sources":["../../src/core/IntlError.tsx"],"sourcesContent":["export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR'\n}\n\nexport default class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n"],"names":["IntlErrorCode","IntlError","_Error","_inheritsLoose","code","originalMessage","_this","message","call","_wrapNativeSuper","Error"],"mappings":";;IAAYA,cAOX;AAPD,CAAA,UAAYA,aAAa,EAAA;AACvBA,EAAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnCA,EAAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,gBAAiC,CAAA;AACjCA,EAAAA,aAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC,CAAA;AACvCA,EAAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnCA,EAAAA,aAAA,CAAA,aAAA,CAAA,GAAA,aAA2B,CAAA;AAC3BA,EAAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC,CAAA;AACvC,CAAC,EAPWA,aAAa,KAAbA,aAAa,GAOxB,EAAA,CAAA,CAAA,CAAA;AAEoBC,IAAAA,SAAU,0BAAAC,MAAA,EAAA;EAAAC,cAAA,CAAAF,SAAA,EAAAC,MAAA,CAAA,CAAA;AAI7B,EAAA,SAAAD,SAAYG,CAAAA,IAAmB,EAAEC,eAAwB,EAAA;AAAA,IAAA,IAAAC,KAAA,CAAA;IACvD,IAAIC,OAAO,GAAWH,IAAI,CAAA;AAC1B,IAAA,IAAIC,eAAe,EAAE;MACnBE,OAAO,IAAI,IAAI,GAAGF,eAAe,CAAA;AAClC,KAAA;AACDC,IAAAA,KAAA,GAAAJ,MAAA,CAAAM,IAAA,CAAA,IAAA,EAAMD,OAAO,CAAC,IAAA,IAAA,CAAA;AAACD,IAAAA,KAAA,CARDF,IAAI,GAAA,KAAA,CAAA,CAAA;AAAAE,IAAAA,KAAA,CACJD,eAAe,GAAA,KAAA,CAAA,CAAA;IAS7BC,KAAA,CAAKF,IAAI,GAAGA,IAAI,CAAA;AAChB,IAAA,IAAIC,eAAe,EAAE;MACnBC,KAAA,CAAKD,eAAe,GAAGA,eAAe,CAAA;AACvC,KAAA;AAAA,IAAA,OAAAC,KAAA,CAAA;AACH,GAAA;AAAC,EAAA,OAAAL,SAAA,CAAA;AAAA,CAAAQ,eAAAA,gBAAA,CAfoCC,KAAK,CAAA;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
type TimeZone = 'Africa/Abidjan' | 'Africa/Accra' | 'Africa/Addis_Ababa' | 'Africa/Algiers' | 'Africa/Asmara' | 'Africa/Bamako' | 'Africa/Bangui' | 'Africa/Banjul' | 'Africa/Bissau' | 'Africa/Blantyre' | 'Africa/Brazzaville' | 'Africa/Bujumbura' | 'Africa/Cairo' | 'Africa/Casablanca' | 'Africa/Ceuta' | 'Africa/Conakry' | 'Africa/Dakar' | 'Africa/Dar_es_Salaam' | 'Africa/Djibouti' | 'Africa/Douala' | 'Africa/El_Aaiun' | 'Africa/Freetown' | 'Africa/Gaborone' | 'Africa/Harare' | 'Africa/Johannesburg' | 'Africa/Juba' | 'Africa/Kampala' | 'Africa/Khartoum' | 'Africa/Kigali' | 'Africa/Kinshasa' | 'Africa/Lagos' | 'Africa/Libreville' | 'Africa/Lome' | 'Africa/Luanda' | 'Africa/Lubumbashi' | 'Africa/Lusaka' | 'Africa/Malabo' | 'Africa/Maputo' | 'Africa/Maseru' | 'Africa/Mbabane' | 'Africa/Mogadishu' | 'Africa/Monrovia' | 'Africa/Nairobi' | 'Africa/Ndjamena' | 'Africa/Niamey' | 'Africa/Nouakchott' | 'Africa/Ouagadougou' | 'Africa/Porto-Novo' | 'Africa/Sao_Tome' | 'Africa/Tripoli' | 'Africa/Tunis' | 'Africa/Windhoek' | 'America/Adak' | 'America/Anchorage' | 'America/Anguilla' | 'America/Antigua' | 'America/Araguaina' | 'America/Argentina/Buenos_Aires' | 'America/Argentina/Catamarca' | 'America/Argentina/Cordoba' | 'America/Argentina/Jujuy' | 'America/Argentina/La_Rioja' | 'America/Argentina/Mendoza' | 'America/Argentina/Rio_Gallegos' | 'America/Argentina/Salta' | 'America/Argentina/San_Juan' | 'America/Argentina/San_Luis' | 'America/Argentina/Tucuman' | 'America/Argentina/Ushuaia' | 'America/Aruba' | 'America/Asuncion' | 'America/Atikokan' | 'America/Bahia' | 'America/Bahia_Banderas' | 'America/Barbados' | 'America/Belem' | 'America/Belize' | 'America/Blanc-Sablon' | 'America/Boa_Vista' | 'America/Bogota' | 'America/Boise' | 'America/Cambridge_Bay' | 'America/Campo_Grande' | 'America/Cancun' | 'America/Caracas' | 'America/Cayenne' | 'America/Cayman' | 'America/Chicago' | 'America/Chihuahua' | 'America/Costa_Rica' | 'America/Creston' | 'America/Cuiaba' | 'America/Curacao' | 'America/Danmarkshavn' | 'America/Dawson' | 'America/Dawson_Creek' | 'America/Denver' | 'America/Detroit' | 'America/Dominica' | 'America/Edmonton' | 'America/Eirunepe' | 'America/El_Salvador' | 'America/Fort_Nelson' | 'America/Fortaleza' | 'America/Glace_Bay' | 'America/Godthab' | 'America/Goose_Bay' | 'America/Grand_Turk' | 'America/Grenada' | 'America/Guadeloupe' | 'America/Guatemala' | 'America/Guayaquil' | 'America/Guyana' | 'America/Halifax' | 'America/Havana' | 'America/Hermosillo' | 'America/Indiana/Indianapolis' | 'America/Indiana/Knox' | 'America/Indiana/Marengo' | 'America/Indiana/Petersburg' | 'America/Indiana/Tell_City' | 'America/Indiana/Vevay' | 'America/Indiana/Vincennes' | 'America/Indiana/Winamac' | 'America/Inuvik' | 'America/Iqaluit' | 'America/Jamaica' | 'America/Juneau' | 'America/Kentucky/Louisville' | 'America/Kentucky/Monticello' | 'America/Kralendijk' | 'America/La_Paz' | 'America/Lima' | 'America/Los_Angeles' | 'America/Lower_Princes' | 'America/Maceio' | 'America/Managua' | 'America/Manaus' | 'America/Marigot' | 'America/Martinique' | 'America/Matamoros' | 'America/Mazatlan' | 'America/Menominee' | 'America/Merida' | 'America/Metlakatla' | 'America/Mexico_City' | 'America/Miquelon' | 'America/Moncton' | 'America/Monterrey' | 'America/Montevideo' | 'America/Montserrat' | 'America/Nassau' | 'America/New_York' | 'America/Nipigon' | 'America/Nome' | 'America/Noronha' | 'America/North_Dakota/Beulah' | 'America/North_Dakota/Center' | 'America/North_Dakota/New_Salem' | 'America/Ojinaga' | 'America/Panama' | 'America/Pangnirtung' | 'America/Paramaribo' | 'America/Phoenix' | 'America/Port-au-Prince' | 'America/Port_of_Spain' | 'America/Porto_Velho' | 'America/Puerto_Rico' | 'America/Punta_Arenas' | 'America/Rainy_River' | 'America/Rankin_Inlet' | 'America/Recife' | 'America/Regina' | 'America/Resolute' | 'America/Rio_Branco' | 'America/Santarem' | 'America/Santiago' | 'America/Santo_Domingo' | 'America/Sao_Paulo' | 'America/Scoresbysund' | 'America/Sitka' | 'America/St_Barthelemy' | 'America/St_Johns' | 'America/St_Kitts' | 'America/St_Lucia' | 'America/St_Thomas' | 'America/St_Vincent' | 'America/Swift_Current' | 'America/Tegucigalpa' | 'America/Thule' | 'America/Thunder_Bay' | 'America/Tijuana' | 'America/Toronto' | 'America/Tortola' | 'America/Vancouver' | 'America/Whitehorse' | 'America/Winnipeg' | 'America/Yakutat' | 'America/Yellowknife' | 'Antarctica/Casey' | 'Antarctica/Davis' | 'Antarctica/DumontDUrville' | 'Antarctica/Macquarie' | 'Antarctica/Mawson' | 'Antarctica/Palmer' | 'Antarctica/Rothera' | 'Antarctica/Syowa' | 'Antarctica/Troll' | 'Antarctica/Vostok' | 'Arctic/Longyearbyen' | 'Asia/Almaty' | 'Asia/Amman' | 'Asia/Anadyr' | 'Asia/Aqtau' | 'Asia/Aqtobe' | 'Asia/Ashgabat' | 'Asia/Atyrau' | 'Asia/Baghdad' | 'Asia/Baku' | 'Asia/Bangkok' | 'Asia/Barnaul' | 'Asia/Beirut' | 'Asia/Bishkek' | 'Asia/Brunei' | 'Asia/Chita' | 'Asia/Choibalsan' | 'Asia/Colombo' | 'Asia/Damascus' | 'Asia/Dhaka' | 'Asia/Dili' | 'Asia/Dubai' | 'Asia/Dushanbe' | 'Asia/Famagusta' | 'Asia/Gaza' | 'Asia/Hebron' | 'Asia/Ho_Chi_Minh' | 'Asia/Hong_Kong' | 'Asia/Hovd' | 'Asia/Irkutsk' | 'Asia/Jakarta' | 'Asia/Jayapura' | 'Asia/Jerusalem' | 'Asia/Kabul' | 'Asia/Kamchatka' | 'Asia/Karachi' | 'Asia/Kathmandu' | 'Asia/Khandyga' | 'Asia/Kolkata' | 'Asia/Krasnoyarsk' | 'Asia/Kuala_Lumpur' | 'Asia/Kuching' | 'Asia/Macau' | 'Asia/Magadan' | 'Asia/Makassar' | 'Asia/Manila' | 'Asia/Nicosia' | 'Asia/Novokuznetsk' | 'Asia/Novosibirsk' | 'Asia/Omsk' | 'Asia/Oral' | 'Asia/Phnom_Penh' | 'Asia/Pontianak' | 'Asia/Pyongyang' | 'Asia/Qatar' | 'Asia/Qostanay' | 'Asia/Qyzylorda' | 'Asia/Riyadh' | 'Asia/Sakhalin' | 'Asia/Samarkand' | 'Asia/Seoul' | 'Asia/Shanghai' | 'Asia/Singapore' | 'Asia/Srednekolymsk' | 'Asia/Taipei' | 'Asia/Tashkent' | 'Asia/Tbilisi' | 'Asia/Tehran' | 'Asia/Thimphu' | 'Asia/Tokyo' | 'Asia/Tomsk' | 'Asia/Ulaanbaatar' | 'Asia/Urumqi' | 'Asia/Ust-Nera' | 'Asia/Vladivostok' | 'Asia/Yakutsk' | 'Asia/Yangon' | 'Asia/Yekaterinburg' | 'Asia/Yerevan' | 'Atlantic/Azores' | 'Atlantic/Bermuda' | 'Atlantic/Canary' | 'Atlantic/Cape_Verde' | 'Atlantic/Faroe' | 'Atlantic/Madeira' | 'Atlantic/Reykjavik' | 'Atlantic/South_Georgia' | 'Atlantic/St_Helena' | 'Atlantic/Stanley' | 'Australia/Adelaide' | 'Australia/Brisbane' | 'Australia/Broken_Hill' | 'Australia/Currie' | 'Australia/Darwin' | 'Australia/Eucla' | 'Australia/Hobart' | 'Australia/Lindeman' | 'Australia/Lord_Howe' | 'Australia/Melbourne' | 'Australia/Perth' | 'Australia/Sydney' | 'Europe/Amsterdam' | 'Europe/Andorra' | 'Europe/Astrakhan' | 'Europe/Athens' | 'Europe/Belgrade' | 'Europe/Berlin' | 'Europe/Bratislava' | 'Europe/Brussels' | 'Europe/Bucharest' | 'Europe/Budapest' | 'Europe/Busingen' | 'Europe/Chisinau' | 'Europe/Copenhagen' | 'Europe/Dublin' | 'Europe/Gibraltar' | 'Europe/Guernsey' | 'Europe/Helsinki' | 'Europe/Isle_of_Man' | 'Europe/Istanbul' | 'Europe/Jersey' | 'Europe/Kaliningrad' | 'Europe/Kiev' | 'Europe/Kirov' | 'Europe/Lisbon' | 'Europe/Ljubljana' | 'Europe/London' | 'Europe/Luxembourg' | 'Europe/Madrid' | 'Europe/Malta' | 'Europe/Mariehamn' | 'Europe/Minsk' | 'Europe/Monaco' | 'Europe/Moscow' | 'Europe/Oslo' | 'Europe/Paris' | 'Europe/Podgorica' | 'Europe/Prague' | 'Europe/Riga' | 'Europe/Rome' | 'Europe/Samara' | 'Europe/San_Marino' | 'Europe/Sarajevo' | 'Europe/Saratov' | 'Europe/Simferopol' | 'Europe/Skopje' | 'Europe/Sofia' | 'Europe/Stockholm' | 'Europe/Tallinn' | 'Europe/Tirane' | 'Europe/Ulyanovsk' | 'Europe/Uzhgorod' | 'Europe/Vaduz' | 'Europe/Vatican' | 'Europe/Vienna' | 'Europe/Vilnius' | 'Europe/Volgograd' | 'Europe/Warsaw' | 'Europe/Zagreb' | 'Europe/Zaporozhye' | 'Europe/Zurich' | 'Indian/Antananarivo' | 'Indian/Chagos' | 'Indian/Christmas' | 'Indian/Cocos' | 'Indian/Comoro' | 'Indian/Kerguelen' | 'Indian/Mahe' | 'Indian/Maldives' | 'Indian/Mauritius' | 'Indian/Mayotte' | 'Indian/Reunion' | 'Pacific/Apia' | 'Pacific/Auckland' | 'Pacific/Bougainville' | 'Pacific/Chatham' | 'Pacific/Chuuk' | 'Pacific/Easter' | 'Pacific/Efate' | 'Pacific/Enderbury' | 'Pacific/Fakaofo' | 'Pacific/Fiji' | 'Pacific/Funafuti' | 'Pacific/Galapagos' | 'Pacific/Gambier' | 'Pacific/Guadalcanal' | 'Pacific/Guam' | 'Pacific/Honolulu' | 'Pacific/Kiritimati' | 'Pacific/Kosrae' | 'Pacific/Kwajalein' | 'Pacific/Majuro' | 'Pacific/Marquesas' | 'Pacific/Nauru' | 'Pacific/Niue' | 'Pacific/Norfolk' | 'Pacific/Noumea' | 'Pacific/Pago_Pago' | 'Pacific/Palau' | 'Pacific/Pitcairn' | 'Pacific/Pohnpei' | 'Pacific/Port_Moresby' | 'Pacific/Rarotonga' | 'Pacific/Tahiti' | 'Pacific/Tarawa' | 'Pacific/Tongatapu' | 'Pacific/Wake' | 'Pacific/Wallis' | 'UTC' | 'W-SU' | 'WET' | 'Zulu' | (string & {});
|
|
2
|
+
export default TimeZone;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type TranslationValue = string | number | boolean | Date | null | undefined;
|
|
3
|
+
type TranslationValues = Record<string, TranslationValue>;
|
|
4
|
+
export type RichTranslationValues = Record<string, TranslationValue | ((chunks: ReactNode) => ReactNode)>;
|
|
5
|
+
export type RichTranslationValuesPlain = Record<string, TranslationValue | ((chunks: string) => string)>;
|
|
6
|
+
export default TranslationValues;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Formats as IntlFormats } from 'intl-messageformat';
|
|
2
|
+
import Formats from './Formats';
|
|
3
|
+
import TimeZone from './TimeZone';
|
|
4
|
+
/**
|
|
5
|
+
* `intl-messageformat` uses separate keys for `date` and `time`, but there's
|
|
6
|
+
* only one native API: `Intl.DateTimeFormat`. Additionally you might want to
|
|
7
|
+
* include both a time and a date in a value, therefore the separation doesn't
|
|
8
|
+
* seem so useful. We offer a single `dateTime` namespace instead, but we have
|
|
9
|
+
* to convert the format before `intl-messageformat` can be used.
|
|
10
|
+
*/
|
|
11
|
+
export default function convertFormatsToIntlMessageFormat(formats: Partial<Formats>, timeZone?: TimeZone): Partial<IntlFormats>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.esm.js';
|
|
2
|
+
|
|
3
|
+
function setTimeZoneInFormats(formats, timeZone) {
|
|
4
|
+
if (!formats) return formats;
|
|
5
|
+
// The only way to set a time zone with `intl-messageformat` is to merge it into the formats
|
|
6
|
+
// https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15
|
|
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
|
+
function convertFormatsToIntlMessageFormat(formats, timeZone) {
|
|
22
|
+
var formatsWithTimeZone = timeZone ? _extends({}, formats, {
|
|
23
|
+
dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)
|
|
24
|
+
}) : formats;
|
|
25
|
+
return _extends({}, formatsWithTimeZone, {
|
|
26
|
+
date: formatsWithTimeZone == null ? void 0 : formatsWithTimeZone.dateTime,
|
|
27
|
+
time: formatsWithTimeZone == null ? void 0 : formatsWithTimeZone.dateTime
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { convertFormatsToIntlMessageFormat as default };
|
|
32
|
+
//# sourceMappingURL=convertFormatsToIntlMessageFormat.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertFormatsToIntlMessageFormat.esm.js","sources":["../../src/core/convertFormatsToIntlMessageFormat.tsx"],"sourcesContent":["import {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport TimeZone from './TimeZone';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: TimeZone\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?: TimeZone\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","_extends","convertFormatsToIntlMessageFormat","formatsWithTimeZone","dateTime","date","time"],"mappings":";;AAKA,SAASA,oBAAoBA,CAC3BC,OAA0D,EAC1DC,QAAkB,EAAA;AAElB,EAAA,IAAI,CAACD,OAAO,EAAE,OAAOA,OAAO,CAAA;AAE5B;AACA;AACA,EAAA,OAAOE,MAAM,CAACC,IAAI,CAACH,OAAO,CAAC,CAACI,MAAM,CAChC,UAACC,GAA0C,EAAEC,GAAG,EAAI;AAClDD,IAAAA,GAAG,CAACC,GAAG,CAAC,GAAAC,QAAA,CAAA;AACNN,MAAAA,QAAQ,EAARA,QAAAA;AAAQ,KAAA,EACLD,OAAO,CAACM,GAAG,CAAC,CAChB,CAAA;AACD,IAAA,OAAOD,GAAG,CAAA;GACX,EACD,EAAE,CACH,CAAA;AACH,CAAA;AAEA;;;;;;AAMG;AACW,SAAUG,iCAAiCA,CACvDR,OAAyB,EACzBC,QAAmB,EAAA;AAEnB,EAAA,IAAMQ,mBAAmB,GAAGR,QAAQ,GAAAM,QAAA,KAC5BP,OAAO,EAAA;AAAEU,IAAAA,QAAQ,EAAEX,oBAAoB,CAACC,OAAO,CAACU,QAAQ,EAAET,QAAQ,CAAA;AAAC,GAAA,CAAA,GACvED,OAAO,CAAA;EAEX,OAAAO,QAAA,KACKE,mBAAmB,EAAA;AACtBE,IAAAA,IAAI,EAAEF,mBAAmB,IAAnBA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,mBAAmB,CAAEC,QAAQ;AACnCE,IAAAA,IAAI,EAAEH,mBAAmB,IAAnBA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,mBAAmB,CAAEC,QAAAA;AAAQ,GAAA,CAAA,CAAA;AAEvC;;;;"}
|