You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -219,6 +219,7 @@ List of 300 VueJS Interview Questions
219
219
|210|[How to implement DateTime localization?](#how-to-implement-date-time-localization)|
220
220
|211|[How do you implement Number localization?](#how-do-you-implement-number-localization)|
221
221
|212|[How do you perform locale changing](#how-do-you-perform-locale-changin)|
222
+
|213|[What is Lazy loading translations?](#what-is-lazy-loading-translations)|
222
223
223
224
1.### What is VueJS?
224
225
**Vue.js** is an open-source, progressive Javascript framework for building user interfaces that aim to be incrementally adoptable. The core library of VueJS is focused on the `view layer` only, and is easy to pick up and integrate with other libraries or existing projects.
@@ -3853,5 +3854,52 @@ List of 300 VueJS Interview Questions
3853
3854
}
3854
3855
</script>
3855
3856
```
3857
+
213. ### What is Lazy loading translations?
3858
+
The loading of all translation files at once is unnecessary and it may impact the performance too. It will be easy for lazy loading or asynchronously loading the translation files when you use webpack. i.e, You can dynamically load or import language translations using webpack as below,
3859
+
```javascript
3860
+
//i18n-setup.js
3861
+
importVuefrom'vue'
3862
+
importVueI18nfrom'vue-i18n'
3863
+
importmessagesfrom'@/lang/en'
3864
+
importaxiosfrom'axios'
3865
+
3866
+
Vue.use(VueI18n)
3867
+
3868
+
exportconsti18n=newVueI18n({
3869
+
locale:'en', // set locale
3870
+
fallbackLocale:'en',
3871
+
messages // set locale messages
3872
+
})
3873
+
3874
+
constloadedLanguages= ['en'] // our default language that is preloaded
3875
+
3876
+
functionsetI18nLanguage (lang) {
3877
+
i18n.locale= lang
3878
+
axios.defaults.headers.common['Accept-Language'] = lang
0 commit comments