Skip to content

Commit 52a80b5

Browse files
Merge remote-tracking branch 'origin/master' into minor
Catalog conflicts resolved by taking minor's message set with master's line-number stripping applied (PR 5075).
2 parents c9eba86 + 25d6558 commit 52a80b5

35 files changed

Lines changed: 57822 additions & 57753 deletions

File tree

bun.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/guides/extending-the-dashboard/localization/index.mdx

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ and the [useLingui hook](https://lingui.dev/ref/react#uselingui).
4444

4545
Create a `lingui.config.js` file in your project root, with references to any plugins that need to be localized:
4646

47-
```js title="lingui.config.js
47+
```js title="lingui.config.js"
4848
import { defineConfig } from '@lingui/cli';
4949

5050
export default defineConfig({
@@ -87,11 +87,58 @@ Since we set the "sourceLocale" to be "en", the `en.po` file will already be com
8787
open up the `de.po` file and add German translations for each of the strings, by filling out the empty `msgstr` values:
8888

8989
```text title="de.po"
90-
#: test-plugins/reviews/dashboard/review-list.tsx:51
90+
#: src/plugins/reviews/dashboard/review-list.tsx:51
9191
msgid "Welcome to Dashboard"
9292
msgstr "Willkommen zum Dashboard" # [!code highlight]
9393
```
9494

95+
## Reducing merge conflicts in your .po files
96+
97+
The `#:` comment above each message records where the string was found, down to the line number. Those
98+
line numbers are recalculated on every extraction, so any edit that shifts code up or down rewrites
99+
them — adding one import at the top of a file changes the recorded line of every string below it, even
100+
though none of the strings themselves changed.
101+
102+
If several people work on the same plugin, this can make the `.po` files a recurring source of merge
103+
conflicts that have nothing to do with the translations. You can turn the line numbers off by passing an
104+
explicit PO formatter to your config:
105+
106+
```js title="lingui.config.js"
107+
import { defineConfig } from '@lingui/cli';
108+
import { formatter } from '@lingui/format-po'; // [!code highlight]
109+
110+
export default defineConfig({
111+
sourceLocale: 'en',
112+
locales: ['en', 'de'],
113+
format: formatter({ lineNumbers: false }), // [!code highlight]
114+
catalogs: [
115+
{
116+
path: '<rootDir>/src/plugins/reviews/dashboard/i18n/{locale}',
117+
include: ['<rootDir>/src/plugins/reviews/dashboard/**'],
118+
},
119+
],
120+
});
121+
```
122+
123+
The references then keep the file path and drop the line number, which is usually enough context for a
124+
translator to find the string:
125+
126+
```text title="de.po"
127+
#: src/plugins/reviews/dashboard/review-list.tsx
128+
msgid "Welcome to Dashboard"
129+
msgstr "Willkommen zum Dashboard"
130+
```
131+
132+
The next `npx lingui extract` rewrites every reference in your catalogs, so expect one large diff when
133+
you first make this change. After that the references only change when a string genuinely moves to a
134+
different file.
135+
136+
:::note
137+
`formatter` comes from `@lingui/format-po`, which is installed as part of the Lingui CLI. If your package
138+
manager enforces strict dependency resolution (pnpm, or Yarn PnP), add it to your project explicitly with
139+
`npm install --save-dev @lingui/format-po`.
140+
:::
141+
95142
## Contributing a translation of the Dashboard itself
96143

97144
The sections above cover localizing **your own** extensions. If instead you want to translate the

docs/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@
650650
"title": "Localization",
651651
"slug": "localization",
652652
"file": "docs/guides/extending-the-dashboard/localization/index.mdx",
653-
"lastModified": "2026-07-23T09:49:01+02:00"
653+
"lastModified": "2026-07-31T11:47:50+02:00"
654654
},
655655
{
656656
"title": "Deployment",

packages/dashboard/lingui.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { defineConfig } from '@lingui/cli';
2+
import { formatter } from '@lingui/format-po';
23

34
export default defineConfig({
45
sourceLocale: 'en',
6+
// Line numbers in the `#:` reference comments churn on every unrelated edit
7+
// to a source file, which makes the catalogs a constant source of merge conflicts.
8+
format: formatter({ lineNumbers: false }),
59
locales: [
610
'he',
711
'ar',

packages/dashboard/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"@lingui/babel-plugin-lingui-macro": "^5.9.3",
7575
"@lingui/cli": "^5.9.3",
7676
"@lingui/core": "^5.9.3",
77+
"@lingui/format-po": "^5.9.3",
7778
"@lingui/react": "^5.9.3",
7879
"@lingui/vite-plugin": "^5.9.3",
7980
"@tailwindcss/vite": "^4.2.2",

0 commit comments

Comments
 (0)