Skip to content

Commit

Permalink
feat(localization): introduce localization to 404 texts
Browse files Browse the repository at this point in the history
  • Loading branch information
YesYouKenSpace committed Feb 18, 2025
1 parent 1c2ba49 commit 134afd7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/SEO.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const getSEOMeta = (props, router, locale) => {
}
case '/404':
return {
title: `${siteInfo?.title} | 页面找不到啦`,
title: `${siteInfo?.title} | ${locale.NAV.PAGE_NOT_FOUND}`,
image: `${siteInfo?.pageCover}`
}
case '/tag':
Expand Down
4 changes: 3 additions & 1 deletion lib/lang/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export default {
NAVIGATOR: 'NAV',
ABOUT: 'About',
MAIL: 'E-Mail',
ARCHIVE: 'Archive'
ARCHIVE: 'Archive',
PAGE_NOT_FOUND: 'Page Not Found',
PAGE_NOT_FOUND_REDIRECT: 'Page Not Found, Redirecting to Home Page...'
},
COMMON: {
THEME: 'Theme',
Expand Down
4 changes: 3 additions & 1 deletion lib/lang/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export default {
ABOUT: '关于',
NAVIGATOR: '导航',
MAIL: '邮箱',
ARCHIVE: '归档'
ARCHIVE: '归档',
PAGE_NOT_FOUND: '页面找不到啦',
PAGE_NOT_FOUND_REDIRECT: '页面无法加载,即将返回首页'
},
COMMON: {
THEME: 'Theme',
Expand Down
3 changes: 2 additions & 1 deletion themes/fukasawa/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ const LayoutArchive = props => {
*/
const Layout404 = props => {
const router = useRouter()
const { locale } = useGlobal()
useEffect(() => {
// 延时3秒如果加载失败就返回首页
setTimeout(() => {
Expand All @@ -232,7 +233,7 @@ const Layout404 = props => {
<div className='dark:text-gray-200'>
<h2 className='inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top'><i className='mr-2 fas fa-spinner animate-spin' />404</h2>
<div className='inline-block text-left h-32 leading-10 items-center'>
<h2 className='m-0 p-0'>页面无法加载,即将返回首页</h2>
<h2 className='m-0 p-0'>{locale.NAV.PAGE_NOT_FOUND_REDIRECT}</h2>
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion themes/game/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ const LayoutSlug = props => {
*/
const Layout404 = props => {
const router = useRouter()
const { locale } = useGameGlobal()
useEffect(() => {
// 延时3秒如果加载失败就返回首页
setTimeout(() => {
Expand All @@ -371,7 +372,7 @@ const Layout404 = props => {
<div className='dark:text-gray-200'>
<h2 className='inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top'><i className='mr-2 fas fa-spinner animate-spin' />404</h2>
<div className='inline-block text-left h-32 leading-10 items-center'>
<h2 className='m-0 p-0'>页面无法加载,即将返回首页</h2>
<h2 className='m-0 p-0'>{locale.NAV.PAGE_NOT_FOUND_REDIRECT}</h2>
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion themes/gitbook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ const LayoutArchive = props => {
*/
const Layout404 = props => {
const router = useRouter()
const { locale } = useGlobal()
useEffect(() => {
// 延时3秒如果加载失败就返回首页
setTimeout(() => {
Expand All @@ -455,7 +456,7 @@ const Layout404 = props => {
<div className='dark:text-gray-200'>
<h2 className='inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top'><i className='mr-2 fas fa-spinner animate-spin' />404</h2>
<div className='inline-block text-left h-32 leading-10 items-center'>
<h2 className='m-0 p-0'>页面无法加载,即将返回首页</h2>
<h2 className='m-0 p-0'>{locale.NAV.PAGE_NOT_FOUND_REDIRECT}</h2>
</div>
</div>
</div>
Expand Down

0 comments on commit 134afd7

Please sign in to comment.