简体   繁体   中英

Pluralization on symfomy command

I've created a commmando which needs pluralization to send some emails

//without pluralization works fine
//$body = $this->translator->trans('expiration.password.reminder.body', $email_params, 'emails');
 $body = $this->translator->transChoice('expiration.password.reminder.subject', 102,[], 'emails');

this is the message to translate ans pluralize

expiration.password.reminder.body: '<p>Dear %name% %surname%,</p>Your password is going to expire in %$day_to_remind% days.

but in the sent email the shown text is not complete:

Your password is going to expire

I don't know what is wrong, anyone know a way which works on symfony3.4 and is not deprecated at symfony4.4?

The %$day_to_remind% parameter should be named %count% instead, as symfony populates it automatically given the second parameter. And you should also provide the singular form according to the format :

# Message key and content shortened
'Your password is going to expire in 1 day|Your password is going to expire in %count% days'

This is deprecated in 4.4, though, but it still works, since the replacement wasn't introduced until 4.2 and as per the symfony stability promise, there are no breaks in minor releases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM