Load fallback language when needed (lazy-load)
See original GitHub issuenuxt-i18n version: 2.3.4
Imagine you have two languages, en
(default) and de
.
But only parts of the en
language is localized in the de
file.
If you now enter a page (e.g. /de/only-half-localized-route
), you see the correct translations (for de) where it applies, but no en translation because the fallback language isn’t loaded properly because of lazy-loading. Instead, you see the translation keys.
A naive fix for it would be to load the fallback language every time, but I guess there is a way to check if a fallback is needed and load the fallback language in that case (if not already loaded).
<div align="right">This feature request is available on Nuxt.js community (#c39)</div>Issue Analytics
- State:
- Created 6 years ago
- Reactions:13
- Comments:24 (1 by maintainers)
Top Results From Across the Web
Load fallback language when needed (lazy-load) #34 - GitHub
Possibly simpler workaround: In nuxt_config.js, using require or import , load default locale manually and pass to vue-i18n configuration:.
Read more >Lazy loading translations | Vue I18n
Lazy loading or asynchronously loading the translation files is really easy when using Webpack. The lang folder is where all of our translation ......
Read more >Add lazy loading to React i18next with React Suspense
Error: withI18nextTranslation(Unknown) suspended while rendering, but no fallback UI was specified. Step 1: Install i18n-xhr-backend NPM module. First you will ...
Read more >Lazy loading best practices - web.dev
Lazy loading delays the loading of resources until after the DOM is interactive when scripts have finished loading and begin execution. For ...
Read more >Lazy Load Translation Files In Angular Using Transloco
Adding the TRANSLOCO_SCOPE to the providers instruct Transloco load the corresponding scope based on the active language and merge it under the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Possibly simpler workaround:
In nuxt_config.js, using
require
orimport
, load default locale manually and pass tovue-i18n
configuration:nuxt-i18n
will merge current locale messages into same object and thenvue-i18n
will be able to access default locale for fallback.My function for load fallback language when needed
/plugins/i18n.js:
then call “this.$loadLanguageAsync(lang)” from anywhere
I am using that for translating via keyboard shortcuts events 😃
Hope this will help someone