Closed BredoGen closed 4 months ago
It is a valid output for both ru
and ru-RU
locales. Comma is used as a decimal separator and currency code is properly placed as a suffix.
I've also verified that with the Unicode CLDR database. Javascript behaves the same:
console.log((11.49).toLocaleString("ru", {style: "currency", currency: "USD"}))
// "11,49 $"
It is a valid output for both ru and ru-RU locales. Comma is used as a decimal separator and currency code is properly placed as a suffix.
Sorry, yes, both versions are valid for Russian. But $ as prefix is more common for prices in e-commerce.
Introducing optional LC_NUMERIC
env will give a chance to use different LANGUAGE and NUMERIC locale for such cases (Babel already uses it in format_currency() method).
Wouldn't using LC_NUMERIC override the format for all languages? There are systems where that variable is exported by the OS which would force the user to explicitly override it which I'm sure would result in bugs being filed against Saleor. What about the decimal point character being different?
Wouldn't using LC_NUMERIC override the format for all languages? There are systems where that variable is exported by the OS which would force the user to explicitly override it which I'm sure would result in bugs being filed against Saleor.
You're right. If LC_NUMERIC
will be exported by the OS - it'll break multi-language currency localization setup.
What about the decimal point character being different?
Using dot as decimal separator for USD prices in Russian is OK and even more common. Everyone is used to see USD prices in English formatting in e-commerce.
Comma as separator and suffix notation is more common for rubles prices: 10,000 RUB.
So, there is no easy solution to include in core.
It's better for me to override "amount" filter implementing my custom logic there (maybe via dict in settings which will override numeric locale for some languages). Now I realize that this feature is redundant for core functionality.
Sorry for erroneous report
What if there was a way to override certain settings on a per-locale setting? For example to say that you want to use ¤ #,##0.00
for US dollars in Russian.
What if there was a way to override certain settings on a per-locale setting? For example to say that you want to use ¤ #,##0.00 for US dollars in Russian.
It will be great feature and it'll completely resolve the problem
Hi.
There is a problem using Saleor/django-prices in case with some default locales: e.g:
Usage:
{{ price|amount:'html' }}
Output: 11,49 $It is not valid output for USD currency (even for RU locale). The valid one is classic $11.49
Reason: "|amount" template filter forces currency format by passing the current language to Babel as locale (see _templatetags/pricesi18n.py:42).
Babel supports overriding numeric locale via LC_NUMERIC env.
It will be very useful if get_locale_data() in prices_i18n.py will be checking this env before passing currency locale to Babel.