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

Locale dynamic import #584

Open
TiGR opened this issue Jan 17, 2024 · 2 comments
Open

Locale dynamic import #584

TiGR opened this issue Jan 17, 2024 · 2 comments

Comments

@TiGR
Copy link

TiGR commented Jan 17, 2024

So, the question is: we have multiple site versions, and in each of these the entire interface is in some specific language. We'd like to provide translations according to the site language. The problem here is that there is no simple way to import only specific translations for specific site language versions.

The only way I see it could be achieved is by using client-side imports, but that would require somehow adding all files to build process, so that all translations be copied to build directory, even if it is not imported directly. And also that puts some requirements for browser support and there is no way to support legacy browsers.

The only way I see it is by loading all supported languages in some for all website versions, which I see as suboptimal.

@t1m0n
Copy link
Owner

t1m0n commented Jan 23, 2024

I guess you could use something like webpack lazy loading or implement it by yourself if you don't want to include all locale files in your bundle.
I think it would be great to have index file in AirDatepicker which would export all possible locales 🤔 . I guess I'll add such in the next release

@TiGR
Copy link
Author

TiGR commented Jan 24, 2024

For most libraries that I've worked with, you could either import specific language, or just include a locale file on page and it would automatically register with the library, and then you could just specify the locale code, and it would take it from the locale registry.

As for the locale files in air-datepicker dist directory, there is no way to import/add these in browser environment, you can't add a script tag (even with type="module") with it. It could work only on build step with some sort of builder (which is not always present).

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

2 participants