@inlang/paraglide-js 1.1.0 → 1.1.1
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 +14 -14
- package/dist/index.js +27 -13
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!--  -->
|
|
2
2
|
|
|
3
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
4
|
|
|
@@ -17,14 +17,14 @@ npx @inlang/paraglide-js@latest init
|
|
|
17
17
|
# Features
|
|
18
18
|
|
|
19
19
|
<doc-features>
|
|
20
|
-
<doc-feature title="No unused translations" image="https://cdn.jsdelivr.net/gh/
|
|
21
|
-
<doc-feature title="Reduced payload" image="https://cdn.jsdelivr.net/gh/
|
|
22
|
-
<doc-feature title="Typesafety" image="https://cdn.jsdelivr.net/gh/
|
|
20
|
+
<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="Reduced payload" image="https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/reduced-payload.png"></doc-feature>
|
|
22
|
+
<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
23
|
</doc-features>
|
|
24
24
|
|
|
25
25
|
### Treeshaking
|
|
26
26
|
|
|
27
|
-
<doc-figure src="https://cdn.jsdelivr.net/gh/
|
|
27
|
+
<doc-figure src="https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/tree-shaking.jpg" alt="An illustration explaining the benefits of treeshaking in software" caption="How Paraglide JS treeshaking works">
|
|
28
28
|
</doc-figure>
|
|
29
29
|
|
|
30
30
|
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.
|
|
@@ -42,13 +42,13 @@ npx @inlang/paraglide-js@latest init
|
|
|
42
42
|
|
|
43
43
|
### 2. Select an adapter (if required)
|
|
44
44
|
|
|
45
|
-
Having an adapter is
|
|
45
|
+
Having an adapter is recommended but not required if you want to use paraglide-js with a framework. If you don't use a framework, you can skip this step.
|
|
46
46
|
|
|
47
47
|
<doc-links>
|
|
48
|
-
<doc-link title="Adapter for Svelte" icon="simple-icons:svelte" href="https://github.com/
|
|
48
|
+
<doc-link title="Adapter for Svelte" icon="simple-icons:svelte" href="https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-svelte/example" description="Go to GitHub example"></doc-link>
|
|
49
49
|
<doc-link title="Adapter for SolidJS" icon="tabler:brand-solidjs" href="https://inlang.com/m/n860p17j/library-inlang-paraglideJsAdapterSolidStart" description="Go to Adapter"></doc-link>
|
|
50
|
-
<doc-link title="Adapter for NextJS" icon="tabler:brand-nextjs" href="https://github.com/
|
|
51
|
-
<doc-link title="Adapter for Vite" icon="tabler:brand-vite" href="https://github.com/
|
|
50
|
+
<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
|
+
<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
52
|
</doc-links>
|
|
53
53
|
|
|
54
54
|
#### Alternatively, [you can write your own adapter](#writing-an-adapter)
|
|
@@ -179,9 +179,9 @@ const msg = m.hello({ name: "Samuel" }, { languageTag: "de" }) // Hallo Samuel!
|
|
|
179
179
|
We provide a few bundler plugins to make it easier to use paraglide-js with a bundler. If you
|
|
180
180
|
are using one of these bundlers, we recommed using the corresponding plugin.
|
|
181
181
|
|
|
182
|
-
- [Rollup](https://github.com/
|
|
183
|
-
- [Webpack](https://github.com/
|
|
184
|
-
- [Vite](https://github.com/
|
|
182
|
+
- [Rollup](https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-rollup)
|
|
183
|
+
- [Webpack](https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-webpack)
|
|
184
|
+
- [Vite](https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-vite)
|
|
185
185
|
|
|
186
186
|
These plugins make sure to rerun the `compile` script whenever you build your project. That way you don't need to modify your build script in `package.json`. If you are using a bundler with a dev-server, like Vite, the plugins also make sure to rerun the `compile` script whenever your messages change.
|
|
187
187
|
|
|
@@ -199,7 +199,7 @@ Inlang Paraglide JS leverages a compiler to emit vanilla JavaScript functions.
|
|
|
199
199
|
|
|
200
200
|
The emitted functions are often referred to as "message functions". By emitting message functions, inlang Paraglide JS eliminates a 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 1kb gzipped.
|
|
201
201
|
|
|
202
|
-

|
|
203
203
|
|
|
204
204
|
Inlang Paraglide-JS consists of four main parts:
|
|
205
205
|
|
|
@@ -355,7 +355,7 @@ render((page) => (
|
|
|
355
355
|
# Community
|
|
356
356
|
|
|
357
357
|
We are grateful for all the support we get from the community. Here are just a few of the comments we've received over the last few weeks.
|
|
358
|
-
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/
|
|
358
|
+
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
359
|
|
|
360
360
|
<doc-comments>
|
|
361
361
|
<doc-comment text="The lib is great guys!" author="ktarmyshov" icon="mdi:github"></doc-comment>
|
package/dist/index.js
CHANGED
|
@@ -6019,7 +6019,7 @@ var MessageLintRule = import_typebox4.Type.Object({
|
|
|
6019
6019
|
/**
|
|
6020
6020
|
* Tyepbox is must be used to validate the Json Schema.
|
|
6021
6021
|
* Github discussion to upvote a plain Json Schema validator and read the benefits of Typebox
|
|
6022
|
-
* https://github.com/
|
|
6022
|
+
* https://github.com/opral/monorepo/discussions/1503
|
|
6023
6023
|
*/
|
|
6024
6024
|
settingsSchema: import_typebox4.Type.Optional(import_typebox4.Type.Object({}, { additionalProperties: true }))
|
|
6025
6025
|
});
|
|
@@ -6119,7 +6119,7 @@ var Plugin = import_typebox6.Type.Object({
|
|
|
6119
6119
|
/**
|
|
6120
6120
|
* Tyepbox is must be used to validate the Json Schema.
|
|
6121
6121
|
* Github discussion to upvote a plain Json Schema validator and read the benefits of Typebox
|
|
6122
|
-
* https://github.com/
|
|
6122
|
+
* https://github.com/opral/monorepo/discussions/1503
|
|
6123
6123
|
*/
|
|
6124
6124
|
settingsSchema: import_typebox6.Type.Optional(import_typebox6.Type.Object({}, { additionalProperties: true })),
|
|
6125
6125
|
loadMessages: import_typebox6.Type.Optional(import_typebox6.Type.Any()),
|
|
@@ -8030,9 +8030,9 @@ The \`project.inlang.json\` file is now contained in a project directory e.g. \`
|
|
|
8030
8030
|
## Why is this happening?
|
|
8031
8031
|
|
|
8032
8032
|
See this RFC https://docs.google.com/document/d/1OYyA1wYfQRbIJOIBDliYoWjiUlkFBNxH_U2R4WpVRZ4/edit#heading=h.pecv6xb7ial6
|
|
8033
|
-
and the following GitHub issue for more information https://github.com/
|
|
8033
|
+
and the following GitHub issue for more information https://github.com/opral/monorepo/issues/1678.
|
|
8034
8034
|
|
|
8035
|
-
- Monorepo support https://github.com/
|
|
8035
|
+
- Monorepo support https://github.com/opral/monorepo/discussions/258.
|
|
8036
8036
|
- Required for many other future features like caching, first class offline support, and more.
|
|
8037
8037
|
- Stablize the inlang project format.
|
|
8038
8038
|
`;
|
|
@@ -8220,7 +8220,7 @@ Valid examples:
|
|
|
8220
8220
|
displayName: rule.displayName,
|
|
8221
8221
|
description: rule.description,
|
|
8222
8222
|
module: ((_b = (_a = resolvedModules()) == null ? void 0 : _a.meta.find((m) => m.id.includes(rule.id))) == null ? void 0 : _b.module) ?? "Unknown module. You stumbled on a bug in inlang's source code. Please open an issue.",
|
|
8223
|
-
// default to warning, see https://github.com/
|
|
8223
|
+
// default to warning, see https://github.com/opral/monorepo/issues/1254
|
|
8224
8224
|
level: ((_c = settingsValue["messageLintRuleLevels"]) == null ? void 0 : _c[rule.id]) ?? "warning"
|
|
8225
8225
|
};
|
|
8226
8226
|
});
|
|
@@ -8849,9 +8849,11 @@ function reexportMessage(messageId, fromLanguageTag) {
|
|
|
8849
8849
|
}
|
|
8850
8850
|
function messageIdFallback(messageId, languageTag) {
|
|
8851
8851
|
return `/**
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8852
|
+
* Failed to resolve message ${messageId} for languageTag "${languageTag}".
|
|
8853
|
+
* @returns {string}
|
|
8854
|
+
*/
|
|
8855
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
8856
|
+
export const ${messageId} = () => "${escapeForDoubleQuoteString(messageId)}"`;
|
|
8855
8857
|
}
|
|
8856
8858
|
|
|
8857
8859
|
// src/services/telemetry/implementation.ts
|
|
@@ -8886,7 +8888,7 @@ function getPrivateEnvVariables() {
|
|
|
8886
8888
|
|
|
8887
8889
|
// ../../env-variables/dist/runtime/publicEnv.js
|
|
8888
8890
|
init_define_ENV_DEFINED_IN_BUILD_STEP();
|
|
8889
|
-
var define_PUBLIC_ENV_DEFINED_IN_BUILD_STEP_default = { PUBLIC_IS_DEV: "false", PUBLIC_GIT_PROXY_BASE_URL: "https://git.inlang.com", PUBLIC_POSTHOG_TOKEN: "phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz", PUBLIC_ALLOWED_AUTH_URLS: "https://inlang.com,https://manage.inlang.com,https://fink.inlang.com", PUBLIC_SERVER_BASE_URL: "https://inlang.com", PUBLIC_WEBSITE_SENTRY_DSN: "https://6ba3cb3bad464dd9a7f8700ed636c07a@o4504345873285120.ingest.sentry.io/4504346044006400", PUBLIC_LIX_GITHUB_APP_NAME: "inlang", PUBLIC_LIX_GITHUB_APP_CLIENT_ID: "Iv1.436da58906364f96" };
|
|
8891
|
+
var define_PUBLIC_ENV_DEFINED_IN_BUILD_STEP_default = { PUBLIC_IS_DEV: "false", PUBLIC_GIT_PROXY_BASE_URL: "https://git.inlang.com", PUBLIC_POSTHOG_TOKEN: "phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz", PUBLIC_ALLOWED_AUTH_URLS: "https://inlang.com,https://manage.inlang.com,https://fink.inlang.com", PUBLIC_SERVER_BASE_URL: "https://inlang.com", PUBLIC_WEBSITE_SENTRY_DSN: "https://6ba3cb3bad464dd9a7f8700ed636c07a@o4504345873285120.ingest.sentry.io/4504346044006400", PUBLIC_HCAPTCHA_SITEKEY: "353a039d-fc34-40a6-a81d-91720e8851b0", PUBLIC_LIX_GITHUB_APP_NAME: "inlang", PUBLIC_LIX_GITHUB_APP_CLIENT_ID: "Iv1.436da58906364f96" };
|
|
8890
8892
|
var publicEnv = new Proxy({}, {
|
|
8891
8893
|
get(target, prop) {
|
|
8892
8894
|
if (typeof prop === "string" && prop.startsWith("PUBLIC_") === false) {
|
|
@@ -12652,7 +12654,8 @@ var publicEnvVariablesSchema = z.object({
|
|
|
12652
12654
|
PUBLIC_WEBSITE_SENTRY_DSN: z.string().optional().describe("DSN for Sentry (in the browser)"),
|
|
12653
12655
|
PUBLIC_POSTHOG_TOKEN: z.string().optional(),
|
|
12654
12656
|
PUBLIC_SERVER_BASE_URL: z.string().url().regex(/^(?!.*\/$).+$/, "Must not end with a slash").describe("The base url of the server e.g. https://inlang.com"),
|
|
12655
|
-
PUBLIC_ALLOWED_AUTH_URLS: z.string().describe("List of allowed base urls eg https://inlang.com,https://manage.inlang.com")
|
|
12657
|
+
PUBLIC_ALLOWED_AUTH_URLS: z.string().describe("List of allowed base urls eg https://inlang.com,https://manage.inlang.com"),
|
|
12658
|
+
PUBLIC_HCAPTCHA_SITEKEY: z.string().describe("The sitekey to https://www.hcaptcha.com/")
|
|
12656
12659
|
});
|
|
12657
12660
|
var privateEnvVariablesSchema = z.object({
|
|
12658
12661
|
LIX_GITHUB_APP_CLIENT_SECRET: z.string(),
|
|
@@ -13078,6 +13081,7 @@ var version = (() => {
|
|
|
13078
13081
|
})();
|
|
13079
13082
|
|
|
13080
13083
|
// src/cli/commands/init.ts
|
|
13084
|
+
import dedent2 from "dedent";
|
|
13081
13085
|
var DEFAULT_PROJECT_PATH = "./project.inlang";
|
|
13082
13086
|
var initCommand = new Command2().name("init").summary("Initializes inlang Paraglide-JS.").action(async () => {
|
|
13083
13087
|
const logger = new Logger({ silent: false, prefix: false });
|
|
@@ -13095,8 +13099,18 @@ var initCommand = new Command2().name("init").summary("Initializes inlang Paragl
|
|
|
13095
13099
|
await maybeChangeTsConfigAllowJs(logger);
|
|
13096
13100
|
await maybeAddVsCodeExtension({ projectPath }, logger);
|
|
13097
13101
|
telemetry.capture({ event: "PARAGLIDE-JS init finished" });
|
|
13102
|
+
const absoluteSettingsPath = resolve2(projectPath, "settings.json");
|
|
13103
|
+
const relativeSettingsFilePath = absoluteSettingsPath.replace(process.cwd(), ".");
|
|
13098
13104
|
logger.box(
|
|
13099
|
-
|
|
13105
|
+
dedent2`inlang Paraglide-JS has been set up sucessfully.
|
|
13106
|
+
|
|
13107
|
+
1. Run your install command (npm i, yarn install, etc)
|
|
13108
|
+
2. Register all your languages in ${relativeSettingsFilePath}
|
|
13109
|
+
3. Run the build script (npm run build, or similar.)
|
|
13110
|
+
4. Done :) Happy paragliding 🪂
|
|
13111
|
+
|
|
13112
|
+
For questions and feedback, visit https://github.com/inlang/monorepo/discussions.
|
|
13113
|
+
`
|
|
13100
13114
|
);
|
|
13101
13115
|
});
|
|
13102
13116
|
var initializeInlangProject = async (logger) => {
|
|
@@ -13207,7 +13221,7 @@ var createNewProjectFlow = async (logger) => {
|
|
|
13207
13221
|
});
|
|
13208
13222
|
if (project.errors().length > 0) {
|
|
13209
13223
|
logger.warn(
|
|
13210
|
-
"Failed to create a new inlang project.\n\nThis is likely an internal bug. Please file an issue at https://github.com/
|
|
13224
|
+
"Failed to create a new inlang project.\n\nThis is likely an internal bug. Please file an issue at https://github.com/opral/monorepo."
|
|
13211
13225
|
);
|
|
13212
13226
|
for (const error of project.errors()) {
|
|
13213
13227
|
logger.error(error);
|
|
@@ -13237,7 +13251,7 @@ var newProjectTemplate = {
|
|
|
13237
13251
|
],
|
|
13238
13252
|
"plugin.inlang.messageFormat": {
|
|
13239
13253
|
// using .inlang/paraglide-js as directory to avoid future conflicts when an official .inlang
|
|
13240
|
-
// directory is introduced, see https://github.com/
|
|
13254
|
+
// directory is introduced, see https://github.com/opral/monorepo/discussions/1418
|
|
13241
13255
|
pathPattern: "./messages/{languageTag}.json"
|
|
13242
13256
|
}
|
|
13243
13257
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inlang/paraglide-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"isomorphic-git": "1.24.5",
|
|
38
38
|
"json5": "2.2.3",
|
|
39
39
|
"posthog-node": "3.1.3",
|
|
40
|
-
"@inlang/
|
|
41
|
-
"@inlang/
|
|
40
|
+
"@inlang/detect-json-formatting": "1.0.0",
|
|
41
|
+
"@inlang/language-tag": "1.3.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@rollup/plugin-terser": "0.4.3",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"typescript": "5.2.2",
|
|
54
54
|
"vitest": "0.34.3",
|
|
55
55
|
"@inlang/telemetry": "0.3.3",
|
|
56
|
-
"@inlang/sdk": "0.22.0",
|
|
57
56
|
"@lix-js/fs": "0.5.0",
|
|
58
|
-
"@inlang/env-variables": "0.2.0"
|
|
57
|
+
"@inlang/env-variables": "0.2.0",
|
|
58
|
+
"@inlang/sdk": "0.22.0"
|
|
59
59
|
},
|
|
60
60
|
"exports": {
|
|
61
61
|
"./internal": {
|