willdurand / BazingaJsTranslationBundle

A pretty nice way to expose your Symfony translation messages to your client applications.
MIT License
572 stars 178 forks source link

Call IntlMessageFormat in transChoice method #341

Open cbwar opened 1 year ago

cbwar commented 1 year ago

IntlMessageFormat is not called in transChoice method

symfony xliff file

<trans-unit id="trans.test1">
    <source>trans.test1</source>
    <target>né(e) le {date}</target>
</trans-unit>
<trans-unit id="trans.test2">
    <source>trans.test2</source>
    <target>[0,18[ né(e) le {date} (moins de 18 ans) | ]1,+Inf] né(e) le {date} ({age} ans)</target>
</trans-unit>

js code

Translator.trans('trans.test1', {'date': moment().format("DD/MM/YYYY")});
Translator.transChoice('trans.test2', 21, {'date': moment().format("DD/MM/YYYY"), 'age': 21});
Translator.transChoice('trans.test2', 5, {'date': moment().format("DD/MM/YYYY"), 'age': 5});

browser console output

2022-12-27 12_23_42-Window