Skip to content

Leave fuzzy translations out of generated .mo files - #317

Merged
oscarotero merged 1 commit into
php-gettext:masterfrom
jayhemnani9910:fix/mo-skip-fuzzy
Nov 30, 2026
Merged

oscarotero merged 1 commit into
php-gettext:masterfrom
jayhemnani9910:fix/mo-skip-fuzzy

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

MoGenerator compiles entries flagged #, fuzzy into the .mo file. GNU msgfmt leaves them out unless --use-fuzzy is given, so the runtime falls back to the source string. After msgmerge, every changed source string is marked fuzzy and keeps its old translation:

#, fuzzy
#| msgid "Old text"
msgid "New text"
msgstr "Texte ancien"

With this library the app shows "Texte ancien" for "New text", the old translation for a changed string. msgfmt output doesn't contain the entry.

The generation loop now skips translations with the fuzzy flag. includeFuzzy() keeps them, like msgfmt --use-fuzzy, following the existing includeHeaders() option.

Testing: added testFuzzyTranslationsAreSkippedByDefault (the entry is absent by default and present with includeFuzzy()), which fails on master. phpunit (109 tests), phpcs and phpstan pass. Compiled the .po above with PoLoader + MoGenerator and compared it with msgfmt through msgunfmt: the fuzzy entry is gone, as with msgfmt. The CHANGELOG has a line under Unreleased.

@oscarotero
oscarotero merged commit 966ab16 into php-gettext:master Nov 30, 2026
11 checks passed
@oscarotero

Copy link
Copy Markdown
Member

It makes sense. thanks!

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