Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork430
Description
Problem Description
Keeping PO files in Git can result in thousands of changed lines with minimal changes to translations after every extraction. The source of most are comments with file paths and line numbers. I think it's possible to disable comments altogether but I do want to keep the reference to the file name.
In essence I want to transform this:
#:survey/config/project-survey.ts:12#:survey/config/project-survey.ts:20#:survey/config/project-survey.ts:55#:survey/config/user-survey.ts:33#:survey/config/user-survey.ts:46msgid"Don’t know"msgstr"Ne vem"
Into this:
#: survey/config/project-survey.ts#: survey/config/user-survey.tsmsgid"Don’t know"msgstr"Ne vem"
Proposed Solution
This config will get rid of the line numbers:
import{defineConfig}from'@lingui/cli'import{formatter}from'@lingui/format-po'exportdefaultdefineConfig({format:formatter({lineNumbers:false,printPlaceholdersInComments:false}),// ...})
But you still get duplicated lines if the same translation appears multiple times in the same file. I think the PO extractor should automatically remove duplicated comment lines regardless of there being an option or not.
Right now I'm using a post-extract script to strip unwanted lines.
clean-po-files.sh
#!/bin/shwd=$(pwd)forpoin"$wd"/src/locales/*.po;do uniq"$po">"${po}.new" rm"$po" mv"${po}.new""$po"done
package.json
{"scripts": {"extract":"lingui extract && ./clean-po-files.sh" }}Alternatives Considered
I'm using the post-extract script for now and that works fine.
Additional Context
No response