Skip to content

[Translator] Why does the currency depend on the locale? #32652

@sylfabre

Description

@sylfabre

Symfony version(s) affected: 4.3

Description
According to https://symfony.com/doc/current/translation/message_format.html#numbers the translator uses the locale to select the currency:

# translations/messages+intl-icu.en.yaml
value_of_object: 'This artifact is worth {value, number, currency}'
// prints "This artifact is worth $9,988,776.65"
// if we would translate this to i.e. French, the value would be shown as
// "9 988 776,65 €"
echo $translator->trans('value_of_object', ['value' => 9988776.65]);

IMO, the currency does not depend on the locale: I may want to display euros in English and US dollars in French.

What is the expected way to display this sentence using the translator?

This artifact is worth €9,988,776.65

A possible workaround would be to define custom formats like with this JS lib:
https://github.com/formatjs/formatjs/tree/master/packages/intl-messageformat#user-defined-formats

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions