@@ -44,7 +44,7 @@ and the [useLingui hook](https://lingui.dev/ref/react#uselingui).
4444
4545Create 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"
4848import { defineConfig } from ' @lingui/cli' ;
4949
5050export default defineConfig ({
@@ -87,11 +87,58 @@ Since we set the "sourceLocale" to be "en", the `en.po` file will already be com
8787open 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
9191msgid "Welcome to Dashboard"
9292msgstr "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
97144The sections above cover localizing ** your own** extensions. If instead you want to translate the
0 commit comments