Fixed XF.phrase fails if a variable appears multiple times

Kirby

Well-known member
Affected version
2.2.13
If a phrase uses the same variable multiple times, only the first occurance gets replaced.

Lets' a asume we have a phrase hello_x_how_do_you_feel_today_x with content Hello {userName}. How do you feel today {userName}?

Using
Code:
{{ phrase('hello_x_how_do_you_feel_today_x', {'userName': 'Kirby'}) }}
in templates works as expected, eg. Hello Kirby. How do you feel today Kirby?

But using
Code:
XF.phrase('hello_x_how_do_you_feel_today_x', {'{userName}': 'Kirby'});
in JS code results in Hello Kirby. How do you feel today {userName}?
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.8).

Change log:
Fix issue where XF.phrase function was not able to handle repeated replacements
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom