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

dayjs locale config is ignored and it uses automaticly browser locale #1783

Open
omar-bear opened this issue Jan 27, 2022 · 2 comments
Open

Comments

@omar-bear
Copy link

omar-bear commented Jan 27, 2022

Describe the bug
dayjs locale config is ignored and it uses automaticly browser locale

Expected behavior

// config.js
import 'dayjs/locale/fr';
dayjs.locale('fr')

in main react page

import './config'

and in my component

dayjs(fullStartDate).to(fullEndDate, true);

the language changes to french but when i refrech it comeback english (i think its because the browser locale)

but when i do this it works as french always

    dayjs(fullStartDate).locale('fr').to(fullEndDate, true);

how can i config the language clearly without using the locale for each time
Information

  • Day.js Version 1.10.7
  • OS: MacOS monterey
  • Browser Chrome last version
  • Time zone: (UTC+1)
@DaleCam
Copy link

DaleCam commented Feb 22, 2022

I had to downgrade to 1.9.8 and it is working in that version.
Edit: Actually only some are working in 1.9.8 version. "es" for example is not working whereas "en-gb" is. Wonder if the locales simply need to be updated.

@jasonhieu1905
Copy link

jasonhieu1905 commented Apr 28, 2022

@iamkun : got the same issue with the code snippet, global locale is override:

import dayjs from 'dayjs';
import locale from 'dayjs/locale/vi';

dayjs.locale(locale);

dayjs().locale('en-us');

let determinedLocale = dayjs.locale();

// will log 'en' instead of 'vi'
console.log('locale changed by local instance ', determinedLocale);

Issue version: 1.11.1
Works fine with older version like : 1.9.8 & 1.10.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants