Repository navigation
4.3.3 - Error messages are ICU MessageFormat patterns (back-port of #1437) - #1687
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Back-port of #1437 to 4.3.3, for the bridge to 4.4: error message file entries are ICU MessageFormat patterns, so a message can use
plural,select, andnumberarguments.TException
formatErrorMessage()formats a message defined in a file with\MessageFormatterin the language of the file (getMessageFileLanguage(): the-xxsuffix, elseen). A code defined in no file, or a pattern ICU cannot parse, still has{0},{1}, ... replaced. These methods andfindErrorMessageFile()match 4.4's.addMessageFile(), then the framework file of the client language (messages-xx.txtormessages.txt), which has the highest precedence. 4.4's English-only master and the visitor messages ofTHttpExceptionare not part of this PR.'{0}', the form every message file used before, keeps plain replacement (isPlainMessagePattern()), so an application's or an extension's message file renders as before. 4.4 renders that form as the literal{0}; UPGRADE.md says to double the apostrophes before 4.4.Message files
messages.txt,messages-fr/id/zh.txt, and the ActiveRecord and SqlMapmessages.txtare converted to ICU quoting with Error messages are ICU MessageFormat patterns #1437's rules ('{0}'→''{0}'', literal braces quoted). Every converted entry renders under ICU exactly as the original did under plain replacement. The 490 entries shared with master's convertedmessages.txtmatch it.pradosoft/prado-activerecord.TSqlMapException
pradosoft/prado-sqlmap: an optional integer error code first, a trailingThrowableas the previous exception, andSimpleXMLElementarguments expanded. It formats throughTException, so its messages are ICU too.getErrorCode()returns the message code; it returned the message text.Tests and docs
TExceptionMessageFilesTest: lookup order, ICU formatting, file language, the plain-pattern fallback, the Data exceptions, and a lint that every entry of the six framework message files parses as ICU and renders each of its arguments.agents/docs are updated.Checked: php-cs-fixer, PHPStan, and the unit suite pass (8626 tests). The message files of the DB extensions (Doctrine, Propel, MongoDB, MySQLi, MSSQL, GraphQL) and prado-rpc parse as ICU, and prado-rpc's tests pass on this branch.