Replies: 1 comment
-
Thanks for sharing your approach, I think this is better suited as a discussion rather than an issue, so I'm converting it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is not a bug report, just share what i have done
By apply this approach, you can get locale message from database, you can have many locale as you want on your app
Default locale with no prefix
No more performance & memory leak issue
...
If you have any solution better than this, pls share with me, i would love to change :)
...
first thing, your should restructure the pages folder like this
next, i have a config file ./i18n.config.ts like this:
sever detector './locales/serverDetector.ts'
util to fetch locale data ./utils/loadLocaleMessageFromApi.ts
i18n plugin to load locale data when app init ./plugins/i18n.ts
in case you want to reload the app when switch locale, use this version of locale switcher ./components/locale-switcher-reload.vue
in case you want to keep current app state, use this version of locale switcher ./components/locale-switcher-replace.vue
add more header to router configs, nuxt.config.ts - may not require
Fetch Wrapper, ./plugins/fetchData.ts - may not require
Hope this help :)
Beta Was this translation helpful? Give feedback.
All reactions