Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localeCurrencyName pipe incorrect translation #971

Closed
michaelbromley opened this issue Jul 6, 2021 · 2 comments
Closed

localeCurrencyName pipe incorrect translation #971

michaelbromley opened this issue Jul 6, 2021 · 2 comments
Assignees
Labels

Comments

@michaelbromley
Copy link
Member

Describe the bug
In the Admin UI we use the localeCurrencyName pipe to localize the names of currencies, e.g. in the currency select input of the Channel detail view.

In some languages, e.g. Russian, the displayed currencies include "not a number".

To Reproduce
Steps to reproduce the behavior:

  1. Set Admin UI display language to Russian
  2. Go to Channel detail view
  3. Open the currency select dropdown
  4. See list like this:
    image

where "не число" means "not a number"

Expected behavior
Should not display "not a number"

Environment (please complete the following information):

  • @vendure/core version: 1.1.0
  • Nodejs version: any
  • Database (mysql/postgres etc): any

Additional context
This is caused by a bad assumption in the pipe that passing undefined to the format() method will always output the string NaN:

There is a proper API to do this without hacky string replacement: formatToParts()

@michaelbromley michaelbromley self-assigned this Jul 6, 2021
@michaelbromley
Copy link
Member Author

michaelbromley commented Jul 6, 2021

Related note from Slack discussion:

One more interesting moment.
Because this api assume formating number, it tries to translate currencies as Genitive but not as Nominative declination.
Example:
Nan US dollars is transformed as US dollars - genetive plural. Nominative is "US dollar".
In Russian it works the same, but result is very strange to read.
"NaN российского рубля" is transformed to "российского рубля" - genetive not plural. Nomative (the aim) is "российский рубль".
In english using Genetive seems normal, but in Russian it seems as unquality translation.

Update:
Discovered the Intl.DisplayNames API which handles this correctly!

It can also be used for country names meaning we can remove all the manual translations of country names from all translation files, woo hoo!

@michaelbromley
Copy link
Member Author

Related issue: the logic in the CurrencyInputComponent that determines whether to place the currency symbol before or after the number is broken for the same reason.

michaelbromley added a commit that referenced this issue Jul 8, 2021
Relates to #971. Allows us to get rid of all manual translations of language names!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant