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

Set number format for different locale than current #1996

Closed
3 tasks done
MickL opened this issue Oct 22, 2024 · 1 comment
Closed
3 tasks done

Set number format for different locale than current #1996

MickL opened this issue Oct 22, 2024 · 1 comment
Labels
Status: Proposal Request for comments

Comments

@MickL
Copy link

MickL commented Oct 22, 2024

Clear and concise description of the problem

I have a shop that sells to EU countries. All of the EU countries use the same number format: 1.150,00 €

My main website is in German (locale: de), but I want to add an english translation (locale: en) for all other countries. By doing that, the number format now changes to €1,150.00 which is a number format no one would ever use.

How can I set the the format to be e.g. german for the english locale?

My current config:

const numberFormats = {
  currency: {
    style: 'currency',
    currency: 'EUR',
  },
};

export default defineI18nConfig(() => ({
  numberFormats: {
    de: numberFormats,
    en: numberFormats,
  },
);

I assume that this will create new Intl.NumberFormat('de', numberFormats); and new Intl.NumberFormat('en', numberFormats); but the en one I want to replace with also 'de'.

Suggested solution

Alternative

No response

Additional context

No response

Validations

@MickL MickL added the Status: Proposal Request for comments label Oct 22, 2024
@kazupon
Copy link
Member

kazupon commented Oct 29, 2024

you can override with locale option for API such as n or $n..
I think you can localize to de on en.
https://vue-i18n.intlify.dev/api/composition.html#value-number-keyoroptions-key-resourcekeys-numberoptions-lt-key-resourcekeys-locales-gt-locale-locales-string

Thanks!

@kazupon kazupon closed this as completed Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Proposal Request for comments
Projects
None yet
Development

No branches or pull requests

2 participants