@inlang/paraglide-js 1.2.0 → 1.2.2
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 +93 -100
- package/default/index.d.ts +1 -0
- package/default/index.js +1 -0
- package/default/why.txt +4 -0
- package/dist/cli/commands/init.d.ts +19 -11
- package/dist/index.js +334 -193
- package/dist/services/file-handling/write-output.d.ts +2 -3
- package/package.json +26 -9
package/README.md
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
[<img src="https://cdn.loom.com/sessions/thumbnails/a8365ec4fa2c4f6bbbf4370cf22dd7f6-with-play.gif" width="100%" /> Watch the pre-release demo of Paraglide JS](https://www.youtube.com/watch?v=-YES3CCAG90)
|
|
4
|
-
|
|
5
|
-
Attention: The following features are missing and will be added in the upcoming weeks:
|
|
1
|
+
[<img src="https://cdn.loom.com/sessions/thumbnails/a8365ec4fa2c4f6bbbf4370cf22dd7f6-with-play.gif" width="100%" /> Watch the demo of Paraglide JS](https://www.youtube.com/watch?v=-YES3CCAG90)
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
<!--  -->
|
|
8
4
|
|
|
9
|
-
#
|
|
5
|
+
# Simple, adaptable, and tiny i18n library for JS
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
Get started instantly with the following command:
|
|
12
8
|
|
|
13
9
|
```bash
|
|
14
10
|
npx @inlang/paraglide-js@latest init
|
|
@@ -18,7 +14,7 @@ npx @inlang/paraglide-js@latest init
|
|
|
18
14
|
|
|
19
15
|
<doc-features>
|
|
20
16
|
<doc-feature title="No unused translations" image="https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/unused-translations.png"></doc-feature>
|
|
21
|
-
<doc-feature title="
|
|
17
|
+
<doc-feature title="Minimal payload" image="https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/reduced-payload.png"></doc-feature>
|
|
22
18
|
<doc-feature title="Typesafety" image="https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/typesafe.png"></doc-feature>
|
|
23
19
|
</doc-features>
|
|
24
20
|
|
|
@@ -29,7 +25,6 @@ npx @inlang/paraglide-js@latest init
|
|
|
29
25
|
|
|
30
26
|
Treeshaking gives us superpowers. With it, each page of your app only loads the messages that it actually uses. Incremental loading like this would usually take hours of manual tweaking to get right. With Paraglide-JS you get it for free. Say goodbye to huge bundles.
|
|
31
27
|
|
|
32
|
-
|
|
33
28
|
# Getting started
|
|
34
29
|
|
|
35
30
|
### 1. Initialize paraglide-js
|
|
@@ -40,37 +35,28 @@ You can initialize paraglide-js by running the following command in your termina
|
|
|
40
35
|
npx @inlang/paraglide-js@latest init
|
|
41
36
|
```
|
|
42
37
|
|
|
43
|
-
|
|
38
|
+
This will:
|
|
39
|
+
|
|
40
|
+
1. Install the necessary dependencies
|
|
41
|
+
2. Call the Paraglide compiler in your `build` script
|
|
42
|
+
3. Set up any necessary configuration files
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
### 2. Set up an adapter (optional)
|
|
45
|
+
|
|
46
|
+
Adapters are framework specific integrations for Paraglide. If you are using a framework, using an adapter is recommended (but not required). If you don't use a framework, you can skip this step.
|
|
46
47
|
|
|
47
48
|
<doc-links>
|
|
48
|
-
<doc-link title="Adapter for
|
|
49
|
-
<doc-link title="Adapter for SolidJS" icon="tabler:brand-solidjs" href="https://inlang.com/m/n860p17j/library-inlang-paraglideJsAdapterSolidStart" description="Go to
|
|
49
|
+
<doc-link title="Adapter for SvelteKit" icon="simple-icons:svelte" href="https://inlang.com/m/dxnzrydw/library-inlang-paraglideJsAdapterSvelteKit" description="Go to Library"></doc-link>
|
|
50
|
+
<doc-link title="Adapter for SolidJS" icon="tabler:brand-solidjs" href="https://inlang.com/m/n860p17j/library-inlang-paraglideJsAdapterSolidStart" description="Go to Library"></doc-link>
|
|
50
51
|
<doc-link title="Adapter for NextJS" icon="tabler:brand-nextjs" href="https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-next" description="Go to GitHub example"></doc-link>
|
|
51
52
|
<doc-link title="Adapter for Vite" icon="tabler:brand-vite" href="https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-vite" description="Go to GitHub"></doc-link>
|
|
52
53
|
</doc-links>
|
|
53
54
|
|
|
54
55
|
#### Alternatively, [you can write your own adapter](#writing-an-adapter)
|
|
55
56
|
|
|
56
|
-
### 3. Add the `compile` script to your `package.json`
|
|
57
|
-
|
|
58
|
-
> If you are using `@inlang/paraglide-js-adapter-vite`, you can skip this step.
|
|
59
|
-
|
|
60
|
-
You can customize the `compile` script to your needs. For example, you can add a `--watch` flag to watch for changes, if you have installed a watcher.
|
|
61
|
-
|
|
62
|
-
```json
|
|
63
|
-
{
|
|
64
|
-
"scripts": {
|
|
65
|
-
"compile": "paraglide-js compile --project ./project.inlang",
|
|
66
|
-
"watch": "paraglide-js compile --project ./project.inlang --watch"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
57
|
# Usage
|
|
72
58
|
|
|
73
|
-
Running
|
|
59
|
+
Running your `build` script will generate a `src/paraglide` folder. This folder contains all the code that you need to use paraglide-js.
|
|
74
60
|
Throughout this guide, you will see imports from `./paraglide/*`. These are all to this folder.
|
|
75
61
|
|
|
76
62
|
> Tip: If you are using a bundler, you can set up an alias to `./src/paraglide` to make the imports shorter. We recommend `$paraglide/*`
|
|
@@ -83,8 +69,8 @@ The compiled messages are placed in `./paraglide/messages.js`. You can import th
|
|
|
83
69
|
// m is a namespace that contains all messages of your project
|
|
84
70
|
// a bundler like rollup or webpack only bundles
|
|
85
71
|
// the messages that are used
|
|
86
|
-
import * as m from "./paraglide/messages"
|
|
87
|
-
import { setLanguageTag } from "./paraglide/runtime"
|
|
72
|
+
import * as m from "./paraglide/messages.js"
|
|
73
|
+
import { setLanguageTag } from "./paraglide/runtime.js"
|
|
88
74
|
|
|
89
75
|
// use a message
|
|
90
76
|
m.hello() // Hello world!
|
|
@@ -101,7 +87,7 @@ m.loginHeader({ name: "Samuel" }) // Hallo Samuel, bitte melde dich an, um fortz
|
|
|
101
87
|
If you want to dynamically choose between a set of messages, you can create a record of messages and index into it. Note that this will not be tree-shaken by your bundler.
|
|
102
88
|
|
|
103
89
|
```js
|
|
104
|
-
import * as m from "./paraglide/messages"
|
|
90
|
+
import * as m from "./paraglide/messages.js"
|
|
105
91
|
|
|
106
92
|
const season = {
|
|
107
93
|
spring: m.spring,
|
|
@@ -113,24 +99,25 @@ const season = {
|
|
|
113
99
|
const msg = season["spring"]() // Hello spring!
|
|
114
100
|
```
|
|
115
101
|
|
|
116
|
-
Paraglide JS provides
|
|
102
|
+
Paraglide JS provides several exports from `./paraglide/runtime.js`:
|
|
117
103
|
|
|
118
|
-
| Variable
|
|
119
|
-
|
|
|
120
|
-
| `sourceLanguageTag`
|
|
121
|
-
| `availableLanguageTags`
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
104
|
+
| Variable | Description |
|
|
105
|
+
| --------------------------- | --------------------------------------------------------------------- |
|
|
106
|
+
| `sourceLanguageTag` | The source language tag of the project |
|
|
107
|
+
| `availableLanguageTags` | All language tags of the current project |
|
|
108
|
+
| `type AvailableLanguageTag` | An Type representing a valid language tag |
|
|
109
|
+
| `languageTag()` | Returns the language tag of the current user |
|
|
110
|
+
| `setLanguageTag()` | Sets the language tag of the current user |
|
|
111
|
+
| `onSetLanguageTag()` | Registers a listener that is called whenever the language tag changes |
|
|
112
|
+
| `isAvailableLanguageTag()` | Checks if a value is a valid language tag |
|
|
126
113
|
|
|
127
114
|
## Setting the language
|
|
128
115
|
|
|
129
|
-
You can set the current [language tag](/m/8y8sxj09/library-inlang-languageTag) by calling `setLanguageTag()`. Any subsequent calls to either `languageTag()` or a message function will return the new language tag.
|
|
116
|
+
You can set the current [language tag](https://www.inlang.com/m/8y8sxj09/library-inlang-languageTag) by calling `setLanguageTag()`. Any subsequent calls to either `languageTag()` or a message function will return the new language tag.
|
|
130
117
|
|
|
131
118
|
```js
|
|
132
|
-
import { setLanguageTag } from "./paraglide/runtime"
|
|
133
|
-
import * as m from "./paraglide/messages"
|
|
119
|
+
import { setLanguageTag } from "./paraglide/runtime.js"
|
|
120
|
+
import * as m from "./paraglide/messages.js"
|
|
134
121
|
|
|
135
122
|
setLanguageTag("de")
|
|
136
123
|
m.hello() // Hallo Welt!
|
|
@@ -139,15 +126,26 @@ setLanguageTag("en")
|
|
|
139
126
|
m.hello() // Hello world!
|
|
140
127
|
```
|
|
141
128
|
|
|
142
|
-
The [language tag](/m/8y8sxj09/library-inlang-languageTag) is global, so you need to be careful with it on the server to make sure multiple requests don't interfere with each other. That's why we recommend using an adapter for your framework. Adapters integrate with the framework's lifecycle and ensure that the language tag is managed correctly.
|
|
129
|
+
The [language tag](https://www.inlang.com/m/8y8sxj09/library-inlang-languageTag) is global, so you need to be careful with it on the server to make sure multiple requests don't interfere with each other. That's why we recommend using an adapter for your framework. Adapters integrate with the framework's lifecycle and ensure that the language tag is managed correctly.
|
|
130
|
+
|
|
131
|
+
## Adding Languages
|
|
132
|
+
|
|
133
|
+
You can define which languages you want to support in `./project.inlang/settings.json`. Just edit the `languageTags` array.
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
// project.inlang/settings.json
|
|
137
|
+
{
|
|
138
|
+
"languageTags": ["en", "de"]
|
|
139
|
+
}
|
|
140
|
+
```
|
|
143
141
|
|
|
144
142
|
## Reacting to a language change
|
|
145
143
|
|
|
146
|
-
You can react to a language change by
|
|
144
|
+
You can react to a language change by registering a callback using `onSetLanguageTag()`. This function is called whenever the [language tag](https://www.inlang.com/m/8y8sxj09/library-inlang-languageTag) changes.
|
|
147
145
|
|
|
148
146
|
```js
|
|
149
|
-
import { setLanguageTag, onSetLanguageTag } from "./paraglide/runtime"
|
|
150
|
-
import * as m from "./paraglide/messages"
|
|
147
|
+
import { setLanguageTag, onSetLanguageTag } from "./paraglide/runtime.js"
|
|
148
|
+
import * as m from "./paraglide/messages.js"
|
|
151
149
|
|
|
152
150
|
onSetLanguageTag((newLanguageTag) => {
|
|
153
151
|
console.log(`The language changed to ${newLanguageTag}`)
|
|
@@ -166,17 +164,17 @@ The main use case for `onSetLanguageTag()` is to trigger a rerender of your app'
|
|
|
166
164
|
|
|
167
165
|
## Forcing a language
|
|
168
166
|
|
|
169
|
-
It's common that you need to force a message to be in a certain language, especially on the server. You can do this by passing an options object to the message function as a
|
|
167
|
+
It's common that you need to force a message to be in a certain language, especially on the server and during tests. You can do this by passing an options object to the message function as a
|
|
170
168
|
second parameter.
|
|
171
169
|
|
|
172
170
|
```js
|
|
173
|
-
import * as m from "./paraglide/messages"
|
|
171
|
+
import * as m from "./paraglide/messages.js"
|
|
174
172
|
const msg = m.hello({ name: "Samuel" }, { languageTag: "de" }) // Hallo Samuel!
|
|
175
173
|
```
|
|
176
174
|
|
|
177
175
|
## Usage with a Bundler
|
|
178
176
|
|
|
179
|
-
We provide
|
|
177
|
+
We provide bundler plugins to make it easier to use Paraglide with a bundler. If you
|
|
180
178
|
are using one of these bundlers, we recommed using the corresponding plugin.
|
|
181
179
|
|
|
182
180
|
- [Rollup](https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-rollup)
|
|
@@ -187,28 +185,29 @@ These plugins make sure to rerun the `compile` script whenever you build your pr
|
|
|
187
185
|
|
|
188
186
|
# Playground
|
|
189
187
|
|
|
190
|
-
You can find many examples for how to use paraglide on codesandbox
|
|
188
|
+
You can find many examples for how to use paraglide on codesandbox, or in [our GitHub repository](https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide).
|
|
191
189
|
|
|
192
190
|
<doc-links>
|
|
193
|
-
<doc-link title="Svelte + Paraglide JS" icon="lucide:codesandbox" href="https://
|
|
191
|
+
<doc-link title="Svelte + Paraglide JS" icon="lucide:codesandbox" href="https://stackblitz.com/~/github.com/LorisSigrist/paraglide-sveltekit-example" description="Play around with Svelte and Paraglide JS"></doc-link>
|
|
192
|
+
<doc-link title="Astro + Paraglide JS" icon="lucide:codesandbox" href="https://stackblitz.com/~/github.com/LorisSigrist/paraglide-astro-example" description="Play around with Astro and Paraglide JS"></doc-link>
|
|
194
193
|
</doc-links>
|
|
195
194
|
|
|
196
195
|
# Architecture
|
|
197
196
|
|
|
198
197
|
Inlang Paraglide JS leverages a compiler to emit vanilla JavaScript functions.
|
|
199
198
|
|
|
200
|
-
The emitted functions are
|
|
199
|
+
The emitted functions are referred to as "message functions". By emitting message functions, inlang Paraglide JS eliminates a whole class of edge cases while also being simpler, faster, and more reliable than other i18n libraries. The compiled runtime contains less than 50 LOC (lines of code) and is less than 300 bytes minified & gzipped.
|
|
201
200
|
|
|
202
201
|

|
|
203
202
|
|
|
204
203
|
Inlang Paraglide-JS consists of four main parts:
|
|
205
204
|
|
|
206
|
-
| Part | Description
|
|
207
|
-
| ------------ |
|
|
208
|
-
| **Compiler** | Compiles messages into tree-shakable message functions
|
|
209
|
-
| **Messages** | The compiled tree-shakable message functions
|
|
210
|
-
| **Runtime** | A runtime that resolves the [language tag](/m/8y8sxj09/library-inlang-languageTag) of the current user
|
|
211
|
-
| **Adapter** | (
|
|
205
|
+
| Part | Description |
|
|
206
|
+
| ------------ | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
207
|
+
| **Compiler** | Compiles messages into tree-shakable message functions |
|
|
208
|
+
| **Messages** | The compiled tree-shakable message functions |
|
|
209
|
+
| **Runtime** | A runtime that resolves the [language tag](https://www.inlang.com/m/8y8sxj09/library-inlang-languageTag) of the current user |
|
|
210
|
+
| **Adapter** | (optional) An adapter that adjusts the runtime for different frameworks |
|
|
212
211
|
|
|
213
212
|
## Compiler
|
|
214
213
|
|
|
@@ -229,19 +228,16 @@ The compiler loads an inlang project and compiles the messages into tree-shakabl
|
|
|
229
228
|
**Output**
|
|
230
229
|
|
|
231
230
|
```js
|
|
232
|
-
// src/paraglide/messages.js
|
|
231
|
+
// src/paraglide/messages/en.js
|
|
233
232
|
|
|
234
233
|
/**
|
|
235
234
|
* @param {object} params
|
|
236
235
|
* @param {string} params.name
|
|
237
236
|
*/
|
|
238
|
-
|
|
239
|
-
return `Hello ${name}!`
|
|
240
|
-
}
|
|
237
|
+
export const hello = (params) => `Hello ${params.name}!`
|
|
241
238
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
239
|
+
/** ... */
|
|
240
|
+
export const loginButton = () => "Login"
|
|
245
241
|
```
|
|
246
242
|
|
|
247
243
|
## Messages
|
|
@@ -257,25 +253,21 @@ Three compiled message functions exist in an example project.
|
|
|
257
253
|
```js
|
|
258
254
|
// src/paraglide/messages.js
|
|
259
255
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
256
|
+
/** ... */
|
|
257
|
+
export const hello = (params) => `Hello ${params.name}!`
|
|
263
258
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
259
|
+
/** ... */
|
|
260
|
+
export const loginButton = () => "Login"
|
|
267
261
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
262
|
+
/** ... */
|
|
263
|
+
export const loginHeader = (params) => `Hello ${params.name}, please login to continue.`
|
|
271
264
|
```
|
|
272
265
|
|
|
273
266
|
Only the message `hello` is used in the source code.
|
|
274
267
|
|
|
275
268
|
```js
|
|
276
|
-
//
|
|
277
|
-
|
|
278
|
-
import * as m from "./paraglide/messages"
|
|
269
|
+
// src/my-code.js
|
|
270
|
+
import * as m from "../paraglide/messages.js"
|
|
279
271
|
|
|
280
272
|
console.log(m.hello({ name: "Samuel" }))
|
|
281
273
|
```
|
|
@@ -283,37 +275,25 @@ console.log(m.hello({ name: "Samuel" }))
|
|
|
283
275
|
The bundler tree shakes (removes) `loginButton` and `loginHeader` and only includes `hello` in the output.
|
|
284
276
|
|
|
285
277
|
```js
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
function hello(params) {
|
|
289
|
-
return `Hello ${params.name}!`
|
|
290
|
-
}
|
|
278
|
+
// dist/my-code.js
|
|
279
|
+
const hello = (params) => `Hello ${params.name}!`
|
|
291
280
|
|
|
292
281
|
console.log(hello({ name: "Samuel" }))
|
|
293
282
|
```
|
|
294
283
|
|
|
295
|
-
## Runtime
|
|
296
|
-
|
|
297
|
-
View the source of `./paraglide/runtime.js` to find the latest runtime API and documentation.
|
|
298
|
-
|
|
299
|
-
## Adapter
|
|
300
|
-
|
|
301
|
-
Paraglide-JS can be adapted to any framework or environment by calling `setLanguageTag()` and `onSetLanguageTag()`.
|
|
302
|
-
|
|
303
|
-
1. `setLanguageTag()` can be used to set a getter function for the [language tag](/m/8y8sxj09/library-inlang-languageTag). The getter function can be used to resolve server-side language tags or to resolve the language tag from a global state management library like Redux or Vuex.
|
|
304
|
-
2. `onSetLanguageTag()` can be used to trigger side-effects such as updating the UI, or requesting the site in the new language from the server.
|
|
305
|
-
|
|
306
284
|
# Writing an Adapter
|
|
307
285
|
|
|
286
|
+
Paraglide can be adapted to any framework or environment by calling `setLanguageTag()` and `onSetLanguageTag()`.
|
|
287
|
+
|
|
308
288
|
The following example adapts Paraglide-JS to a fictitious metaframework like NextJS, SolidStart, SvelteKit, or Nuxt.
|
|
309
289
|
|
|
310
|
-
The goal is to provide a high-level understanding of how to adapt Paraglide
|
|
290
|
+
The goal is to provide a high-level understanding of how to adapt Paraglide to a framework. Besides this example, we recommend viewing the source-code of available adapters. In general, only two functions need to be called to adapt Paraglide to a framework:
|
|
311
291
|
|
|
312
|
-
1.
|
|
313
|
-
2.
|
|
292
|
+
1. `setLanguageTag()` can be used to set a getter function for the [language tag](https://www.inlang.com/m/8y8sxj09/library-inlang-languageTag). The getter function can be used to resolve server-side language tags or to resolve the language tag from a global state management library like Redux or Vuex.
|
|
293
|
+
2. `onSetLanguageTag()` can be used to trigger side-effects such as updating the UI, or requesting the site in the new language from the server.
|
|
314
294
|
|
|
315
295
|
```tsx
|
|
316
|
-
import { setLanguageTag, onSetLanguageTag } from "
|
|
296
|
+
import { setLanguageTag, onSetLanguageTag } from "../paraglide/runtime.js"
|
|
317
297
|
import { isServer, request, render } from "@example/framework"
|
|
318
298
|
|
|
319
299
|
// On a server, the language tag needs to be resolved on a
|
|
@@ -358,15 +338,28 @@ We are grateful for all the support we get from the community. Here are just a f
|
|
|
358
338
|
Of course we are open to and value criticism as well. If you have any feedback, please let us know directly on [GitHub](https://github.com/opral/monorepo/discussions/1464)
|
|
359
339
|
|
|
360
340
|
<doc-comments>
|
|
341
|
+
<doc-comment text="Just tried Paraglide JS from @inlangHQ. This is how i18n should be done! Totally new level of DX for both implementation and managing translations! Superb support for SvelteKit as well ⭐" author="Patrik Engborg" icon="mdi:twitter" data-source="https://twitter.com/patrikengborg/status/1747260930873053674"></doc-comment>
|
|
361
342
|
<doc-comment text="The lib is great guys!" author="ktarmyshov" icon="mdi:github"></doc-comment>
|
|
362
343
|
<doc-comment text="Thank you for that huge work you have done and still doing!" author="ZerdoX-x" icon="mdi:github"></doc-comment>
|
|
363
344
|
<doc-comment text="[...] the switch between the sdk-js and paraglide has been pretty great! " author="albbus" icon="mdi:discord"></doc-comment>
|
|
364
345
|
<doc-comment text="Thanks for all the great work @Samuel Stroschein" author="Willem" icon="mdi:discord"></doc-comment>
|
|
365
346
|
</doc-comments>
|
|
366
347
|
|
|
348
|
+
# Roadmap
|
|
349
|
+
|
|
350
|
+
Of course, we're not done yet! We plan on adding the following features to Paraglide JS in the upcoming weeks:
|
|
351
|
+
|
|
352
|
+
- [ ] Pluralization ([Join the Discussion](https://github.com/opral/monorepo/discussions/2025))
|
|
353
|
+
- [ ] Formatting of numbers and dates ([Join the Discussion](https://github.com/opral/monorepo/discussions/992))
|
|
354
|
+
- [ ] Markup Placeholders ([Join the Discussion](https://github.com/opral/monorepo/discussions/913))
|
|
355
|
+
|
|
367
356
|
# Talks
|
|
368
357
|
|
|
369
358
|
- [Svelte Summit Spring 2023](https://www.youtube.com/watch?v=Y6IbPfMU1xM)
|
|
370
359
|
- [Svelte Summit Fall 2023](https://www.youtube.com/watch?v=-YES3CCAG90)
|
|
371
360
|
- Web Zurich December 2023
|
|
372
361
|
- [Svelte London January 2024](https://www.youtube.com/watch?v=eswNQiq4T2w&t=646s)
|
|
362
|
+
|
|
363
|
+
# Pricing
|
|
364
|
+
|
|
365
|
+
<doc-dev-tool-pricing></doc-dev-tool-pricing>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/default/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/default/why.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
Paraglide is a CLI at it's heart & therefore doesn't have a real JS entry point. This
|
|
2
|
+
means that NPM doesn't show the TS icon on the package, which may lead people to believe
|
|
3
|
+
it's not typesafe. To sidestep this we added an empty export. We don't think this is dishonest,
|
|
4
|
+
because both paraglide's source code and it's output are fully typed.
|
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { type ProjectSettings } from "@inlang/sdk";
|
|
3
3
|
import { Logger } from "../../services/logger/index.js";
|
|
4
|
+
import { type Repository } from "@lix-js/client";
|
|
5
|
+
import type { NodeishFilesystem } from "@lix-js/fs";
|
|
6
|
+
type Context = {
|
|
7
|
+
logger: Logger;
|
|
8
|
+
repo: Repository;
|
|
9
|
+
};
|
|
4
10
|
export declare const initCommand: Command;
|
|
5
|
-
export declare const initializeInlangProject: (
|
|
11
|
+
export declare const initializeInlangProject: (ctx: Context) => Promise<string>;
|
|
6
12
|
export declare const maybeAddVsCodeExtension: (args: {
|
|
7
13
|
projectPath: string;
|
|
8
|
-
},
|
|
9
|
-
export declare const addParaglideJsToDevDependencies: (
|
|
10
|
-
export declare const findExistingInlangProjectPath: () => Promise<string | undefined>;
|
|
14
|
+
}, ctx: Context) => Promise<void>;
|
|
15
|
+
export declare const addParaglideJsToDevDependencies: (ctx: Context) => Promise<void>;
|
|
16
|
+
export declare const findExistingInlangProjectPath: (ctx: Context) => Promise<string | undefined>;
|
|
11
17
|
export declare const existingProjectFlow: (args: {
|
|
12
18
|
existingProjectPath: string;
|
|
13
|
-
},
|
|
14
|
-
export declare const createNewProjectFlow: (
|
|
19
|
+
}, ctx: Context) => Promise<undefined>;
|
|
20
|
+
export declare const createNewProjectFlow: (ctx: Context) => Promise<undefined>;
|
|
15
21
|
export declare const newProjectTemplate: ProjectSettings;
|
|
16
|
-
export declare const checkIfPackageJsonExists: (
|
|
17
|
-
export declare const checkIfUncommittedChanges: (
|
|
22
|
+
export declare const checkIfPackageJsonExists: (ctx: Context) => Promise<undefined>;
|
|
23
|
+
export declare const checkIfUncommittedChanges: (ctx: Context) => Promise<void>;
|
|
18
24
|
export declare const addCompileStepToPackageJSON: (args: {
|
|
19
25
|
projectPath: string;
|
|
20
|
-
},
|
|
26
|
+
}, ctx: Context) => Promise<undefined>;
|
|
21
27
|
/**
|
|
22
28
|
* Ensures that the moduleResolution compiler option is set to "bundler" or similar in the tsconfig.json.
|
|
23
29
|
*
|
|
24
30
|
* Otherwise, types defined in `package.exports` are not resolved by TypeScript. Leading to type
|
|
25
31
|
* errors with Paraglide-JS.
|
|
26
32
|
*/
|
|
27
|
-
export declare const maybeChangeTsConfigModuleResolution: (
|
|
33
|
+
export declare const maybeChangeTsConfigModuleResolution: (ctx: Context) => Promise<void>;
|
|
28
34
|
/**
|
|
29
35
|
* Paraligde JS compiles to JS with JSDoc comments. TypeScript doesn't allow JS files by default.
|
|
30
36
|
*/
|
|
31
|
-
export declare const maybeChangeTsConfigAllowJs: (
|
|
37
|
+
export declare const maybeChangeTsConfigAllowJs: (ctx: Context) => Promise<void>;
|
|
38
|
+
export declare function fileExists(filePath: string, nodeishFs: NodeishFilesystem): Promise<boolean>;
|
|
39
|
+
export {};
|