1

How do you configure number localization in Nuxt?

I have my nuxt.config like so

modules: [
    ['nuxt-i18n', {
      locales: [
        {
          code: 'en',
          iso: 'en-US',
          file: 'en-US.js'
        }
      lazy: true,
      langDir: 'lang/',
      defaultLocale: 'en',
    }]
  ],

but if I try to add a template like so to a page

<p>{{ $n(100, 'currency') }}</p>

I get the error in my console:

[vue-i18n] Fall back to 'en-US' number formats from 'en number formats.

I tried searching for examples but couldn't find any in the nuxt documentation.

James Burke
  • 2,229
  • 1
  • 26
  • 34

1 Answers1

3

I solved it in this way:

modules: [
    ['nuxt-i18n', {
       locales: [
         {
           code: 'en',
           iso: 'en-US',
           file: 'en-US.js'
         }
       ],
       lazy: true,
       langDir: 'lang/',
       defaultLocale: 'en',
       vueI18n: {
         numberFormats: {
           en: {
             currency: {
                style: 'currency', 
                 currency: 'USD'
                }
           }
         }
       }
     }
    ],
Ashkan
  • 846
  • 11
  • 20