GaborTorma / nuxt-dayjs-i18n

4 stars 1 forks source link

Nuxt3 date problem #7

Closed Ischafak closed 9 months ago

Ischafak commented 11 months ago

there is a problem that i dont understand

{{ $df('2023-09-07 15:00:02', 'L LTS') }} when i write this i see 'L LTS' in screen

i18n: { locales: [{ code: 'tr', iso: 'tr', file: '/i18n/tr/index.js', name: 'Turkish', }, { // use same code with dayjs locale file names: // https://github.com/iamkun/dayjs/tree/dev/src/locale code: 'en', iso: 'en', file: '/i18n/en/index.js', name: 'English', }], defaultLocale: 'tr', detectBrowserLanguage: false, vueI18n: './i18n.config.ts' }, dayjs: { locales: ['tr', 'en'] }, dayjsI18n: { computedPlugins: true, // you can specify in array: ['localiztedFormat', 'relativeTime', 'localeData'] provideFormat: true, // provide $df for Vue debug: false, },

"nuxt": "3.8.1", "dayjs-nuxt": "^2.1.9", "@gabortorma/nuxt-dayjs-i18n": "^2.0.1",

inside modules '@gabortorma/nuxt-dayjs-i18n', '@nuxtjs/i18n', ['dayjs-nuxt', {plugins: ['customParseFormat']}],

Ischafak commented 11 months ago

oh ok i guess its about threshhold when i write dddd it wrote truly

GaborTorma commented 11 months ago

Ok, no problem. You can check the last line in playground. I upgraded the dependencies.

Ischafak commented 11 months ago

@GaborTorma i have 1 more thing to ask actually when i change language with $i18n.setLocale the texts are changing directly but date is not rerendering is there anything i can do about that

GaborTorma commented 11 months ago

You can check the config of playground. If you change the languange with the comcobox, it use $i18n.setLocale and the date changed immediately.

Ischafak commented 11 months ago

i am trying to do it with buttons right now. I have 2 buttons one of them is changing language to en the other one changing to tr. When i click buttons my other texts are changing but {{ $df(company.subscription.data.renewal_at, 'dddd') }} this one is not changing.

GaborTorma commented 11 months ago

It works well in the playground. Can you provide a minimum repo for testing?

Ischafak commented 11 months ago

i dont know did i do something wrong but this https://codesandbox.io/p/devbox/keen-volhard-8t9hw9?file=%2Fpages%2Findex.vue @GaborTorma

Ischafak commented 11 months ago

in my project looks like it is working on index.vue but in component it is not changing

Ischafak commented 11 months ago

1 more thing even if there is a single valid $t('') the component rerenders so it looks alright but if there is no $t the component is not rendering again so day looks old

GaborTorma commented 11 months ago

Thanx for reporting this. It's an interesting issue. Later I will check it.

GaborTorma commented 9 months ago

Fixed: Codesandbox

Sorry for the late response.