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: website/docs/misc/community.md
+15-12Lines changed: 15 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,33 +1,36 @@
1
1
---
2
2
title: Community and Contributing
3
+
description: Learn how to connect with the Lingui community and contribute to the project
3
4
---
4
5
6
+
For any open-source project, the community is the backbone of success. It's the community that drives growth, provides valuable feedback, and contributes to the project in countless ways.
7
+
5
8
## Community
6
9
7
10
Lingui has a significant number of developers as a part of its community.
8
11
9
-
On this page we've listed some Lingui-related communities that you can be a part of; see the other pages in this section for additional online and in-person learning materials.
10
-
11
-
Before participating in Lingui's communities, please read our [Code of Conduct](https://github.com/lingui/js-lingui/blob/main/CODE_OF_CONDUCT.md). We expect that all community members adhere to the guidelines within.
12
+
On this page, you'll find links to various Lingui-related communities you can join, as well as additional resources for learning and collaboration. Be sure to explore the other pages in this section for more learning opportunities.
12
13
13
-
### Stack Overflow
14
-
15
-
Stack Overflow is a popular forum to ask code-level questions or if you're stuck with a specific error. Read through the [existing questions](https://stackoverflow.com/questions/tagged/linguijs) tagged with `linguijs` or [ask your own](https://stackoverflow.com/questions/ask?tags=linguijs)!
14
+
Before participating, please take a moment to review our [Code of Conduct](https://github.com/lingui/js-lingui/blob/main/CODE_OF_CONDUCT.md). We expect all members to follow these guidelines to ensure a positive and welcoming environment for everyone.
16
15
17
-
### Discussion forums
16
+
### Discussion Forums
18
17
19
-
The [Lingui Discord server](https://discord.gg/gFWwAYnMtA) is a place where you can learn, share, and collaborate about anything and everything Lingui.
18
+
The [Lingui Discord Server](https://discord.gg/gFWwAYnMtA) is a place where you can learn, share, and collaborate about anything and everything Lingui.
20
19
21
20

22
21
23
-
- Connect with users from the community.
22
+
- Connect with users in the community.
24
23
- Get your questions answered and learn cool new tips and tricks.
25
-
- Watch for notifications of new content from Lingui and the community.
26
-
- Share your knowledge and expertise with others.
24
+
- Get notifications about new content from Lingui and the community.
25
+
- Share your knowledge and experience with others.
26
+
27
+
### Stack Overflow
28
+
29
+
Stack Overflow is a popular forum to ask code-level questions or if you're stuck with a specific error. Read through the [existing questions](https://stackoverflow.com/questions/tagged/linguijs) tagged with `linguijs` or [ask your own](https://stackoverflow.com/questions/ask?tags=linguijs)!
27
30
28
31
### News
29
32
30
-
For the latest news about Lingui, follow [@LinguiJS](https://twitter.com/LinguiJS) on Twitter.
33
+
For the latest news about Lingui, follow [@LinguiJS](https://x.com/LinguiJS) on X.
@@ -5,11 +5,13 @@ description: Comparison of Lingui and i18next internationalization libraries
5
5
6
6
# Comparison with i18next
7
7
8
-
[i18next](https://www.i18next.com/) is an internationalization-framework written in and for JavaScript. i18next and Lingui are two popular internationalization (i18n) libraries used for translating and localizing JS-based applications. Both libraries have their strengths and weaknesses, and which one is best for a particular project depends on the project's specific needs.
8
+
[i18next](https://www.i18next.com/) is a widely used internationalizationframework designed specifically for JavaScript applications. Both i18next and Lingui are popular libraries for translating and localizing JavaScript-based projects, each offering unique strengths and features.
9
9
10
-
## Basic comparison
10
+
The choice between them ultimately depends on the specific needs of your project.
Since the Lingui v4 release, there is a core function [i18n.t(...)](/docs/ref/core.md#i18n.t) that allows doing pretty much the same thing. The following example shows how this works with Lingui:
37
+
The equivalent example with Lingui looks like this:
The `message` property can be specified in the case of [Message Extraction](/docs/guides/message-extraction.md) usage flow. You can use the `i18n.t` function only with the `id`, but in this case you'll have to manage your localization catalogs yourself, without advantages of the [message extraction](/docs/guides/message-extraction.md) feature.
59
+
:::tip
60
+
This example uses a macro for the translation. Macros are a powerful feature of Lingui that allows youto write messages directly in your code. Read more about [Macros](/docs/ref/macro.mdx).
55
61
:::
56
62
63
+
If you prefer to define explicit IDs for your messages, you can follow this approach:
Read more about [Explicit vs Generated Message IDs](/docs/guides/explicit-vs-generated-ids.md).
72
+
57
73
## Interpolation
58
74
59
-
Interpolation is one of the most used functionalities in I18N. It allows integrating dynamic values into your translations.
75
+
Interpolation is a key internationalization (i18n) feature that allows you to insert dynamic values into your translations. Both Lingui and i18next support interpolation.
60
76
61
77
i18next sample:
62
78
63
79
```js
80
+
importi18nextfrom"i18next";
81
+
82
+
i18next.t("My name is {name}", { name:"Tom" });
64
83
i18next.t("msg.name", { name:"Tom" });
65
84
```
66
85
67
86
Lingui sample:
68
87
69
88
```js
70
-
i18n._({ id:"msg.name", message:"My name is {name}", values: { name:"Tom" } });
89
+
import { t } from"@lingui/core/macro";
90
+
91
+
constname="Tom";
92
+
93
+
t`My name is ${name}`;
94
+
t({ id:"msg.name", message:`My name is ${name}` });
71
95
```
72
96
73
97
## Formatting
74
98
75
-
Both the Lingui and i18next formatting functions are based on the [Intl API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).
99
+
Both Lingui and i18next formatting functions are based on the [Intl API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).
Lingui uses the ICU MessageFormat syntax to handle plurals. It provides a simple and translator-friendly approach to plurals localization.
183
+
Lingui uses the [ICU MessageFormat](/docs/guides/message-format.md) syntax to handle plurals. It provides a simple and translator-friendly approach to plurals localization.
151
184
152
185
For example:
153
186
@@ -158,7 +191,7 @@ plural(numBooks, {
158
191
});
159
192
```
160
193
161
-
Under the hood, pluralis replaced with low-level `i18n._`. For production, the above example will become:
194
+
Under the hood, the [`plural`](/docs/ref/macro.mdx#plural) macro is replaced with a low-level [`i18n._`](/docs/ref/core.md#i18n._) call. In production, the example will look like this:
162
195
163
196
```js
164
197
i18n._({
@@ -169,7 +202,7 @@ i18n._({
169
202
});
170
203
```
171
204
172
-
When we extract messages from source code using Lingui CLI, we get:
205
+
When we extract messages from the source code using the [Lingui CLI](/docs/ref/cli.md), we get:
173
206
174
207
```icu-message-format
175
208
{numBooks, plural, one {# book} other {# books}}
@@ -185,37 +218,91 @@ i18next handles plurals differently. It requires a separate key to be defined fo
185
218
```
186
219
187
220
```js
221
+
importi18nextfrom"i18next";
222
+
188
223
i18next.t("key", { count:0 }); // -> "items"
189
224
i18next.t("key", { count:1 }); // -> "item"
190
225
i18next.t("key", { count:5 }); // -> "items"
191
226
```
192
227
193
228
## Context
194
229
195
-
By providing a context you can differ translations. Both i18next and Lingui have the context feature to differentiate messages.
230
+
By providing context, you can differentiate translations for the same sentences or provide translators with more details. Both i18next and Lingui have the context feature to differentiate messages.
196
231
197
-
## Summary
232
+
i18next sample:
198
233
199
-
This is a rather short comparison. Both libraries have quite different concepts, but at the same time the core internationalization approaches are similar and use the same background.
234
+
```js
235
+
importi18nextfrom"i18next";
236
+
237
+
i18next.t("Right", { context:"direction" });
238
+
```
239
+
240
+
Lingui sample:
241
+
242
+
```js
243
+
import { msg } from"@lingui/core/macro";
244
+
245
+
msg({
246
+
message:"Right",
247
+
context:"direction",
248
+
});
249
+
```
250
+
251
+
:::tip
252
+
Lingui automatically provides additional context by including in the `.po` file the locations where each message is used, and `msgctxt` if the context is specified. This is useful for translators to understand the context of the message:
253
+
254
+
```gettext title="en.po"
255
+
#: src/App.js:5
256
+
msgctxt "direction"
257
+
msgid "Right"
258
+
msgstr "Right"
259
+
```
260
+
261
+
i18next can't do this from its plain JSON files.
262
+
:::
200
263
201
-
On top of that, [Lingui](https://github.com/lingui/js-lingui):
264
+
## React Integration
265
+
266
+
Both libraries provide React components for handling translations in React applications. Lingui provides a set of [React Macros](/docs/ref/macro.mdx#react-macros) that simplify writing messages directly in your code. i18next provides a `Trans` component to handle translations in JSX.
- provides macros to simplify writing messages using MessageFormat syntax
205
-
- provides a CLI for extracting and compiling messages
206
-
- supports a number of [Catalog formats](/docs/ref/catalog-formats.md), including [Custom Formatters](/docs/guides/custom-formatter.md)
207
-
- is very small (**3kb** gzipped), fast, flexible, and stable
208
-
- works for vanilla JS, Next.js, Vue.js, Node.js etc.
209
-
- is actively maintained.
290
+
This is a rather brief comparison. Both libraries have quite different concepts, but at the same time the core internationalization approaches are similar and use the same background.
210
291
211
-
On the other hand, [i18next](https://www.i18next.com/):
292
+
**On top of that, Lingui:**
212
293
213
-
- mature. Based on how long i18next already is available open source, there is no real i18n case that could not be solved with i18next
214
-
- extensible
215
-
- has a big ecosystem.
294
+
- Supports rich-text messages.
295
+
- Provides macros to simplify writing messages using ICU MessageFormat syntax.
296
+
- Provides a CLI tool for extracting and compiling messages.
297
+
- Supports a number of [Catalog Formats](/docs/ref/catalog-formats.md), including [Custom Formatters](/docs/guides/custom-formatter.md).
298
+
- Is very small, fast, flexible, and stable.
299
+
- Works with vanilla JS, React (including RSC), Next.js, Node.js, Vue.js etc.
300
+
- Is actively maintained.
216
301
217
-
Lingui is a great choice for projects that require modern and efficient translation approaches, support for popular frameworks, and tools for managing translations. However, whether Lingui is better than i18next or not depends on the specific needs of the project.
302
+
**On the other hand, i18next:**
218
303
219
-
## Discussion
304
+
- Is mature. Based on how long i18next has been open source, there is no real i18n case that cannot be solved with i18next.
305
+
- Is extensible, with many plugins and tools developed by other contributors, including extractors, locale identifiers, etc.
306
+
- Has a big ecosystem.
220
307
221
-
Do you have any comments or questions? Please join the discussion at [GitHub](https://github.com/lingui/js-lingui/discussions) or raise an [issue](https://github.com/lingui/js-lingui/issues/new). All feedback is welcome!
308
+
In conclusion, Lingui is an excellent option for projects that need modern and efficient translation methods, support for popular frameworks, and effective translation management tools. However, the choice between Lingui and i18next ultimately depends on the specific requirements of your project.
0 commit comments