Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

How to use ICU's select with decimals on Symfony4?

$
0
0

Symfony4 uses ICU for translations. I want a rich display of time values in my translation - in French. For instance, 1.25 hours should display "One hour and a quarter" - pardon my french.

Yet, i found no way to escape dots, or wrap my "key" value with quotes. The following example always returns a U_PATTERN_SYNTAX_ERROR if i try any way of escaping the dot:

messages+intl-icu.fr.yml

  durationHours: >-
    {n, select,
        0     {Non précisé}
        1     {1 heure}
        1.25  {1 heure et quart}
        other {{n} heures}
    }

TaskService.php

$this->tl->trans('task.durationHours', ['n' => $task->getDurationInHours()]);

The docs i based my research upon:


Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>