Skip to content

Commit 61bdfef

Browse files
authored
Merge pull request tangly1024#3233 from YesYouKenSpace/feat/localization-404
feat(localization): introduce localization to 404 texts
2 parents 5c77c18 + 504f5fb commit 61bdfef

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

components/SEO.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ const getSEOMeta = (props, router, locale) => {
247247
}
248248
case '/404':
249249
return {
250-
title: `${siteInfo?.title} | 页面找不到啦`,
250+
title: `${siteInfo?.title} | ${locale.NAV.PAGE_NOT_FOUND}`,
251251
image: `${siteInfo?.pageCover}`
252252
}
253253
case '/tag':

lib/lang/en-US.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export default {
1717
NAVIGATOR: 'NAV',
1818
ABOUT: 'About',
1919
MAIL: 'E-Mail',
20-
ARCHIVE: 'Archive'
20+
ARCHIVE: 'Archive',
21+
PAGE_NOT_FOUND: 'Page Not Found',
22+
PAGE_NOT_FOUND_REDIRECT: 'Page Not Found, Redirecting to Home Page...'
2123
},
2224
COMMON: {
2325
THEME: 'Theme',

lib/lang/zh-CN.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export default {
1717
ABOUT: '关于',
1818
NAVIGATOR: '导航',
1919
MAIL: '邮箱',
20-
ARCHIVE: '归档'
20+
ARCHIVE: '归档',
21+
PAGE_NOT_FOUND: '页面找不到啦',
22+
PAGE_NOT_FOUND_REDIRECT: '页面无法加载,即将返回首页'
2123
},
2224
COMMON: {
2325
THEME: 'Theme',

themes/fukasawa/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ const LayoutArchive = props => {
215215
*/
216216
const Layout404 = props => {
217217
const router = useRouter()
218+
const { locale } = useGlobal()
218219
useEffect(() => {
219220
// 延时3秒如果加载失败就返回首页
220221
setTimeout(() => {
@@ -232,7 +233,7 @@ const Layout404 = props => {
232233
<div className='dark:text-gray-200'>
233234
<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>
234235
<div className='inline-block text-left h-32 leading-10 items-center'>
235-
<h2 className='m-0 p-0'>页面无法加载,即将返回首页</h2>
236+
<h2 className='m-0 p-0'>{locale.NAV.PAGE_NOT_FOUND_REDIRECT}</h2>
236237
</div>
237238
</div>
238239
</div>

themes/game/index.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import NotionPage from '@/components/NotionPage'
66
import { PWA as initialPWA } from '@/components/PWA'
77
import ShareBar from '@/components/ShareBar'
88
import { siteConfig } from '@/lib/config'
9+
import { useGlobal } from '@/lib/global'
910
import { loadWowJS } from '@/lib/plugins/wow'
1011
import { deepClone, isBrowser, shuffleArray } from '@/lib/utils'
1112
import Link from 'next/link'
13+
import { useRouter } from 'next/router'
1214
import { createContext, useContext, useEffect, useRef, useState } from 'react'
1315
import Announcement from './components/Announcement'
1416
import { ArticleLock } from './components/ArticleLock'
@@ -30,7 +32,6 @@ import SideBarContent from './components/SideBarContent'
3032
import SideBarDrawer from './components/SideBarDrawer'
3133
import CONFIG from './config'
3234
import { Style } from './style'
33-
import { useRouter } from 'next/router'
3435

3536
// const AlgoliaSearchModal = dynamic(() => import('@/components/AlgoliaSearchModal'), { ssr: false })
3637

@@ -354,6 +355,7 @@ const LayoutSlug = props => {
354355
*/
355356
const Layout404 = props => {
356357
const router = useRouter()
358+
const { locale } = useGlobal()
357359
useEffect(() => {
358360
// 延时3秒如果加载失败就返回首页
359361
setTimeout(() => {
@@ -366,16 +368,21 @@ const Layout404 = props => {
366368
}, 3000)
367369
}, [])
368370

369-
return <>
370-
<div className='md:-mt-20 text-black w-full h-screen text-center justify-center content-center items-center flex flex-col'>
371-
<div className='dark:text-gray-200'>
372-
<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>
373-
<div className='inline-block text-left h-32 leading-10 items-center'>
374-
<h2 className='m-0 p-0'>页面无法加载,即将返回首页</h2>
375-
</div>
376-
</div>
371+
return (
372+
<>
373+
<div className='md:-mt-20 text-black w-full h-screen text-center justify-center content-center items-center flex flex-col'>
374+
<div className='dark:text-gray-200'>
375+
<h2 className='inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top'>
376+
<i className='mr-2 fas fa-spinner animate-spin' />
377+
404
378+
</h2>
379+
<div className='inline-block text-left h-32 leading-10 items-center'>
380+
<h2 className='m-0 p-0'>{locale.NAV.PAGE_NOT_FOUND_REDIRECT}</h2>
381+
</div>
377382
</div>
383+
</div>
378384
</>
385+
)
379386
}
380387

381388
/**

themes/gitbook/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ const LayoutArchive = props => {
438438
*/
439439
const Layout404 = props => {
440440
const router = useRouter()
441+
const { locale } = useGlobal()
441442
useEffect(() => {
442443
// 延时3秒如果加载失败就返回首页
443444
setTimeout(() => {
@@ -455,7 +456,7 @@ const Layout404 = props => {
455456
<div className='dark:text-gray-200'>
456457
<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>
457458
<div className='inline-block text-left h-32 leading-10 items-center'>
458-
<h2 className='m-0 p-0'>页面无法加载,即将返回首页</h2>
459+
<h2 className='m-0 p-0'>{locale.NAV.PAGE_NOT_FOUND_REDIRECT}</h2>
459460
</div>
460461
</div>
461462
</div>

0 commit comments

Comments
 (0)