Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICU message formatter used in JS incorrectly handles '{placeholder}' syntax #3702

Open
rob006 opened this issue Dec 1, 2022 · 0 comments
Open
Labels

Comments

@rob006
Copy link
Contributor

rob006 commented Dec 1, 2022

Current Behavior

Placeholders wrapped between '' should be treated as literal string, so User: '{user}' should be always translated to User: '{user}'. Currently it works correctly if PHP translator is used, but JS translator ignores quoting and replaces placeholders in every case, and produces User: 'rob006'. As a result translators needs to quote differently depending on context - we need User: '{user}' for JS and User: ''{user}'' for PHP. There is no convenient way to know where specific string is used, so this is super inconvenient for languages that use single quote by default. Currently there is ~40 such translations on Weblate: https://weblate.rob006.net/search/flarum/?offset=1&q=target%3Ar%22%27%5C%7B%22&sort_by=context&checksum= and it is hard to say which translations are correct and which should be fixed by replacing ' with ''.

Steps to Reproduce

  1. Create User: ''{user}'' translation.

Expected Behavior

Results for $translator->trans('my-key', ['user' => 'rob006']) and app.translator.trans('my-key', { user: 'rob006' }) should be the same: User: 'rob006'.

Screenshots

No response

Environment

  • Flarum version: 1.6.2
  • PHP version: 7.4.33

Output of php flarum info

No response

Possible Solution

No response

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant