2

I would like to change the short weekdays for the dutch locale (nl). To do that I would need to use updateLocale, as described here: https://day.js.org/docs/en/customization/weekday-abbreviations. This is what I currently have in nuxt.config.js:

  modules: [
    '@nuxtjs/dayjs',
  ],
  dayjs: {
    locales: ['en', 'nl'],
    defaultLocale: 'nl',
    plugins: [
      'updateLocale',
      'relativeTime'
    ],
    updateLocale: ('nl', {
      weekdaysShort: ['Su', 'Mo', 'Tu', 'WAHH', 'Th', 'Fr', 'Sa']
    })
  }

Never mind the 'WAHH' part, that's just for testing. But obviously this isn't working. What's the correct way of handling this?

Using this: https://www.npmjs.com/package/@nuxtjs/dayjs

Sacred Agent
  • 53
  • 1
  • 6

1 Answers1

0

Make a dayjs.js file in plugins folder and write code below.

export default function ({ $dayjs }) {
  $dayjs.updateLocale('en', {
    relativeTime: {
      future: 'in %s',
      past: '%s ago',
      s: 'a few seconds',
      m: 'a minute',
      mm: '%d minutes',
      h: 'an hour',
      hh: '%d hours',
      d: 'a day',
      dd: '%d days',
      M: 'a month',
      MM: '%d months',
      y: 'a year',
      yy: '%d years',
    },
  })
}

And add this plugin to nuxt.config.js.

// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [ '~/plugins/dayjs'],

Finally, add updateLocale to dayjs config in nuxt.config.js

...

dayjs: {
    locales: ['en'],
    defaultLocale: 'en',
    defaultTimeZone: 'America/New_York',
    plugins: ['timezone', 'relativeTime', 'updateLocale'],
  },

...
k4sud0n
  • 15
  • 4