diff --git a/packages/@vuepress/core/lib/node/ClientComputedMixin.js b/packages/@vuepress/core/lib/node/ClientComputedMixin.js
index dbe8a3f7a5..a3166805bd 100644
--- a/packages/@vuepress/core/lib/node/ClientComputedMixin.js
+++ b/packages/@vuepress/core/lib/node/ClientComputedMixin.js
@@ -54,7 +54,7 @@ module.exports = siteData => {
for (const path in locales) {
if (path === '/') {
defaultLang = locales[path]
- } else if (this.$page.path.indexOf(path) === 0) {
+ } else if (this.$page.path.indexOf(path) === 0 || (!this.$page.path && this.$route.path.indexOf(path) === 0)) {
targetLang = locales[path]
}
}
diff --git a/packages/@vuepress/core/lib/node/__tests__/prepare/fixtures/docs-i18n/.vuepress/config.js b/packages/@vuepress/core/lib/node/__tests__/prepare/fixtures/docs-i18n/.vuepress/config.js
index 3f7bce8e67..d6dbf26c40 100644
--- a/packages/@vuepress/core/lib/node/__tests__/prepare/fixtures/docs-i18n/.vuepress/config.js
+++ b/packages/@vuepress/core/lib/node/__tests__/prepare/fixtures/docs-i18n/.vuepress/config.js
@@ -21,13 +21,27 @@ module.exports = {
label: 'English',
selectText: 'Languages',
editLinkText: 'Edit this page on GitHub',
- lastUpdated: 'Last Updated'
+ lastUpdated: 'Last Updated',
+ notFoundLinkText: 'Take me home.',
+ notFoundMessages: [
+ `There's nothing here.`,
+ `How did we get here?`,
+ `That's a Four-Oh-Four.`,
+ `Looks like we've got some broken links.`
+ ]
},
'/zh/': {
label: '简体中文',
selectText: '选择语言',
editLinkText: '在 GitHub 上编辑此页',
- lastUpdated: '上次更新'
+ lastUpdated: '上次更新',
+ notFoundLinkText: '返回首页',
+ notFoundMessages: [
+ '这里什么都没有。',
+ '你怎么到这来了?',
+ '这是一个 404 页面。',
+ '看起来这是一个错误的链接。'
+ ]
}
}
}
diff --git a/packages/@vuepress/test-utils/client/siteData.js b/packages/@vuepress/test-utils/client/siteData.js
index 5e3ea16429..52193a3b54 100644
--- a/packages/@vuepress/test-utils/client/siteData.js
+++ b/packages/@vuepress/test-utils/client/siteData.js
@@ -29,13 +29,27 @@ export default {
"label": "English",
"selectText": "Languages",
"editLinkText": "Edit this page on GitHub",
- "lastUpdated": "Last Updated"
+ "lastUpdated": "Last Updated",
+ "notFoundLinkText": "Take me home.",
+ "notFoundMessages": [
+ "There's nothing here.",
+ "How did we get here?",
+ "That's a Four-Oh-Four.",
+ "Looks like we've got some broken links."
+ ]
},
"/zh/": {
"label": "简体中文",
"selectText": "选择语言",
"editLinkText": "在 GitHub 上编辑此页",
- "lastUpdated": "上次更新"
+ "lastUpdated": "上次更新",
+ "notFoundLinkText": "返回首页",
+ "notFoundMessages": [
+ "这里什么都没有。",
+ "你怎么到这来了?",
+ "这是一个 404 页面。",
+ "看起来这是一个错误的链接。"
+ ]
}
}
},
diff --git a/packages/@vuepress/theme-default/layouts/404.vue b/packages/@vuepress/theme-default/layouts/404.vue
index 2cbfa0f179..2597c78d98 100644
--- a/packages/@vuepress/theme-default/layouts/404.vue
+++ b/packages/@vuepress/theme-default/layouts/404.vue
@@ -1,29 +1,50 @@
-
404
+
+ 404
- {{ getMsg() }}
+ {{ getMsg() }}
-
- Take me home.
-
+
+ {{ notFoundLinkText }}
+
+