svelte-intlayer 8.6.3 → 8.6.5
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/dist/client/intlayerStore.js +2 -3
- package/dist/client/setupIntlayer.svelte.js +4 -2
- package/dist/client/useLocale.js +2 -2
- package/dist/client/useRewriteURL.js +2 -2
- package/dist/html/HTMLWithSelector.svelte +14 -0
- package/dist/html/HTMLWithSelector.svelte.d.ts +24 -0
- package/dist/plugins.js +11 -9
- package/package.json +6 -6
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { internationalization } from '@intlayer/config/built';
|
|
2
2
|
import { derived, writable } from 'svelte/store';
|
|
3
|
-
const defaultLocale =
|
|
4
|
-
?.defaultLocale;
|
|
3
|
+
const defaultLocale = internationalization?.defaultLocale;
|
|
5
4
|
// Create the main intlayer store
|
|
6
5
|
const createIntlayerStore = () => {
|
|
7
6
|
const { subscribe, set, update } = writable({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { internationalization } from '@intlayer/config/built';
|
|
2
|
+
import { setIntlayerIdentifier } from '@intlayer/config/client';
|
|
2
3
|
import { useEditor } from '../editor/useEditor';
|
|
3
4
|
import { setIntlayerContext } from './intlayerContext';
|
|
4
5
|
import { intlayerStore } from './intlayerStore';
|
|
@@ -20,6 +21,7 @@ import { intlayerStore } from './intlayerStore';
|
|
|
20
21
|
* ```
|
|
21
22
|
*/
|
|
22
23
|
export const setupIntlayer = (initialLocale) => {
|
|
24
|
+
setIntlayerIdentifier();
|
|
23
25
|
useEditor();
|
|
24
26
|
// Create Reactive State (Svelte 5)
|
|
25
27
|
// We make the locale a "rune" so updates propagate
|
|
@@ -31,7 +33,7 @@ export const setupIntlayer = (initialLocale) => {
|
|
|
31
33
|
// Define the Context Object
|
|
32
34
|
const contextValue = {
|
|
33
35
|
get locale() {
|
|
34
|
-
return locale ??
|
|
36
|
+
return locale ?? internationalization.defaultLocale;
|
|
35
37
|
},
|
|
36
38
|
setLocale: (newLocale) => {
|
|
37
39
|
locale = newLocale;
|
package/dist/client/useLocale.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { internationalization } from '@intlayer/config/built';
|
|
2
2
|
import { derived } from 'svelte/store';
|
|
3
3
|
import { getIntlayerContext } from './intlayerContext';
|
|
4
4
|
import { intlayerStore } from './intlayerStore';
|
|
@@ -25,7 +25,7 @@ import { setLocaleInStorage } from './useLocaleStorage';
|
|
|
25
25
|
*/
|
|
26
26
|
export const useLocale = ({ isCookieEnabled, onLocaleChange, } = {}) => {
|
|
27
27
|
const context = getIntlayerContext();
|
|
28
|
-
const { defaultLocale, locales: availableLocales } =
|
|
28
|
+
const { defaultLocale, locales: availableLocales } = internationalization ?? {};
|
|
29
29
|
if (context) {
|
|
30
30
|
// Use context if available
|
|
31
31
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { routing } from '@intlayer/config/built';
|
|
2
2
|
import { getRewritePath } from '@intlayer/core/localization';
|
|
3
3
|
import { useLocale } from './useLocale';
|
|
4
4
|
/**
|
|
@@ -7,7 +7,7 @@ import { useLocale } from './useLocale';
|
|
|
7
7
|
*/
|
|
8
8
|
export const useRewriteURL = () => {
|
|
9
9
|
const { locale } = useLocale();
|
|
10
|
-
const rewrite =
|
|
10
|
+
const rewrite = routing?.rewrite;
|
|
11
11
|
if (typeof window !== 'undefined') {
|
|
12
12
|
// We observe locale changes
|
|
13
13
|
locale.subscribe(($locale) => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { KeyPath } from '@intlayer/types/keyPath';
|
|
3
|
+
import ContentSelector from '../editor/ContentSelector.svelte';
|
|
4
|
+
import HTMLRenderer from './HTMLRenderer.svelte';
|
|
5
|
+
|
|
6
|
+
export let dictionaryKey: string;
|
|
7
|
+
export let keyPath: KeyPath[];
|
|
8
|
+
export let value: string;
|
|
9
|
+
export let components: any = {};
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<ContentSelector {dictionaryKey} {keyPath}>
|
|
13
|
+
<HTMLRenderer {value} {components} />
|
|
14
|
+
</ContentSelector>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { KeyPath } from '@intlayer/types/keyPath';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const HTMLWithSelector: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
dictionaryKey: string;
|
|
17
|
+
keyPath: KeyPath[];
|
|
18
|
+
value: string;
|
|
19
|
+
components?: any;
|
|
20
|
+
}, {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
}, {}, {}, string>;
|
|
23
|
+
type HTMLWithSelector = InstanceType<typeof HTMLWithSelector>;
|
|
24
|
+
export default HTMLWithSelector;
|
package/dist/plugins.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { editor, internationalization } from '@intlayer/config/built';
|
|
2
2
|
import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, nestedPlugin, translationPlugin, } from '@intlayer/core/interpreter';
|
|
3
3
|
import * as NodeTypes from '@intlayer/types/nodeType';
|
|
4
4
|
import { default as ContentSelector } from './editor/ContentSelector.svelte';
|
|
@@ -39,11 +39,13 @@ let _MarkdownMetadataWithSelector = null;
|
|
|
39
39
|
let _MarkdownRenderer = null;
|
|
40
40
|
let _MarkdownWithSelector = null;
|
|
41
41
|
let _svelteHtmlRuntime = null;
|
|
42
|
+
let _HTMLWithSelector = null;
|
|
42
43
|
void Promise.all([
|
|
43
44
|
import('./markdown/MarkdownMetadataRenderer.svelte').then((m) => (_MarkdownMetadataRenderer = m.default)),
|
|
44
45
|
import('./markdown/MarkdownMetadataWithSelector.svelte').then((m) => (_MarkdownMetadataWithSelector = m.default)),
|
|
45
46
|
import('./markdown/MarkdownRenderer.svelte').then((m) => (_MarkdownRenderer = m.default)),
|
|
46
47
|
import('./markdown/MarkdownWithSelector.svelte').then((m) => (_MarkdownWithSelector = m.default)),
|
|
48
|
+
import('./html/HTMLWithSelector.svelte').then((m) => (_HTMLWithSelector = m.default)),
|
|
47
49
|
import('./markdown/runtime').then((m) => (_svelteHtmlRuntime = m.svelteHtmlRuntime)),
|
|
48
50
|
]);
|
|
49
51
|
/**
|
|
@@ -59,9 +61,7 @@ export const intlayerNodePlugins = TREE_SHAKE_INTLAYER_NODE
|
|
|
59
61
|
typeof node === 'number',
|
|
60
62
|
transform: (node, { children, ...rest }) => renderIntlayerNode({
|
|
61
63
|
value: children ?? node,
|
|
62
|
-
component: !TREE_SHAKE_EDITOR &&
|
|
63
|
-
? ContentSelector
|
|
64
|
-
: undefined,
|
|
64
|
+
component: !TREE_SHAKE_EDITOR && editor.enabled ? ContentSelector : undefined,
|
|
65
65
|
props: rest,
|
|
66
66
|
}),
|
|
67
67
|
};
|
|
@@ -194,7 +194,7 @@ export const markdownStringPlugin = TREE_SHAKE_MARKDOWN
|
|
|
194
194
|
!metadataNode,
|
|
195
195
|
transform: (metadataNode, props) => renderIntlayerNode({
|
|
196
196
|
value: metadataNode,
|
|
197
|
-
component: !TREE_SHAKE_EDITOR &&
|
|
197
|
+
component: !TREE_SHAKE_EDITOR && editor.enabled
|
|
198
198
|
? (_MarkdownMetadataWithSelector ?? _MarkdownMetadataRenderer)
|
|
199
199
|
: _MarkdownMetadataRenderer,
|
|
200
200
|
props: {
|
|
@@ -213,7 +213,7 @@ export const markdownStringPlugin = TREE_SHAKE_MARKDOWN
|
|
|
213
213
|
const render = (components) => {
|
|
214
214
|
const nodeResult = renderIntlayerNode({
|
|
215
215
|
value: node,
|
|
216
|
-
component: !TREE_SHAKE_EDITOR &&
|
|
216
|
+
component: !TREE_SHAKE_EDITOR && editor.enabled
|
|
217
217
|
? (_MarkdownWithSelector ?? _MarkdownRenderer)
|
|
218
218
|
: _MarkdownRenderer,
|
|
219
219
|
props: {
|
|
@@ -280,7 +280,9 @@ export const htmlPlugin = TREE_SHAKE_HTML
|
|
|
280
280
|
const render = (userComponents = {}) => renderIntlayerNode({
|
|
281
281
|
...props,
|
|
282
282
|
value: htmlString,
|
|
283
|
-
component:
|
|
283
|
+
component: !TREE_SHAKE_EDITOR && editor.enabled
|
|
284
|
+
? (_HTMLWithSelector ?? HTMLRenderer)
|
|
285
|
+
: HTMLRenderer,
|
|
284
286
|
props: {
|
|
285
287
|
...props,
|
|
286
288
|
value: htmlString,
|
|
@@ -298,10 +300,10 @@ export const htmlPlugin = TREE_SHAKE_HTML
|
|
|
298
300
|
* This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
|
|
299
301
|
*/
|
|
300
302
|
export const getPlugins = (locale, fallback = true) => [
|
|
301
|
-
translationPlugin(locale ??
|
|
303
|
+
translationPlugin(locale ?? internationalization.defaultLocale, fallback ? internationalization.defaultLocale : undefined),
|
|
302
304
|
enumerationPlugin,
|
|
303
305
|
conditionPlugin,
|
|
304
|
-
nestedPlugin(locale ??
|
|
306
|
+
nestedPlugin(locale ?? internationalization.defaultLocale),
|
|
305
307
|
filePlugin,
|
|
306
308
|
genderPlugin,
|
|
307
309
|
intlayerNodePlugins,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-intlayer",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.5",
|
|
4
4
|
"description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intlayer",
|
|
@@ -82,11 +82,11 @@
|
|
|
82
82
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@intlayer/api": "8.6.
|
|
86
|
-
"@intlayer/config": "8.6.
|
|
87
|
-
"@intlayer/core": "8.6.
|
|
88
|
-
"@intlayer/editor": "8.6.
|
|
89
|
-
"@intlayer/types": "8.6.
|
|
85
|
+
"@intlayer/api": "8.6.5",
|
|
86
|
+
"@intlayer/config": "8.6.5",
|
|
87
|
+
"@intlayer/core": "8.6.5",
|
|
88
|
+
"@intlayer/editor": "8.6.5",
|
|
89
|
+
"@intlayer/types": "8.6.5"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@sveltejs/adapter-auto": "7.0.1",
|