diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py index e642a1a08..a333ab65b 100644 --- a/babel/messages/frontend.py +++ b/babel/messages/frontend.py @@ -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): diff --git a/tests/messages/frontend/test_frontend.py b/tests/messages/frontend/test_frontend.py index c8b8d17d5..8600b9f5c 100644 --- a/tests/messages/frontend/test_frontend.py +++ b/tests/messages/frontend/test_frontend.py @@ -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): """