Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Reduce PO catalog comments changes for cleaner source control #2405

Open
@andrejcremoznik

Description

@andrejcremoznik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp