babel icon indicating copy to clipboard operation
babel copied to clipboard

Allow passthrough of xgettext's plural templates

Open akx opened this issue 11 months ago • 2 comments

As #1154 reported, Babel would choke trying to parse a plural expression that is but a template.

After this, such templates can be parsed and manipulated, but may have strange interactions with other features.

akx avatar Feb 03 '25 09:02 akx

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.68%. Comparing base (b50a1d2) to head (6cf8070). Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1185   +/-   ##
=======================================
  Coverage   91.68%   91.68%           
=======================================
  Files          27       27           
  Lines        4689     4690    +1     
=======================================
+ Hits         4299     4300    +1     
  Misses        390      390           
Flag Coverage Δ
macos-14-3.10 90.72% <100.00%> (+<0.01%) :arrow_up:
macos-14-3.11 90.66% <100.00%> (+<0.01%) :arrow_up:
macos-14-3.12 90.87% <100.00%> (+<0.01%) :arrow_up:
macos-14-3.13 90.87% <100.00%> (+<0.01%) :arrow_up:
macos-14-3.8 90.59% <100.00%> (+<0.01%) :arrow_up:
macos-14-3.9 90.65% <100.00%> (+<0.01%) :arrow_up:
macos-14-pypy3.10 90.72% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.10 90.74% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.11 90.68% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.12 90.89% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.13 90.89% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.8 90.61% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.9 90.67% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-pypy3.10 90.74% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.10 90.73% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.11 90.67% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.12 90.88% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.13 90.88% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.8 90.70% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.9 90.66% <100.00%> (+<0.01%) :arrow_up:
windows-2022-pypy3.10 90.73% <100.00%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 03 '25 09:02 codecov[bot]

After this, such templates can be parsed and manipulated, but may have strange interactions with other features.

I wonder if it'd be better to either reject these (with a nicer error message) or try to detect the nplurals=INTEGER; plural=EXPRESSION; snippet and default to nplurals=2 and plural=(n != 1) as we do now?

This way the catalog wouldn't be in this weird partially valid state. For type-checked code you also wouldn't need to type guard num_plurals in case it's a string

tomasr8 avatar Feb 03 '25 11:02 tomasr8