我目前正在与Vuepress合作。但我想在我的Vuepress网站上使用多种语言。经过3天的努力,我决定把我的问题放在这里。(是的,我查看了Vuepress的文档:https://vuepress.vuejs.org/guide/i18n.html#default-theme-i18n-config)
问题:在我的配置中,荷兰语是我的主要语言。当我想把英语作为语言环境的时候。我的导航不会更新。下面是我的配置:
module.exports = {
title: 'Portfolio Bjorn',
description: ' ',
themeConfig: {
nav: [
{ text: 'Over mij', link: '/overmij.html'},
{ text: 'Portolfio', link: '/portfolio/'},
{ text: 'Contact', link: '/contact.html'},
{
text: 'Languages',
items: [
{ text: 'Dutch', link: '/' },
{ text: 'English', link: '/english/' }
]
}
],
sidebar: {
'/portfolio/': [
'',
'school',
'zelfgemaakt'
]
},
locales: {
'/english': {
lang: 'en-Us',
nav: [
{ text: 'About', link: '/about.html'},
{ text: 'Portfolio', link: '/portfolio_en/'},
{ text: 'Contact', link: '/contact_en.html'},
]
}
}
}
}我还有一张文件夹结构的图片:

我希望有人知道这个问题的答案,这样我才能继续。
亲切的问候
发布于 2018-11-15 08:08:29
我假设您使用的是默认主题。
您在配置中犯了一个简单的错误-您在themeConfig中放置了常规locale选项。
相反,您需要在一般情况下定义站点的区域设置,然后还可以定义特定于主题配置的本地化数据。
您的配置应如下所示:
module.exports = {
locales: {
/* This is where you place your general locale config */
'/': {
lang: 'nl-NL',
},
'/en/': {
lang: 'en-US',
title: 'english title of the website'
}
},
themeConfig: {
locales: {
/* This is where you place your theme specific, localized data */
'/': {
nav: [/* dutch nav */]
},
'/en/': {
nav: [/* english nav */]
},
}
}
}发布于 2018-09-06 17:46:19
我认为您需要设置基本区域设置,并在那里设置默认值,而不是上面所做的标准方法,例如:
module.exports = {
title: 'Portfolio Bjorn',
description: ' ',
themeConfig: {
locales: {
'/': {
label: 'Dutch',
nav: [
{ text: 'Over mij', link: '/overmij.html'},
{ text: 'Portolfio', link: '/portfolio/'},
{ text: 'Contact', link: '/contact.html'},
]
},
'/english': {
label: 'English',
nav: [
{ text: 'About', link: '/about.html'},
{ text: 'Portfolio', link: '/portfolio_en/'},
{ text: 'Contact', link: '/contact_en.html'},
]
}
}
}
}您也不需要在导航中定义语言下拉列表,我相信当您设置多种语言时,它会自动触发
https://stackoverflow.com/questions/52170865
复制相似问题