Skip to content

Write the header entry to .mo files by default - #316

Merged
oscarotero merged 1 commit into
php-gettext:masterfrom
jayhemnani9910:fix/mo-include-headers-by-default
Nov 27, 2026
Merged

oscarotero merged 1 commit into
php-gettext:masterfrom
jayhemnani9910:fix/mo-include-headers-by-default

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

MoGenerator only writes the header entry when includeHeaders() is called, so a .mo made the way the README shows has no Plural-Forms. GNU gettext then falls back to the English rule n != 1: for Russian, ngettext('%d file', '%d files', 5) returns "5 файла" instead of "5 файлов", and the same happens for Polish, Czech, Arabic and others.

The header is now written by default, as msgfmt and 4.x did; includeHeaders(false) still leaves it out. As with msgfmt output, translating "" returns the header again, so it's noted under Changed in the CHANGELOG.

Added a test that a default generator keeps the plural form. Checked with GNU ngettext against a Russian .mo: 1 файл, 3 файла, 5 файлов, 21 файл.

@oscarotero

Copy link
Copy Markdown
Member

What do you think about adding the Plural-Forms header always, even if includeHeaders is set to false? Does it makes sense?

@oscarotero
oscarotero merged commit 711be33 into php-gettext:master Nov 27, 2026
11 checks passed
@oscarotero

Copy link
Copy Markdown
Member

never mind, I think it's better to add them by default. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants