You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs/src/routes/docs/integrations/i18n/index.mdx
+89-91Lines changed: 89 additions & 91 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,8 @@ contributors:
7
7
- tzdesign
8
8
- Benny-Nottonson
9
9
- mrhoodz
10
-
updated_at: '2023-10-08T10:16:44Z'
10
+
- wmertens
11
+
updated_at: '2025-11-23T00:00:00Z'
11
12
created_at: '2023-04-19T22:13:46Z'
12
13
---
13
14
@@ -71,117 +72,114 @@ Our recommendation is to use a tool that would provide a runtime approach on the
71
72
72
73
## Internationalization Libraries
73
74
74
-
### $localize
75
+
### Paraglide JS
75
76
76
-
[$localize](https://angular.io/api/localize/init/$localize) the translation system is based on the $localize system from [Angular](https://angular.io/). The translations can be extracted in xmb, xlf, xlif, xliff, xlf2, xlif2, xliff2, and json formats.
77
+
[Paraglide JS](https://inlang.com/m/gerre34r/library-inlang-paraglideJs)is a compile-time translation library that generates type-safe translation functions from standard message format messages.
77
78
78
-
>NOTE: The $localize system is a compile-time translation system and is completely removed from the final output. $localize is a sub-project of Angular, and including its usage does not mean that Angular is used for rendering of applications.
79
+
#### Advantages
80
+
-**Tiny Runtime Overhead**: Translations are compiled to trivial functions.
81
+
-**Framework Agnostic**: Can be used with various frameworks, even within the same project.
82
+
-**Type-Safe Translations**: Generates type-safe functions for translations, reducing runtime errors
83
+
-**Lazy Loading**: Only the translations used by the application are bundled, optimizing bundle size.
84
+
-**Standard Message Format**: Supports complex message formatting using the widely adopted ICU message format.
85
+
-**Developed ecosystem**: Part of the inlang ecosystem, which provides additional tools and integrations for managing translations.
86
+
#### Disadvantages
87
+
-**Ships all languages**: The translations for all languages are included in the single build output, which may increase the overall bundle size.
88
+
-**No runtime features**: Lacks the possibility to add messages at runtime.
79
89
80
-
The easiest way to add $localize to Qwik is using the Qwik CLI command. This will install the required dependencies and create a new public route `/src/routes/[locale]` showcasing i18n $localize integration.
90
+
#### Installation
91
+
The easiest way to add Paraglide JS to Qwik is by following the [official guide for Vite](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/vite).
81
92
82
-
<PackageManagerTabs>
83
-
<spanq:slot="pnpm">
84
-
```shell
85
-
pnpm run qwik add localize
86
-
```
87
-
</span>
88
-
<spanq:slot="npm">
89
-
```shell
90
-
npm run qwik add localize
91
-
```
92
-
</span>
93
-
<spanq:slot="yarn">
94
-
```shell
95
-
yarn run qwik add localize
96
-
```
97
-
</span>
98
-
<spanq:slot="bun">
99
-
```shell
100
-
bun run qwik add localize
93
+
For further features like language switching and automatic translations, check the [documentation](https://inlang.com/m/gerre34r/library-inlang-paraglideJs).
94
+
95
+
#### Usage
96
+
Use the generated functions in your code:
97
+
98
+
```tsx
99
+
import*asmfrom'./src/paraglide/messages'
100
+
import { component$ } from'@builder.io/qwik';
101
+
102
+
exportdefaultcomponent$(() => {
103
+
return <p>{m.hello({name: 'World'})}</p>
104
+
})
101
105
```
102
-
</span>
103
-
</PackageManagerTabs>
104
106
105
-
For further reference, please check this [example repo](https://github.com/mhevery/qwik-i18n).
107
+
### compiled-i18n
106
108
107
-
#### Extract translations
109
+
[compiled-i18n](https://github.com/wmertens/compiled-i18n) is inspired by the $localize system from Angular. It only requires a plugin to be added to the Vite configuration.
108
110
109
-
When you are done with your changes, you can use the `i18n-extract` command to extract the translations from the code.
110
-
This will update the file you see in `package.json`.
111
+
It supports both runtime and compile-time translations.
111
112
112
-
<PackageManagerTabs>
113
-
<spanq:slot="pnpm">
114
-
```shell
115
-
pnpm run i18n-extract
116
-
```
117
-
</span>
118
-
<spanq:slot="npm">
119
-
```shell
120
-
npm run i18n-extract
121
-
```
122
-
</span>
123
-
<spanq:slot="yarn">
124
-
```shell
125
-
yarn run i18n-extract
126
-
```
127
-
</span>
128
-
<spanq:slot="bun">
129
-
```shell
130
-
bun run i18n-extract
131
-
```
132
-
</span>
133
-
</PackageManagerTabs>
113
+
#### Advantages
114
+
-**Zero Runtime Overhead (Compile-time mode)**: Translations are inlined at build time, resulting in no runtime cost for lookups.
115
+
-**Simplicity**: Minimal setup. Simple template string function API.
116
+
-**Framework Agnostic**: Can be used with various frameworks, even within the same project.
117
+
-**Flexible Approach**: Supports both runtime and compile-time modes, allowing developers to choose based on their needs.
118
+
-**Per-locale builds**: Compile-time mode inlines translations, eliminating runtime lookups. Server code includes all languages, simplifying deployment.
119
+
-**Automatic extraction**: Automatically adds new keys to translation files during build, and warns about missing and/or unused translations.
134
120
135
-
#### Auto translations for $localize with deepl
121
+
#### Disadvantages
122
+
-**Per-locale builds**: Compile-time mode requires separate builds for each locale, complicating deployment.
136
123
137
-
For auto translations, you can use the [deepl-localize](https://www.npmjs.com/package/deepl-localize) package. It will automatically translate your strings using the [deepl.com](https://deepl.com/) API.
124
+
#### Installation
125
+
Run `npx qwik add compiled-i18n` to add compiled-i18n to your Qwik app.
138
126
139
-
Use the `deepl-localize` command to translate your strings with:
127
+
See the [Qwik-specific instructions](https://github.com/wmertens/compiled-i18n/blob/main/docs/qwik.md) for more details.
bunx deepl-localize translate -b src/locales/message.en.json -l de-DE fr-FR -a "YOUR-DEEPL-API-KEY"
160
-
```
161
-
</span>
162
-
</PackageManagerTabs>
163
-
164
-
Alternatively, you can use the `deepl-localize` command to translate your strings within your script section:
165
-
```json
166
-
{
167
-
"scripts":{
168
-
"translate":"deepl-localize translate -b src/locales/message.en.json -l de-DE fr-FR -a 'your-deepl-api-key'"
169
-
}
170
-
}
171
-
```
129
+
Automatic translation is supported via [deepl-localize](https://github.com/tzdesign/deepl-localize).
172
130
173
-
### compiled-i18n
131
+
For further explanation of the API and features like pluralization, check the [documentation](https://github.com/wmertens/compiled-i18n/blob/main/Readme.md).
174
132
175
-
[compiled-i18n](https://github.com/wmertens/compiled-i18n) is inspired by the $localize system from Angular. It only requires a plugin to be added to the Vite configuration.
133
+
#### Usage
134
+
Use the template string function anywhere in your code:
176
135
177
-
It supports both runtime and compile-time translations.
136
+
```tsx
137
+
import {_} from'compiled-i18n'
178
138
179
-
See the [Qwik-specific instructions](https://github.com/wmertens/compiled-i18n/blob/main/docs/qwik.md).
139
+
console.log(_`Logenv ${process.env.NODE_ENV}`)
180
140
181
-
Automatic translation is supported via [deepl-localize](https://github.com/tzdesign/deepl-localize).
0 commit comments