@tolgee/svelte 5.33.3-prerelease.f3241859.0 → 6.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/README.md +20 -20
- package/dist/GlobalContextPlugin.js +1 -1
- package/dist/T.svelte +1 -1
- package/dist/TolgeeProvider.svelte +5 -7
- package/dist/__integration/components/Namespaces.svelte +1 -1
- package/dist/__integration/components/TestGetTolgee.svelte +0 -1
- package/dist/__integration/components/TestGetTolgee.svelte.d.ts +1 -1
- package/dist/__integration/components/TestTranslateComponent.svelte +1 -1
- package/dist/__testUtil/TolgeeProviderFallback.svelte +1 -1
- package/dist/__testUtil/TolgeeProviderSlotTest.svelte +2 -4
- package/dist/__testUtil/TolgeeProviderSlotTest.svelte.d.ts +1 -1
- package/dist/getTolgeeContext.js +1 -2
- package/dist/getTranslate.js +2 -2
- package/package.json +86 -86
package/README.md
CHANGED
|
@@ -70,21 +70,21 @@ Then use the library in your app:
|
|
|
70
70
|
|
|
71
71
|
```svelte
|
|
72
72
|
<script lang="ts">
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
import { TolgeeProvider, Tolgee, SveltePlugin, FormatSimple } from '@tolgee/svelte';
|
|
74
|
+
|
|
75
|
+
const tolgee = Tolgee()
|
|
76
|
+
.use(SveltePlugin())
|
|
77
|
+
.use(FormatSimple())
|
|
78
|
+
.init({
|
|
79
|
+
apiUrl: import.meta.env.VITE_TOLGEE_API_URL,
|
|
80
|
+
apiKey: import.meta.env.VITE_TOLGEE_API_KEY,
|
|
81
|
+
language: 'en'
|
|
82
|
+
});
|
|
83
83
|
</script>
|
|
84
84
|
|
|
85
85
|
<TolgeeProvider {tolgee}>
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
<div slot="fallback">Loading...</div>
|
|
87
|
+
<slot />
|
|
88
88
|
</TolgeeProvider>
|
|
89
89
|
```
|
|
90
90
|
|
|
@@ -96,7 +96,7 @@ To translate texts using Tolgee Svelte integration, you can use `T` component or
|
|
|
96
96
|
|
|
97
97
|
```svelte
|
|
98
98
|
<script>
|
|
99
|
-
|
|
99
|
+
import { T } from '@tolgee/svelte';
|
|
100
100
|
</script>
|
|
101
101
|
|
|
102
102
|
<T keyName="key" defaultValue="This is default" />
|
|
@@ -108,9 +108,9 @@ The `getTranslate` function returns a store containing the function, which trans
|
|
|
108
108
|
|
|
109
109
|
```svelte
|
|
110
110
|
<script>
|
|
111
|
-
|
|
111
|
+
import { getTranslate } from '@tolgee/svelte';
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
const { t } = getTranslate();
|
|
114
114
|
</script>
|
|
115
115
|
|
|
116
116
|
{$t('this_is_a_key', { key: 'value', key2: 'value2' })}
|
|
@@ -122,13 +122,13 @@ To change the current language, use `getTolgee` method. For example, you can bin
|
|
|
122
122
|
|
|
123
123
|
```svelte
|
|
124
124
|
<script lang="ts">
|
|
125
|
-
|
|
125
|
+
import { getTolgee } from '@tolgee/svelte';
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
const tolgee = getTolgee(['language']);
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
function handleLanguageChange(e) {
|
|
130
|
+
$tolgee.changeLanguage(e.currentTarget.value);
|
|
131
|
+
}
|
|
132
132
|
</script>
|
|
133
133
|
|
|
134
134
|
<select value={$tolgee.getLanguage()} on:change={handleLanguageChange}> ... </select>
|
package/dist/T.svelte
CHANGED
|
@@ -13,12 +13,10 @@ onMount(() => {
|
|
|
13
13
|
onDestroy(tolgee.stop);
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
|
-
{#if !isLoading
|
|
16
|
+
{#if !isLoading}
|
|
17
17
|
<slot />
|
|
18
|
-
{:else }
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<slot name="fallback" />
|
|
23
|
-
{/if}
|
|
18
|
+
{:else if fallback}
|
|
19
|
+
{fallback}
|
|
20
|
+
{:else}
|
|
21
|
+
<slot name="fallback" />
|
|
24
22
|
{/if}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="svelte" />
|
|
2
|
-
import type { TolgeeEvent } from
|
|
2
|
+
import type { TolgeeEvent } from '@tolgee/web';
|
|
3
3
|
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> {
|
|
4
4
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
5
|
$$bindings?: Bindings;
|
|
@@ -3,7 +3,7 @@ import TestTranslateComponentInside from "./TestTranslateComponentInside.svelte"
|
|
|
3
3
|
export let tolgee;
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
|
-
<TolgeeProvider
|
|
6
|
+
<TolgeeProvider {tolgee}>
|
|
7
7
|
<TestTranslateComponentInside />
|
|
8
8
|
<span slot="fallback">Loading...</span>
|
|
9
9
|
</TolgeeProvider>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="svelte" />
|
|
2
|
-
import type { TolgeeInstance } from
|
|
2
|
+
import type { TolgeeInstance } from '@tolgee/web';
|
|
3
3
|
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> {
|
|
4
4
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
5
|
$$bindings?: Bindings;
|
package/dist/getTolgeeContext.js
CHANGED
|
@@ -5,8 +5,7 @@ import { getGlobalContext } from './GlobalContextPlugin';
|
|
|
5
5
|
* @throws Error when context is not defined.
|
|
6
6
|
*/
|
|
7
7
|
export const getTolgeeContext = () => {
|
|
8
|
-
const context = (getContext('tolgeeContext') ||
|
|
9
|
-
getGlobalContext());
|
|
8
|
+
const context = (getContext('tolgeeContext') || getGlobalContext());
|
|
10
9
|
if (context === undefined) {
|
|
11
10
|
throw Error('Tolgee context is undefined. Trying to use getTranslate method or T component outside TolgeeProvider?');
|
|
12
11
|
}
|
package/dist/getTranslate.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { derived } from 'svelte/store';
|
|
2
|
-
import { getTranslateProps
|
|
2
|
+
import { getTranslateProps } from '@tolgee/web';
|
|
3
3
|
import getTranslateInternal from './getTranslateInternal';
|
|
4
4
|
const getTranslate = (ns) => {
|
|
5
5
|
const { t: tInternal, isLoading } = getTranslateInternal(ns);
|
|
6
6
|
const t = derived(tInternal, (value) => (...params) => {
|
|
7
|
-
|
|
7
|
+
// @ts-expect-error passing params as they were
|
|
8
8
|
const props = getTranslateProps(...params);
|
|
9
9
|
return value(props);
|
|
10
10
|
});
|
package/package.json
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
2
|
+
"name": "@tolgee/svelte",
|
|
3
|
+
"version": "6.0.0",
|
|
4
|
+
"description": "Svelte implementation for Tolgee localization framework",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/tolgee/tolgee-js.git"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"svelte": "./dist/index.js",
|
|
13
|
+
"homepage": "https://tolgee.io",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"localization",
|
|
16
|
+
"internationalization",
|
|
17
|
+
"l10n",
|
|
18
|
+
"i18n",
|
|
19
|
+
"translation",
|
|
20
|
+
"languages"
|
|
21
|
+
],
|
|
22
|
+
"author": "JanCizmar",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"declaration": true,
|
|
25
|
+
"type": "module",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"dev": "vite build --watch",
|
|
28
|
+
"develop": "vite build --watch",
|
|
29
|
+
"build": "vite build && npm run package",
|
|
30
|
+
"package": "svelte-kit sync && svelte-package && publint",
|
|
31
|
+
"preview": "vite preview",
|
|
32
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
33
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"lint": "prettier --check . && eslint .",
|
|
36
|
+
"format": "prettier --write .",
|
|
37
|
+
"clean": "rm -rf dist .svelte-kit"
|
|
38
|
+
},
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"svelte": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist",
|
|
48
|
+
"!dist/**/*.test.*",
|
|
49
|
+
"!dist/**/*.spec.*"
|
|
50
|
+
],
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"svelte": "^4.0.0 || ^5.0.0"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@tolgee/web": "6.0.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@sveltejs/adapter-auto": "^3.0.0",
|
|
59
|
+
"@sveltejs/kit": "^2.0.0",
|
|
60
|
+
"@sveltejs/package": "^2.0.0",
|
|
61
|
+
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
|
62
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
63
|
+
"@testing-library/svelte": "^5.2.3",
|
|
64
|
+
"@tolgee/format-icu": "6.0.0",
|
|
65
|
+
"@tolgee/testing": "6.0.0",
|
|
66
|
+
"@types/eslint": "^9.6.0",
|
|
67
|
+
"eslint": "^9.0.0",
|
|
68
|
+
"eslint-config-prettier": "^9.1.0",
|
|
69
|
+
"eslint-plugin-svelte": "^2.36.0",
|
|
70
|
+
"globals": "^15.0.0",
|
|
71
|
+
"jest": "^29.7.0",
|
|
72
|
+
"prettier": "^3.1.1",
|
|
73
|
+
"prettier-plugin-svelte": "^3.1.2",
|
|
74
|
+
"publint": "^0.2.0",
|
|
75
|
+
"svelte": "^5.1.9",
|
|
76
|
+
"svelte-check": "^4.0.0",
|
|
77
|
+
"typescript": "^5.0.0",
|
|
78
|
+
"typescript-eslint": "^8.0.0",
|
|
79
|
+
"vite": "^5.0.11",
|
|
80
|
+
"vitest": "^2.0.0",
|
|
81
|
+
"vitest-fetch-mock": "^0.3.0"
|
|
82
|
+
},
|
|
83
|
+
"publishConfig": {
|
|
84
|
+
"access": "public"
|
|
85
|
+
},
|
|
86
|
+
"sideEffects": false,
|
|
87
|
+
"gitHead": "98413308b043399b530e400f44141ceb1ca2dbe9"
|
|
88
88
|
}
|