@inlang/paraglide-js 2.15.0 → 2.15.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
CHANGED
|
@@ -148,13 +148,14 @@ Message format is **plugin-based** — use the default inlang format, or switch
|
|
|
148
148
|
|
|
149
149
|
## Comparison
|
|
150
150
|
|
|
151
|
-
| Feature
|
|
152
|
-
|
|
|
153
|
-
| **i18n bundle size**
|
|
154
|
-
| **Tree-shakable**
|
|
155
|
-
| **Typesafe**
|
|
156
|
-
| **Framework agnostic**
|
|
157
|
-
| **i18n routing**
|
|
151
|
+
| Feature | Paraglide | i18next | react-intl |
|
|
152
|
+
| -------------------------- | ---------------------------------- | --------------------- | --------------------- |
|
|
153
|
+
| **i18n bundle size** | Up to 70% smaller via tree-shaking | ❌ Ships all messages | ❌ Ships all messages |
|
|
154
|
+
| **Tree-shakable** | ✅ | ❌ | ❌ |
|
|
155
|
+
| **Typesafe** | ✅ | Partial | ❌ |
|
|
156
|
+
| **Framework agnostic** | ✅ | Wrappers needed | React only |
|
|
157
|
+
| **i18n routing** | ✅ Built-in | ❌ | ❌ |
|
|
158
|
+
| **ICU MessageFormat 1** | ✅ [Via plugin](https://inlang.com/m/p7c8m1d2/plugin-inlang-icu-messageformat-1) | ✅ | ✅ |
|
|
158
159
|
|
|
159
160
|
**[Full Comparison →](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/comparison)**
|
|
160
161
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-readme.d.ts","sourceRoot":"","sources":["../../src/compiler/create-readme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"create-readme.d.ts","sourceRoot":"","sources":["../../src/compiler/create-readme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAuJnE"}
|
|
@@ -89,6 +89,59 @@ await compile({
|
|
|
89
89
|
|
|
90
90
|
See the [strategy documentation](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/strategy) for details.
|
|
91
91
|
|
|
92
|
+
## Markup (Rich Text)
|
|
93
|
+
|
|
94
|
+
Messages can contain markup tags for bold, links, and other inline elements. Translators control where tags appear; developers control how they render.
|
|
95
|
+
|
|
96
|
+
### Message syntax
|
|
97
|
+
|
|
98
|
+
\`\`\`json
|
|
99
|
+
{
|
|
100
|
+
"cta": "{#link to=|/docs|}Read the docs{/link}",
|
|
101
|
+
"bold_text": "This is {#bold}important{/bold}"
|
|
102
|
+
}
|
|
103
|
+
\`\`\`
|
|
104
|
+
|
|
105
|
+
- \`{#tagName}\` opens a tag, \`{/tagName}\` closes it.
|
|
106
|
+
- Options: \`to=|/docs|\` (accessed via \`options.to\`).
|
|
107
|
+
- Attributes: \`@track\` (boolean, accessed via \`attributes.track\`).
|
|
108
|
+
|
|
109
|
+
This is the default inlang message syntax. Paraglide's message format is plugin-based — you can use [ICU MessageFormat 1](https://inlang.com/m/p7c8m1d2/plugin-inlang-icu-messageformat-1), [i18next](https://inlang.com/m/3i8bor92/plugin-inlang-i18next), or other [plugins](https://inlang.com/c/plugins) instead.
|
|
110
|
+
|
|
111
|
+
### Rendering markup
|
|
112
|
+
|
|
113
|
+
Calling \`m.cta()\` returns **plain text** (markup stripped). To render markup, use the framework adapter or the low-level \`parts()\` API:
|
|
114
|
+
|
|
115
|
+
\`\`\`js
|
|
116
|
+
const parts = m.cta.parts({});
|
|
117
|
+
// [
|
|
118
|
+
// { type: "markup-start", name: "link", options: { to: "/docs" }, attributes: {} },
|
|
119
|
+
// { type: "text", value: "Read the docs" },
|
|
120
|
+
// { type: "markup-end", name: "link" }
|
|
121
|
+
// ]
|
|
122
|
+
\`\`\`
|
|
123
|
+
|
|
124
|
+
Framework adapters provide a \`<ParaglideMessage>\` component that accepts markup renderers:
|
|
125
|
+
|
|
126
|
+
- \`@inlang/paraglide-js-react\`
|
|
127
|
+
- \`@inlang/paraglide-js-vue\`
|
|
128
|
+
- \`@inlang/paraglide-js-svelte\`
|
|
129
|
+
- \`@inlang/paraglide-js-solid\`
|
|
130
|
+
|
|
131
|
+
\`\`\`jsx
|
|
132
|
+
import { ParaglideMessage } from "@inlang/paraglide-js-react"; // or -vue, -svelte, -solid
|
|
133
|
+
|
|
134
|
+
<ParaglideMessage
|
|
135
|
+
message={m.cta}
|
|
136
|
+
inputs={{}}
|
|
137
|
+
markup={{
|
|
138
|
+
link: ({ children, options }) => <a href={options.to}>{children}</a>,
|
|
139
|
+
}}
|
|
140
|
+
/>
|
|
141
|
+
\`\`\`
|
|
142
|
+
|
|
143
|
+
See the [markup documentation](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/markup) for details.
|
|
144
|
+
|
|
92
145
|
## Key concepts
|
|
93
146
|
|
|
94
147
|
- **Tree-shakeable**: Each message is a function, enabling [up to 70% smaller i18n bundle sizes](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/benchmark) than traditional i18n libraries.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-readme.js","sourceRoot":"","sources":["../../src/compiler/create-readme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAA8B;IAC1D,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW;QACxC,CAAC,CAAC,sBAAsB,IAAI,CAAC,WAAW,MAAM;QAC9C,CAAC,CAAC,EAAE,CAAC;IAEN,OAAO;;;EAGN,gBAAgB
|
|
1
|
+
{"version":3,"file":"create-readme.js","sourceRoot":"","sources":["../../src/compiler/create-readme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAA8B;IAC1D,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW;QACxC,CAAC,CAAC,sBAAsB,IAAI,CAAC,WAAW,MAAM;QAC9C,CAAC,CAAC,EAAE,CAAC;IAEN,OAAO;;;EAGN,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8IjB,CAAC;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inlang/paraglide-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.15.
|
|
4
|
+
"version": "2.15.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@inlang/recommend-sherlock": "^0.2.1",
|
|
30
|
-
"@inlang/sdk": "^2.
|
|
30
|
+
"@inlang/sdk": "^2.9.1",
|
|
31
31
|
"commander": "11.1.0",
|
|
32
32
|
"consola": "3.4.0",
|
|
33
33
|
"json5": "2.2.3",
|