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$
Description
The
lint-popre-commit hook fails with exit code 1 when.pofiles 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
.pofile with plural entries triggers the issue:Running
uvx lint-poon such a file produces:The linter skips the plural lines, then reads the next entry's
msgidas themsgstrof the current entry, producing a false mismatch. The tool exits with code 1, blocking the commit.Impact
.pofiles — this is not caused by any particular changemsgfmt --checkandjust compile-localespass without issues on the same filesngettext/ plural forms in templates or Python code cannot pass the pre-commit hook withoutSKIP=lint-poExpected behavior
lint-poshould either properly parse plural form entries or skip them without reporting false errors.Environment
.pre-commit-config.yaml: