mirror of
https://github.com/BeamMP/BeamMP-Website.git
synced 2026-12-02 02:34:30 +00:00
Added i18n Translation Support
Co-Authored-By: Tixx <83774803+WiserTixx@users.noreply.github.com>
This commit is contained in:
1 parent
0d4d34634a
commit
3873388b48
15 files changed
+821
-460
No files matched your search
+17
-1
@@ -1,3 +1,4 @@
|
||||
import { loadLocaleMessages, setI18nLanguage, SUPPORT_LOCALES } from '@/i18n'
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import NotFound from '@/views/NotFound.vue'
|
||||
|
||||
@@ -80,7 +81,22 @@ const router = createRouter({
|
||||
})
|
||||
|
||||
// Global navigation guard for meta data
|
||||
router.beforeEach((to, from, next) => {
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
const paramsLocale = to.params.locale || 'en'
|
||||
|
||||
// use locale if paramsLocale is not in SUPPORT_LOCALES
|
||||
/*if (!SUPPORT_LOCALES.includes(paramsLocale)) {
|
||||
return next(`/${locale}`)
|
||||
}*/
|
||||
|
||||
// load locale messages
|
||||
if (!i18n.global.availableLocales.includes(paramsLocale)) {
|
||||
await loadLocaleMessages(i18n, paramsLocale)
|
||||
}
|
||||
|
||||
// set i18n language
|
||||
setI18nLanguage(i18n, paramsLocale)
|
||||
|
||||
// Set page title
|
||||
document.title = to.meta.title || 'BeamMP'
|
||||
|
||||
|
||||
Reference in new issue
Block a user