Skip to content

bug: lint-po pre-commit hook fails on plural forms (msgid_plural) #1312

@davidpoblador

Description

@davidpoblador

Description

The lint-po pre-commit hook fails with exit code 1 when .po files contain plural forms (msgid_plural / msgstr[0] / msgstr[1]). The linter doesn't recognize these standard gettext directives, treats them as unexpected input, gets out of sync, and reports false positive errors.

Reproduction

Any .po file with plural entries triggers the issue:

msgid "%(count)s active schedule"
msgid_plural "%(count)s active schedules"
msgstr[0] "%(count)s programació activa"
msgstr[1] "%(count)s programacions actives"

Running uvx lint-po on such a file produces:

UserWarning: (1) Unexpected input: msgid_plural "%(count)s active schedules"
UserWarning: (1) Unexpected input: msgstr[0] "%(count)s active schedule"
UserWarning: (1) Unexpected input: msgstr[1] "%(count)s active schedules"

Difference between msgid="%(count)s active schedule" and msgstr="Manage schedules":
  Missing from msgstr: %(count)s
  at locales/en/LC_MESSAGES/messages.po:1053

The linter skips the plural lines, then reads the next entry's msgid as the msgstr of the current entry, producing a false mismatch. The tool exits with code 1, blocking the commit.

Impact

  • The hook fails on both old and new .po files — this is not caused by any particular change
  • msgfmt --check and just compile-locales pass without issues on the same files
  • Projects using ngettext / plural forms in templates or Python code cannot pass the pre-commit hook without SKIP=lint-po

Expected behavior

lint-po should either properly parse plural form entries or skip them without reporting false errors.

Environment

  • Hook config from .pre-commit-config.yaml:
    - id: lint-po
      name: lint-po
      entry: uvx lint-po
      language: system
      files: \.po$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions