You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a high level description of the issue. The problem has already been identified and lies in the internals of the rich-icu-message-formatter library.
Calling app.translator.trans('core.lib.meta_titles.without_page_title', {forumName: 'A & B', pageNumber: 1}) returns ['A & B'] instead of the expected ['A & B']
The translation is defined as such:
without_page_title: "{pageNumber, plural, =1 {{forumName}} other {Page # - {forumName}}}"
The problem doesn't exist with translations that only have a flat message without any pluralization switch.
The problem happens whenever the {placeholder} isn't in the same place in the sentence in the plural variant. If both placeholders are at the same index, the entities are correctly decoded.
The issue is most noticeable when using the "1" or "0" rule of a pluralization message since "other" is most likely to be selected at random by the ICU library. But since this is partly based on a randomly generated value, the behavior can be different once in a while.
Steps to Reproduce
.
Expected Behavior
.
Screenshots
No response
Environment
Flarum version: test on dev-main, applies at least back to 1.5
Hosting environment: local
PHP version: irrelevant
Browser: irrelevant, can reproduce in jest unit tests
Output of php flarum info
Output of "php flarum info", run this in terminal in your Flarum directory.
Possible Solution
Described in the ICU issue. Pluralization parameters need to be isolated from other placeholders so that the entire logic runs with the same pluralization instead of using singular for part of the code and plural for the other half.
Additional Context
This is the underlying cause behind these previous issues and fixes for the page title. But the underlying issue applies to a lot more than just the title. It just happens that Flarum title uses a pluralization rule.
Current Behavior
This is a high level description of the issue. The problem has already been identified and lies in the internals of the
rich-icu-message-formatter
library.Detailed issue askvortsov1/rich-icu-message-formatter#3
Calling
app.translator.trans('core.lib.meta_titles.without_page_title', {forumName: 'A & B', pageNumber: 1})
returns['A & B']
instead of the expected['A & B']
The translation is defined as such:
The problem doesn't exist with translations that only have a flat message without any pluralization switch.
The problem happens whenever the
{placeholder}
isn't in the same place in the sentence in the plural variant. If both placeholders are at the same index, the entities are correctly decoded.The issue is most noticeable when using the "1" or "0" rule of a pluralization message since "other" is most likely to be selected at random by the ICU library. But since this is partly based on a randomly generated value, the behavior can be different once in a while.
Steps to Reproduce
.
Expected Behavior
.
Screenshots
No response
Environment
Output of
php flarum info
Possible Solution
Described in the ICU issue. Pluralization parameters need to be isolated from other placeholders so that the entire logic runs with the same pluralization instead of using singular for part of the code and plural for the other half.
Additional Context
This is the underlying cause behind these previous issues and fixes for the page title. But the underlying issue applies to a lot more than just the title. It just happens that Flarum title uses a pluralization rule.
#3514
#3542
The text was updated successfully, but these errors were encountered: