updating language switcher links on route change; fixed prev/next blabla article links

This commit is contained in:
2021-01-27 21:21:20 +01:00
parent 2b67b22ce5
commit 584c4cc5d2
3 changed files with 22 additions and 5 deletions

View File

@ -103,7 +103,6 @@ Vue.use(VueSimpleAccordion, {
function initVi18n () {
// i18n.locale = drupalDecoupled.lang_code
// console.log('i18n.messages', i18n.messages)
loadLanguageAsync(drupalDecoupled.lang_code)
.then(() => {
console.log('main.js language loaded')
@ -164,6 +163,22 @@ Vue.use(VueSimpleAccordion, {
}
document.querySelector('body').classList.add(...classes)
// update block language selection
let links = document.querySelectorAll('#block-languageswitcher a.language-link')
let path = to.path.replace(/^\/\D{2,3}\//, '')
// remove language relative prefix from path classes (fr, en, etc)
.replace(/^\/\D{2,3}$/, '')
if(path !== ''){
path = '/'+path
}
links.forEach((link, i) => {
console.log("language link",path , link)
link.setAttribute('href', `/${link.getAttribute('hreflang')}${path}`)
});
// trigger router
next()
})