iamkun / iamkun/dayjs

Load locale without the need of a global instance

Open
#2,516 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

Hello,

I'm working on a web project using `dayjs` which should load locales dynamically (using `await import('');`) from the `locales` folder of `dayjs`.
However, these files need an instance of `dayjs` available as global object, in my case I need to set `window.dayjs` which is pretty ugly.
Is there a way to load the locale and directly specify the `dayjs` instance it should use?

Thanks!

Possibly related: https://github.com/iamkun/dayjs/issues/655

Contributor guide

Open the contributing guide

Research direction

Start by examining the locale files in the locales folder and how they obtain the global dayjs instance when loaded through a dynamic import. Review the possibly related issue #655 and determine whether the requested behavior can be specified without window.dayjs; done should provide a supported way to associate a locale with a chosen dayjs instance.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
internationalization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.