Fix downloading all languages #528
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partially fixes #525. The changes dynamically import the language. The current method loads the language when the application is ready to display the ui. With the new approach that is too late to start downloading the language js file. Thats why i call the method in
initClientApp()
.This improves performance, but further optimization is possible. Currently, my changes don't affect the existing
dynamicActivationLocale()
call because I'm unsure of the impact ofsetLoaded()
. We're also downloading a large index.js file, which then triggers numerous imports. This forces the browser to wait for the initial file before discovering and requesting other necessary files, such as the language file.To address this, we should flatten the dependency structure. Instead of a single
<script>
tag inindex.html
, we should have multiple. For example, since the browser sends preferred languages in its headers, we could handle language lookup server-side, eliminating the need to download JavaScript for this purpose and then import a language file in the browser.You can modify the changes as you like. The key part is
const module = (await import(`./locales/${locale}.po`)); i18n.load(locale, module.messages);
Checklist
Thank you for your contribution! 🎉