Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion babel/messages/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def _run_domain(self, domain):
if self.statistics:
translated = 0
for message in list(catalog)[1:]:
if message.string:
if message.string and (not message.pluralizable or any(message.string)):
translated += 1
percentage = 0
if len(catalog):
Expand Down
15 changes: 15 additions & 0 deletions tests/messages/frontend/test_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,21 @@ def test_compile_catalog_explicit(tmp_path):
assert mo_file.exists()


def test_compile_catalog_statistics_untranslated_plural(tmp_path, caplog):
po_file = tmp_path / 'temp.po'
po_file.write_text('msgid "a"\nmsgstr "b"\n\nmsgid "c"\nmsgid_plural "d"\nmsgstr[0] ""\n')
cmdinst = configure_cli_command([
'compile',
'--statistics',
'--use-fuzzy',
'-i', str(po_file),
'-o', str(tmp_path / 'temp.mo'),
]) # fmt: skip
with caplog.at_level('INFO', logger='babel'):
assert not cmdinst.run()
assert '1 of 2 messages (50%) translated' in caplog.text


@pytest.mark.parametrize("explicit_locale", [None, 'fi_FI'], ids=("implicit", "explicit"))
def test_update_dir(tmp_path, explicit_locale: bool):
"""
Expand Down