-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(feat): localize 404 page (fix #1987) #2004
Conversation
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.` | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs translation.
"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." | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs translation.
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.` | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs translation.
@@ -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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you trying to solve with this condition? When would this.$page.path
not be defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dzetah ?
@@ -42,6 +42,13 @@ module.exports = ctx => ({ | |||
selectText: 'Languages', | |||
ariaLabel: 'Select language', | |||
editLinkText: 'Edit this page on GitHub', | |||
notFoundLinkText: 'Take me home.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to set this for the /
locale as these are the default values right?
packages/docs/docs/zh/guide/i18n.md
Outdated
// TODO: comment me | ||
notFoundLinkText: 'Take me home.', | ||
// TODO: comment me | ||
notFoundMessages: [/* ... */], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here (to translate)
packages/docs/docs/zh/guide/i18n.md
Outdated
@@ -54,6 +54,8 @@ module.exports = { | |||
label: 'English', | |||
ariaLabel: 'Languages' | |||
editLinkText: 'Edit this page on GitHub', | |||
notFoundLinkText: 'Take me home.', | |||
notFoundMessages: [/* ... */], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here (to translate)
|
||
// custom text for 404 page link. Defaults to "Take me home." | ||
notFoundLinkText: 'Take me home.', | ||
notFoundMessages: [/* ... */] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is important to write an example with the default values here, to let the user know what the default values are.
packages/docs/docs/guide/i18n.md
Outdated
@@ -79,6 +83,8 @@ module.exports = { | |||
selectText: '选择语言', | |||
label: '简体中文', | |||
editLinkText: '在 GitHub 上编辑此页', | |||
notFoundLinkText: 'Take me home.', | |||
notFoundMessages: [/* ... */], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here
packages/@vuepress/core/lib/node/__tests__/prepare/fixtures/docs-i18n/.vuepress/config.js
Show resolved
Hide resolved
packages/@vuepress/core/lib/node/__tests__/prepare/fixtures/docs-i18n/.vuepress/config.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is great work @dzetah! Just small things to fix and one question to answer to!
@newsbielt703 or @meteorlxy could you help with the |
@dzetah Sorry I did not that some sentences were using apostrophes 😅 In this case you can wrap these sentences with |
Hello, any news on this ? I'd like to see this merged soon :) I think it only lacks the Chinese translation (docs and defaults). |
@dzetah yes, we just need one more approve and zh translation (@meteorlxy ?) BTW could you answer this question in my review ?
|
@kefranabg I answered this question before but it looks like you can't see my answer so i'll post it here below too :)
|
I've finished the Chinese translation. Also resolved conflicts, linted the code, and made some tweaks. |
Currently, it will show the default messages first, and change to the locale messages. It's not so perfect 🤔 https://deploy-preview-2004--vuepress.netlify.com/zh/guide/aaa |
@dzetah Could you fix this? We're not supposed to have this blink effect |
Although it's not a critical problem, I think it would be a little complicated to fix that. Maybe vuepress-plugin-dehydrate will help ---- to dehydrate the |
@kefranabg Obviously this is not an expected behaviour, I'll try to take a look at this later this week... Thanks @meteorlxy for your improvements :) |
@meteorlxy I'm not sure vuepress-plugin-dehydrate will help us in this case because the 404 component is replacing the page at the given location. Maybe I'm misunderstanding the issue here 🤔 |
@meteorlxy @kefranabg I think we could just use the |
@kefranabg I opened this PR a year ago and I just stumbled upon it again today 😅 Is this still something that can be merged ? |
@dzetah See #2744. BTW, it's already supported in the default theme of VuePress v2 |
Hi @meteorlxy thanks for your answer, I'm going to use VuePress 2 from now on then :) I guess we can decline this PR. |
Summary
What kind of change does this PR introduce? (check at least one)
If changing the UI of default theme, please provide the before/after screenshot:
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
fix #xxx[,#xxx]
, where "xxx" is the issue number)You have tested in the following browsers: (Providing a detailed version will be better.)
If adding a new feature, the PR's description includes:
To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.
Other information:
This PR adds localized messages to the 404 page, matching the language of the URL.
It is still missing some Chinese translations for the default messages which I am not able to provide.