Skip to content

Treat "0" as a valid string - #311

Merged
oscarotero merged 2 commits into
php-gettext:masterfrom
swissspidy:fix/zero-strings
Nov 18, 2026
Merged

oscarotero merged 2 commits into
php-gettext:masterfrom
swissspidy:fix/zero-strings

Conversation

@swissspidy

@swissspidy swissspidy commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Strings were checked for truthiness in several places, so "0" was handled like an empty string:

  • The PO loader dropped untranslated entries with msgid "0".
  • The PO generator wrote msgstr "" for a "0" translation and left out a "0" context, plural or previous string.
  • The MO generator skipped entries translated as "0", as well as a "0" context or plural.
  • Translation::mergeWith() replaced a "0" translation or plural with the other one, and ignored them when overriding.

See #312 for the Rector failures

Claude-Session: https://claude.ai/code/session_01UWTd5qmztfFv37ybV4xsjV

@swissspidy
swissspidy marked this pull request as ready for review November 17, 2026 16:28
Copilot AI balanced review requested due to automatic review settings November 17, 2026 16:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Strings were checked for truthiness in several places, so "0" was
handled like an empty string:

* The PO loader dropped untranslated entries with `msgid "0"`.
* The PO generator wrote `msgstr ""` for a "0" translation and left out
  a "0" context, plural or previous string.
* The MO generator skipped entries translated as "0", as well as a "0"
  context or plural.
* `Translation::mergeWith()` replaced a "0" translation or plural with
  the other one, and ignored them when overriding.
@oscarotero
oscarotero merged commit aa3f432 into php-gettext:master Nov 18, 2026
9 checks passed
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.

3 participants