@tolgee/svelte 5.29.2 → 5.29.3
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 +41 -55
- package/{GlobalContextPlugin.d.ts → dist/GlobalContextPlugin.d.ts} +1 -1
- package/dist/T.svelte +21 -0
- package/dist/T.svelte.d.ts +24 -0
- package/{TolgeeProvider.svelte → dist/TolgeeProvider.svelte} +7 -7
- package/{TolgeeProvider.svelte.d.ts → dist/TolgeeProvider.svelte.d.ts} +5 -3
- package/dist/__integration/components/Namespaces.svelte +19 -0
- package/dist/__integration/components/Namespaces.svelte.d.ts +16 -0
- package/dist/__integration/components/TestGetTolgee.svelte +14 -0
- package/dist/__integration/components/TestGetTolgee.svelte.d.ts +19 -0
- package/dist/__integration/components/TestProviderComponent.svelte +18 -0
- package/dist/__integration/components/TestProviderComponent.svelte.d.ts +19 -0
- package/dist/__integration/components/TestTComponent.svelte +24 -0
- package/dist/__integration/components/TestTComponent.svelte.d.ts +19 -0
- package/dist/__integration/components/TestTranslateComponent.svelte +9 -0
- package/dist/__integration/components/TestTranslateComponent.svelte.d.ts +19 -0
- package/dist/__integration/components/TestTranslateComponentInside.svelte +19 -0
- package/dist/__integration/components/TestTranslateComponentInside.svelte.d.ts +25 -0
- package/dist/__integration/mockCoreFetch.d.ts +25 -0
- package/dist/__integration/mockCoreFetch.js +12 -0
- package/dist/__testUtil/TolgeeProviderFallback.svelte +7 -0
- package/dist/__testUtil/TolgeeProviderFallback.svelte.d.ts +19 -0
- package/dist/__testUtil/TolgeeProviderSlotTest.svelte +10 -0
- package/dist/__testUtil/TolgeeProviderSlotTest.svelte.d.ts +19 -0
- package/{getTolgee.d.ts → dist/getTolgee.d.ts} +2 -1
- package/{getTranslate.d.ts → dist/getTranslate.d.ts} +1 -0
- package/{getTranslateInternal.d.ts → dist/getTranslateInternal.d.ts} +1 -0
- package/{getTranslateInternal.js → dist/getTranslateInternal.js} +1 -1
- package/package.json +86 -71
- package/CHANGELOG.md +0 -1207
- package/README.njk.md +0 -102
- package/T.svelte +0 -21
- package/T.svelte.d.ts +0 -22
- /package/{GlobalContextPlugin.js → dist/GlobalContextPlugin.js} +0 -0
- /package/{getTolgee.js → dist/getTolgee.js} +0 -0
- /package/{getTolgeeContext.d.ts → dist/getTolgeeContext.d.ts} +0 -0
- /package/{getTolgeeContext.js → dist/getTolgeeContext.js} +0 -0
- /package/{getTranslate.js → dist/getTranslate.js} +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{types.d.ts → dist/types.d.ts} +0 -0
- /package/{types.js → dist/types.js} +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<!-- This file was generated using pnpm generate-readmes script
|
|
2
|
-
|
|
1
|
+
<!-- This file was generated using pnpm generate-readmes script
|
|
2
|
+
|
|
3
3
|
Don't edit this file. Edit the README.md.njk. Macros can be found in readmeMacros/macros.njk
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
-->
|
|
6
6
|
|
|
7
7
|
<h1 align="center" style="border-bottom: none">
|
|
@@ -28,6 +28,7 @@ Tolgee is an open-source alternative to Crowdin, Phrase, or Lokalise with its ve
|
|
|
28
28
|
[](https://github.com/tolgee/tolgee-js)
|
|
29
29
|
[](https://github.com/tolgee/server)
|
|
30
30
|
[](https://github.com/tolgee/tolgee-platform/discussions)
|
|
31
|
+
|
|
31
32
|
</div>
|
|
32
33
|
|
|
33
34
|
<div align="center">
|
|
@@ -40,27 +41,24 @@ Tolgee is an open-source alternative to Crowdin, Phrase, or Lokalise with its ve
|
|
|
40
41
|
|
|
41
42
|
</div>
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
44
|
# What is Tolgee for Svelte?
|
|
45
|
+
|
|
46
46
|
Svelte integration library of Tolgee. With this package, it's super simple to add i18n to your Svelte app!
|
|
47
47
|
For more information about using Tolgee with Svelte, visit the [docs 📖](https://tolgee.io/integrations/svelte).
|
|
48
48
|
|
|
49
49
|
Localize (translate) your Svelte or SvelteKit projects to multiple languages with Tolgee.
|
|
50
50
|
Integration of Tolgee is extremely simple! 🇯🇵 🇰🇷 🇩🇪 🇨🇳 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧
|
|
51
51
|
|
|
52
|
-
|
|
53
52
|
## Quick links
|
|
53
|
+
|
|
54
54
|
- [Tolgee for Svelte docs](https://tolgee.io/js-sdk/integrations/svelte/overview)
|
|
55
55
|
- [Tolgee JS SDK docs](https://tolgee.io/js-sdk)
|
|
56
56
|
- [Tolgee Website](https://tolgee.io)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
- Product (Learn more about the great features)
|
|
58
|
+
- [Dev tools](https://tolgee.io/features/dev-tools)
|
|
59
|
+
- [Translation assistance](https://tolgee.io/features/translation-assistance)
|
|
60
|
+
- [Collaboration](https://tolgee.io/features/collaboration)
|
|
61
61
|
- [Tolgee platform docs](https://tolgee.io/platform)
|
|
62
|
-
|
|
63
|
-
|
|
64
62
|
|
|
65
63
|
## Installation
|
|
66
64
|
|
|
@@ -68,31 +66,25 @@ Integration of Tolgee is extremely simple! 🇯🇵 🇰🇷 🇩🇪 🇨🇳
|
|
|
68
66
|
npm install @tolgee/svelte
|
|
69
67
|
```
|
|
70
68
|
|
|
71
|
-
|
|
72
69
|
Then use the library in your app:
|
|
73
70
|
|
|
74
71
|
```svelte
|
|
75
72
|
<script lang="ts">
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
.init({
|
|
87
|
-
apiUrl: import.meta.env.VITE_TOLGEE_API_URL,
|
|
88
|
-
apiKey: import.meta.env.VITE_TOLGEE_API_KEY,
|
|
89
|
-
language: 'en',
|
|
90
|
-
});
|
|
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
|
+
});
|
|
91
83
|
</script>
|
|
92
84
|
|
|
93
85
|
<TolgeeProvider {tolgee}>
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
<div slot="fallback">Loading...</div>
|
|
87
|
+
<slot />
|
|
96
88
|
</TolgeeProvider>
|
|
97
89
|
```
|
|
98
90
|
|
|
@@ -104,7 +96,7 @@ To translate texts using Tolgee Svelte integration, you can use `T` component or
|
|
|
104
96
|
|
|
105
97
|
```svelte
|
|
106
98
|
<script>
|
|
107
|
-
|
|
99
|
+
import { T } from '@tolgee/svelte';
|
|
108
100
|
</script>
|
|
109
101
|
|
|
110
102
|
<T keyName="key" defaultValue="This is default" />
|
|
@@ -116,9 +108,9 @@ The `getTranslate` function returns a store containing the function, which trans
|
|
|
116
108
|
|
|
117
109
|
```svelte
|
|
118
110
|
<script>
|
|
119
|
-
|
|
111
|
+
import { getTranslate } from '@tolgee/svelte';
|
|
120
112
|
|
|
121
|
-
|
|
113
|
+
const { t } = getTranslate();
|
|
122
114
|
</script>
|
|
123
115
|
|
|
124
116
|
{$t('this_is_a_key', { key: 'value', key2: 'value2' })}
|
|
@@ -130,29 +122,25 @@ To change the current language, use `getTolgee` method. For example, you can bin
|
|
|
130
122
|
|
|
131
123
|
```svelte
|
|
132
124
|
<script lang="ts">
|
|
133
|
-
|
|
125
|
+
import { getTolgee } from '@tolgee/svelte';
|
|
134
126
|
|
|
135
|
-
|
|
127
|
+
const tolgee = getTolgee(['language']);
|
|
136
128
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
129
|
+
function handleLanguageChange(e) {
|
|
130
|
+
$tolgee.changeLanguage(e.currentTarget.value);
|
|
131
|
+
}
|
|
140
132
|
</script>
|
|
141
133
|
|
|
142
|
-
<select value={$tolgee.getLanguage()} on:change={handleLanguageChange}>
|
|
143
|
-
...
|
|
144
|
-
</select>
|
|
134
|
+
<select value={$tolgee.getLanguage()} on:change={handleLanguageChange}> ... </select>
|
|
145
135
|
```
|
|
146
136
|
|
|
147
|
-
|
|
148
137
|
## Prerequisites
|
|
149
138
|
|
|
150
139
|
1. You have some Svelte-based project
|
|
151
140
|
2. You have generated an API key from [Tolgee Cloud](https://app.tolgee.io) or a self-hosted Tolgee instance.
|
|
152
|
-
|
|
153
|
-
|
|
154
141
|
|
|
155
142
|
## Why use Tolgee?
|
|
143
|
+
|
|
156
144
|
Tolgee saves a lot of time you would spend on localization tasks otherwise. It enables you to provide perfectly translated software.
|
|
157
145
|
|
|
158
146
|
### Features
|
|
@@ -166,56 +154,54 @@ Tolgee saves a lot of time you would spend on localization tasks otherwise. It e
|
|
|
166
154
|

|
|
167
155
|
Read more on the [Tolgee website](https://tolgee.io)
|
|
168
156
|
|
|
169
|
-
|
|
170
157
|
## Development
|
|
171
158
|
|
|
172
159
|
We welcome your PRs.
|
|
173
160
|
|
|
174
161
|
To develop the package locally:
|
|
162
|
+
|
|
175
163
|
1. Clone [the repository](https://github.com/tolgee/tolgee-js)
|
|
176
164
|
1. Install the packages in the repository root
|
|
165
|
+
|
|
177
166
|
```
|
|
178
167
|
pnpm install
|
|
179
168
|
```
|
|
180
169
|
|
|
181
|
-
|
|
182
170
|
1. Run the development script
|
|
171
|
+
|
|
183
172
|
```
|
|
184
173
|
pnpm develop:svelte
|
|
185
174
|
```
|
|
175
|
+
|
|
186
176
|
This runs the development suite of this monorepo for the `svelte` integration. The changes in each dependency package are
|
|
187
177
|
automatically built and propagated to the test application, which you can open and play within the browser.
|
|
188
178
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
179
|
### Testing
|
|
193
180
|
|
|
194
181
|
To run Jest tests of this package, execute
|
|
182
|
+
|
|
195
183
|
```
|
|
196
184
|
npm run test
|
|
197
185
|
```
|
|
198
|
-
In the `/packages/svelte` directory.
|
|
199
|
-
|
|
200
|
-
|
|
201
186
|
|
|
187
|
+
In the `/packages/svelte` directory.
|
|
202
188
|
|
|
203
189
|
### End-to-end (e2e) testing
|
|
190
|
+
|
|
204
191
|
To run the e2e tests, simply execute
|
|
192
|
+
|
|
205
193
|
```
|
|
206
194
|
pnpm run e2e run svelte
|
|
207
195
|
```
|
|
208
196
|
|
|
209
197
|
To open and play with e2e tests, run:
|
|
198
|
+
|
|
210
199
|
```
|
|
211
200
|
pnpm run e2e open svelte
|
|
212
201
|
```
|
|
213
202
|
|
|
214
|
-
|
|
215
|
-
|
|
216
203
|
## Contributors
|
|
217
204
|
|
|
218
205
|
<a href="https://github.com/tolgee/tolgee-platform/graphs/contributors">
|
|
219
206
|
<img alt="contributors" src="https://contrib.rocks/image?repo=tolgee/tolgee-js"/>
|
|
220
207
|
</a>
|
|
221
|
-
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { TolgeePlugin } from '@tolgee/web';
|
|
2
2
|
import type { TolgeeSvelteContext } from './types';
|
|
3
3
|
export declare const GlobalContextPlugin: () => TolgeePlugin;
|
|
4
|
-
export declare function getGlobalContext(): TolgeeSvelteContext;
|
|
4
|
+
export declare function getGlobalContext(): TolgeeSvelteContext | undefined;
|
package/dist/T.svelte
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>import getTranslateInternal from "./getTranslateInternal";
|
|
2
|
+
export let keyName;
|
|
3
|
+
export let params = void 0;
|
|
4
|
+
export let noWrap = false;
|
|
5
|
+
export let defaultValue = void 0;
|
|
6
|
+
export let ns = void 0;
|
|
7
|
+
export let language = void 0;
|
|
8
|
+
if (!keyName) {
|
|
9
|
+
console.error("Missing keyName prop!");
|
|
10
|
+
}
|
|
11
|
+
const { t } = getTranslateInternal();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
{$t({
|
|
15
|
+
key: keyName,
|
|
16
|
+
params: params,
|
|
17
|
+
noWrap: noWrap,
|
|
18
|
+
defaultValue: defaultValue,
|
|
19
|
+
ns,
|
|
20
|
+
language,
|
|
21
|
+
})}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { TranslationKey } from '@tolgee/web';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
keyName: TranslationKey;
|
|
6
|
+
params?: Record<string, unknown> | undefined;
|
|
7
|
+
noWrap?: boolean | undefined;
|
|
8
|
+
defaultValue?: undefined;
|
|
9
|
+
ns?: string | undefined;
|
|
10
|
+
language?: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
events: {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {};
|
|
16
|
+
exports?: {} | undefined;
|
|
17
|
+
bindings?: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
export type TProps = typeof __propDef.props;
|
|
20
|
+
export type TEvents = typeof __propDef.events;
|
|
21
|
+
export type TSlots = typeof __propDef.slots;
|
|
22
|
+
export default class T extends SvelteComponent<TProps, TEvents, TSlots> {
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<script>import { onDestroy, onMount, setContext } from
|
|
1
|
+
<script>import { onDestroy, onMount, setContext } from "svelte";
|
|
2
2
|
export let tolgee;
|
|
3
|
-
export let fallback =
|
|
3
|
+
export let fallback = void 0;
|
|
4
4
|
let isLoading = !tolgee.isLoaded();
|
|
5
|
-
setContext(
|
|
6
|
-
|
|
5
|
+
setContext("tolgeeContext", {
|
|
6
|
+
tolgee
|
|
7
7
|
});
|
|
8
8
|
onMount(() => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
tolgee.run().finally(() => {
|
|
10
|
+
isLoading = false;
|
|
11
|
+
});
|
|
12
12
|
});
|
|
13
13
|
onDestroy(tolgee.stop);
|
|
14
14
|
</script>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
import type { TolgeeInstance } from '@tolgee/web';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
tolgee: TolgeeInstance;
|
|
6
|
-
fallback?:
|
|
6
|
+
fallback?: undefined;
|
|
7
7
|
};
|
|
8
8
|
events: {
|
|
9
9
|
[evt: string]: CustomEvent<any>;
|
|
@@ -12,10 +12,12 @@ declare const __propDef: {
|
|
|
12
12
|
default: {};
|
|
13
13
|
fallback: {};
|
|
14
14
|
};
|
|
15
|
+
exports?: {} | undefined;
|
|
16
|
+
bindings?: string | undefined;
|
|
15
17
|
};
|
|
16
18
|
export type TolgeeProviderProps = typeof __propDef.props;
|
|
17
19
|
export type TolgeeProviderEvents = typeof __propDef.events;
|
|
18
20
|
export type TolgeeProviderSlots = typeof __propDef.slots;
|
|
19
|
-
export default class TolgeeProvider extends
|
|
21
|
+
export default class TolgeeProvider extends SvelteComponent<TolgeeProviderProps, TolgeeProviderEvents, TolgeeProviderSlots> {
|
|
20
22
|
}
|
|
21
23
|
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script>import { getTranslate } from "../../index";
|
|
2
|
+
const { isLoading, t } = getTranslate("test");
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<div>
|
|
6
|
+
{#if $isLoading}
|
|
7
|
+
<div data-testid="loading">Loading...</div>
|
|
8
|
+
{/if}
|
|
9
|
+
<div data-testid="test">{$t('test')}</div>
|
|
10
|
+
<div data-testid="test_english_fallback">
|
|
11
|
+
{$t('test_english_fallback')}
|
|
12
|
+
</div>
|
|
13
|
+
<div data-testid="non_existant">
|
|
14
|
+
{$t('non_existant', 'Non existant')}
|
|
15
|
+
</div>
|
|
16
|
+
<div data-testid="ns_fallback">
|
|
17
|
+
{$t('fallback', { ns: 'invalid' })}
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
exports?: {} | undefined;
|
|
9
|
+
bindings?: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
export type NamespacesProps = typeof __propDef.props;
|
|
12
|
+
export type NamespacesEvents = typeof __propDef.events;
|
|
13
|
+
export type NamespacesSlots = typeof __propDef.slots;
|
|
14
|
+
export default class Namespaces extends SvelteComponent<NamespacesProps, NamespacesEvents, NamespacesSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script>import { getTolgee } from "../../getTolgee";
|
|
2
|
+
export let events = [];
|
|
3
|
+
const tolgee = getTolgee(events);
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<div>
|
|
7
|
+
<div data-testid="language">{String($tolgee.getLanguage())}</div>
|
|
8
|
+
<div data-testid="pendingLanguage">{String($tolgee.getPendingLanguage())}</div>
|
|
9
|
+
<div data-testid="fetching">{String($tolgee.isFetching())}</div>
|
|
10
|
+
<div data-testid="loading">{String($tolgee.isLoading())}</div>
|
|
11
|
+
<div data-testid="initialLoad">{String($tolgee.isInitialLoading())}</div>
|
|
12
|
+
<div data-testid="running">{String($tolgee.isRunning())}</div>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { TolgeeEvent } from "@tolgee/web";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
events?: TolgeeEvent[] | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
exports?: {} | undefined;
|
|
12
|
+
bindings?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type TestGetTolgeeProps = typeof __propDef.props;
|
|
15
|
+
export type TestGetTolgeeEvents = typeof __propDef.events;
|
|
16
|
+
export type TestGetTolgeeSlots = typeof __propDef.slots;
|
|
17
|
+
export default class TestGetTolgee extends SvelteComponent<TestGetTolgeeProps, TestGetTolgeeEvents, TestGetTolgeeSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script>import { TolgeeProvider, T } from "../..";
|
|
2
|
+
export let tolgee;
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<TolgeeProvider {tolgee}>
|
|
6
|
+
<div>
|
|
7
|
+
<div data-testid="hello_world">
|
|
8
|
+
<T keyName="hello_world" />
|
|
9
|
+
</div>
|
|
10
|
+
<div data-testid="english_fallback">
|
|
11
|
+
<T keyName="english_fallback" />
|
|
12
|
+
</div>
|
|
13
|
+
<div data-testid="non_existant">
|
|
14
|
+
<T keyName="non_existant" defaultValue="Default value" />
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
<span slot="fallback">Loading...</span>
|
|
18
|
+
</TolgeeProvider>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { TolgeeInstance } from '@tolgee/web';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
tolgee: TolgeeInstance;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
exports?: {} | undefined;
|
|
12
|
+
bindings?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type TestProviderComponentProps = typeof __propDef.props;
|
|
15
|
+
export type TestProviderComponentEvents = typeof __propDef.events;
|
|
16
|
+
export type TestProviderComponentSlots = typeof __propDef.slots;
|
|
17
|
+
export default class TestProviderComponent extends SvelteComponent<TestProviderComponentProps, TestProviderComponentEvents, TestProviderComponentSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script>import { T, TolgeeProvider } from "../..";
|
|
2
|
+
export let tolgee;
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<TolgeeProvider {tolgee}>
|
|
6
|
+
<div>
|
|
7
|
+
<div data-testid="peter_dogs">
|
|
8
|
+
<T keyName="peter_dogs" params={{ dogsCount: 5 }} />
|
|
9
|
+
</div>
|
|
10
|
+
<div data-testid="hello_world">
|
|
11
|
+
<T keyName="hello_world" />
|
|
12
|
+
</div>
|
|
13
|
+
<div data-testid="hello_world_no_wrap">
|
|
14
|
+
<T keyName="hello_world" noWrap />
|
|
15
|
+
</div>
|
|
16
|
+
<div data-testid="non_existant">
|
|
17
|
+
<T keyName="non_existant" defaultValue="Non existant" />
|
|
18
|
+
</div>
|
|
19
|
+
<div data-testid="with_language_prop">
|
|
20
|
+
<T keyName="hello_world" language="en" />
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<span slot="fallback">Loading...</span>
|
|
24
|
+
</TolgeeProvider>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { TolgeeInstance } from '@tolgee/web';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
tolgee: TolgeeInstance;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
exports?: {} | undefined;
|
|
12
|
+
bindings?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type TestTComponentProps = typeof __propDef.props;
|
|
15
|
+
export type TestTComponentEvents = typeof __propDef.events;
|
|
16
|
+
export type TestTComponentSlots = typeof __propDef.slots;
|
|
17
|
+
export default class TestTComponent extends SvelteComponent<TestTComponentProps, TestTComponentEvents, TestTComponentSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<script>import { TolgeeProvider } from "../..";
|
|
2
|
+
import TestTranslateComponentInside from "./TestTranslateComponentInside.svelte";
|
|
3
|
+
export let tolgee;
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<TolgeeProvider tolgee={tolgee}>
|
|
7
|
+
<TestTranslateComponentInside />
|
|
8
|
+
<span slot="fallback">Loading...</span>
|
|
9
|
+
</TolgeeProvider>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { TolgeeInstance } from '@tolgee/web';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
tolgee: TolgeeInstance;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
exports?: {} | undefined;
|
|
12
|
+
bindings?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type TestTranslateComponentProps = typeof __propDef.props;
|
|
15
|
+
export type TestTranslateComponentEvents = typeof __propDef.events;
|
|
16
|
+
export type TestTranslateComponentSlots = typeof __propDef.slots;
|
|
17
|
+
export default class TestTranslateComponent extends SvelteComponent<TestTranslateComponentProps, TestTranslateComponentEvents, TestTranslateComponentSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { getTranslate } from '../..';
|
|
3
|
+
const { t } = getTranslate();
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<div>
|
|
7
|
+
<div data-testid="peter_dogs">
|
|
8
|
+
{$t('peter_dogs', { dogsCount: 5 })}
|
|
9
|
+
</div>
|
|
10
|
+
<div data-testid="hello_world">
|
|
11
|
+
{$t('hello_world')}
|
|
12
|
+
</div>
|
|
13
|
+
<div data-testid="hello_world_no_wrap">
|
|
14
|
+
{$t({ key: 'hello_world', noWrap: true })}
|
|
15
|
+
</div>
|
|
16
|
+
<div data-testid="non_existant">
|
|
17
|
+
{$t('non_existant', 'Non existant')}
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} TestTranslateComponentInsideProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} TestTranslateComponentInsideEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} TestTranslateComponentInsideSlots */
|
|
4
|
+
export default class TestTranslateComponentInside extends SvelteComponent<{
|
|
5
|
+
[x: string]: never;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {}> {
|
|
9
|
+
}
|
|
10
|
+
export type TestTranslateComponentInsideProps = typeof __propDef.props;
|
|
11
|
+
export type TestTranslateComponentInsideEvents = typeof __propDef.events;
|
|
12
|
+
export type TestTranslateComponentInsideSlots = typeof __propDef.slots;
|
|
13
|
+
import { SvelteComponent } from "svelte";
|
|
14
|
+
declare const __propDef: {
|
|
15
|
+
props: {
|
|
16
|
+
[x: string]: never;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {};
|
|
22
|
+
exports?: undefined;
|
|
23
|
+
bindings?: undefined;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import 'node-fetch';
|
|
2
|
+
export declare const mockCoreFetch: () => {
|
|
3
|
+
fetch: import("vitest-fetch-mock").FetchMock;
|
|
4
|
+
resolveAll: () => void;
|
|
5
|
+
currentApiKey: {
|
|
6
|
+
promise: Promise<string>;
|
|
7
|
+
resolve: () => void;
|
|
8
|
+
};
|
|
9
|
+
csTranslations: {
|
|
10
|
+
promise: Promise<string>;
|
|
11
|
+
resolve: () => void;
|
|
12
|
+
};
|
|
13
|
+
enTranslations: {
|
|
14
|
+
promise: Promise<string>;
|
|
15
|
+
resolve: () => void;
|
|
16
|
+
};
|
|
17
|
+
enTestTranslations: {
|
|
18
|
+
promise: Promise<string>;
|
|
19
|
+
resolve: () => void;
|
|
20
|
+
};
|
|
21
|
+
csTestTranslations: {
|
|
22
|
+
promise: Promise<string>;
|
|
23
|
+
resolve: () => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import 'node-fetch';
|
|
2
|
+
import { getMocker } from '@tolgee/testing/mockData.js';
|
|
3
|
+
import createFetchMock from 'vitest-fetch-mock';
|
|
4
|
+
import { vi } from 'vitest';
|
|
5
|
+
const fetchMocker = createFetchMock(vi);
|
|
6
|
+
export const mockCoreFetch = () => {
|
|
7
|
+
const mocker = getMocker();
|
|
8
|
+
const fetch = fetchMocker.mockResponse((req) => {
|
|
9
|
+
return mocker.getDataForUrl(req.url);
|
|
10
|
+
});
|
|
11
|
+
return { ...mocker.mockData, fetch, resolveAll: mocker.resolveAll };
|
|
12
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { TolgeeInstance } from '@tolgee/web';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
tolgee: TolgeeInstance;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
exports?: {} | undefined;
|
|
12
|
+
bindings?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type TolgeeProviderFallbackProps = typeof __propDef.props;
|
|
15
|
+
export type TolgeeProviderFallbackEvents = typeof __propDef.events;
|
|
16
|
+
export type TolgeeProviderFallbackSlots = typeof __propDef.slots;
|
|
17
|
+
export default class TolgeeProviderFallback extends SvelteComponent<TolgeeProviderFallbackProps, TolgeeProviderFallbackEvents, TolgeeProviderFallbackSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { TolgeeInstance } from "@tolgee/web";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
tolgee: TolgeeInstance;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
exports?: {} | undefined;
|
|
12
|
+
bindings?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type TolgeeProviderSlotTestProps = typeof __propDef.props;
|
|
15
|
+
export type TolgeeProviderSlotTestEvents = typeof __propDef.events;
|
|
16
|
+
export type TolgeeProviderSlotTestSlots = typeof __propDef.slots;
|
|
17
|
+
export default class TolgeeProviderSlotTest extends SvelteComponent<TolgeeProviderSlotTestProps, TolgeeProviderSlotTestEvents, TolgeeProviderSlotTestSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|