Giter VIP home page Giter VIP logo

Comments (5)

quroom avatar quroom commented on June 15, 2024 3

@acidjazz
Thanks for answering.

nuxt.config.ts

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  modules: ['dayjs-nuxt'],
  dayjs: {
    locales: ['ko', 'en'],
    plugins: ['relativeTime', 'utc', 'timezone'],
    defaultLocale: 'ko',
    defaultTimezone: 'Asia/Seoul',
  },
});

I added this code in nuxt.config.ts

defaultLocale: 'ko',

Isn't it for setting defaultLocale?
If it isn't, could you make it correct?

image

Anyway I will try same thing with v2.1.7 and leave comment ASAP

Updated.
defaultLocale looks working well in 2.1.7 version.
But I want to make what I understand clear.
If I didn't understand correctly, make me clear.
It's only possible setting global default locale in nuxt.config.
If I want to make locale updated with local browser language setting, I need to make composable to support it.
Is that right?

Then why don't it support update locale automatically based on user's locale based on might be browser?
It can be supported by optional.

from dayjs.

acidjazz avatar acidjazz commented on June 15, 2024

https://stackblitz.com/edit/nuxt-starter-rstvii?file=app.vue

Look, I set defaultLocale as ko But fromNow doesn't return time with ko locale.

And it also doesn't reflect browser locale setting.

You are only setting the locale for that one line in the component, you need to set it in your nuxt config if it you want it global, or have a composable return it w/ that locale

from dayjs.

quroom avatar quroom commented on June 15, 2024

@acidjazz
Thanks for quick response!

I am not sure what I unserstand correctly.

  1. "you need to set it in your nuxt config if it you want it global"
    -> I set it as "ko" in nuxt.config.ts , you can check it in the link. So I expect
    This codeuseDayjs()('2023-01-01').fromNow() returns "10 달 전"
    But it returns 10 months ago. It isn't ko locale.. Isn't it?

  2. "have a composable return it w/ that locale"
    I am not sure how I can make code as you said.

from dayjs.

acidjazz avatar acidjazz commented on June 15, 2024

@quroom i did not see you set it up in your nuxt config, looking into this now..

from dayjs.

acidjazz avatar acidjazz commented on June 15, 2024

fixed in https://github.com/fumeapp/dayjs/releases/tag/v2.1.7

from dayjs.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.