@formatjs/svelte-intl 1.0.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.md +9 -0
- package/README.md +3 -0
- package/context-key.d.ts +1 -0
- package/context-key.js +1 -0
- package/index.d.ts +12 -0
- package/index.js +10 -0
- package/package.json +28 -0
- package/provider.d.ts +3 -0
- package/provider.js +13 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 FormatJS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
package/context-key.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const intlKey: unique symbol;
|
package/context-key.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const intlKey = Symbol();
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type IntlFormatters as CoreIntlFormatters, type MessageDescriptor } from "@formatjs/intl";
|
|
2
|
+
export * from "./provider.js";
|
|
3
|
+
export { intlKey } from "./context-key.js";
|
|
4
|
+
export { type IntlShape, type IntlConfig, type ResolvedIntlConfig, createIntl, createIntlCache, type MessageDescriptor, type IntlCache, type Formatters, type FormatDisplayNameOptions, type FormatListOptions, type FormatPluralOptions, type FormatRelativeTimeOptions, type FormatNumberOptions, type FormatDateOptions, type CustomFormatConfig, type CustomFormats, UnsupportedFormatterError, InvalidConfigError, MissingDataError, MessageFormatError, MissingTranslationError, IntlErrorCode, IntlError } from "@formatjs/intl";
|
|
5
|
+
export type IntlFormatters = CoreIntlFormatters<string>;
|
|
6
|
+
export declare function defineMessages<
|
|
7
|
+
K extends keyof any,
|
|
8
|
+
T = MessageDescriptor,
|
|
9
|
+
U extends Record<K, T> = Record<K, T>
|
|
10
|
+
>(msgs: U): U;
|
|
11
|
+
export declare function defineMessage<T>(msg: T): T;
|
|
12
|
+
export type { MessageFormatElement } from "@formatjs/icu-messageformat-parser";
|
package/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "@formatjs/intl";
|
|
2
|
+
export * from "./provider.js";
|
|
3
|
+
export { intlKey } from "./context-key.js";
|
|
4
|
+
export { createIntl, createIntlCache, UnsupportedFormatterError, InvalidConfigError, MissingDataError, MessageFormatError, MissingTranslationError, IntlErrorCode, IntlError } from "@formatjs/intl";
|
|
5
|
+
export function defineMessages(msgs) {
|
|
6
|
+
return msgs;
|
|
7
|
+
}
|
|
8
|
+
export function defineMessage(msg) {
|
|
9
|
+
return msg;
|
|
10
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@formatjs/svelte-intl",
|
|
3
|
+
"description": "formatjs intl binding for svelte",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "Long Ho <holevietlong@gmail.com>",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@formatjs/icu-messageformat-parser": "workspace:*",
|
|
14
|
+
"@formatjs/intl": "workspace:*"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"svelte": "^5.0.0"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://formatjs.github.io/docs/svelte-intl",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"formatjs",
|
|
22
|
+
"i18n",
|
|
23
|
+
"internationalization",
|
|
24
|
+
"intl",
|
|
25
|
+
"svelte"
|
|
26
|
+
],
|
|
27
|
+
"repository": "formatjs/formatjs.git"
|
|
28
|
+
}
|
package/provider.d.ts
ADDED
package/provider.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "@formatjs/intl";
|
|
2
|
+
import { getContext, setContext } from "svelte";
|
|
3
|
+
import { intlKey } from "./context-key.js";
|
|
4
|
+
export function provideIntl(intl) {
|
|
5
|
+
setContext(intlKey, intl);
|
|
6
|
+
}
|
|
7
|
+
export function useIntl() {
|
|
8
|
+
const intl = getContext(intlKey);
|
|
9
|
+
if (!intl) {
|
|
10
|
+
throw new Error(`An intl object was not provided. Use provideIntl in an ancestor component.`);
|
|
11
|
+
}
|
|
12
|
+
return intl;
|
|
13
|
+
}
|