Skip to content

Commit bf048f9

Browse files
committed
feat: finish trans
1 parent af363e2 commit bf048f9

File tree

17 files changed

+102
-53
lines changed

17 files changed

+102
-53
lines changed

next-i18next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//next-i18next.config.js
22

33
module.exports = {
4-
debug: true,
4+
// debug: true,
55
i18n: {
66
defaultLocale: 'zh',
77
locales: ['zh', 'en'],

public/locales/en/article.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"hot": "Popular",
99
"last": "Latest"
1010
},
11-
"author": "Author: {{name}}",
12-
"read": "Read: {{num}}"
11+
"author": "Author {{name}}",
12+
"read": "Views {{num}}"
1313
}

public/locales/en/common.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"rank": "Ranking",
77
"article": "Articles",
88
"submit": "Submit",
9-
"profile": "My Profile",
10-
"notification": "Notifications",
9+
"profile": "Profile",
10+
"notification": "Notification",
1111
"logout": "Logout"
1212
},
1313
"login": {

public/locales/en/rank.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"rating": "Score",
2323
"change": "Change",
2424
"md_change": "📊",
25-
"model": "Type"
25+
"model": "Model"
2626
}
2727
},
2828
"netcraft": {

public/locales/en/repository.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@
6767
"title": "Comments",
6868
"sort_hot": "Popular",
6969
"sort_new": "Newest",
70-
"total": "{{total}} selected comments",
70+
"total": "{{total}} comments",
7171
"more_reply": "View all {{total}} replies",
7272
"load_more": "Load more...",
73-
"no_comment": "No selected comments yet",
73+
"no_comment": "No comments yet",
7474
"used": "Used",
7575
"unused": "Not Used",
7676
"score": "Rating:",

src/components/buttons/LanguageSwitcher.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// components/LanguageSwitcher.tsx
22
import { useRouter } from 'next/router';
33
import { useEffect, useRef, useState } from 'react';
4+
import { MdTranslate } from 'react-icons/md';
45

56
type LanguageSwitchProps = {
67
type?: string;
@@ -9,29 +10,25 @@ type LanguageSwitchProps = {
910
const LanguageSwitcher = (props: LanguageSwitchProps) => {
1011
const router = useRouter();
1112
const { locale, asPath } = router;
12-
const [selectedLocale, setSelectedLocale] = useState(locale);
1313
const [isHovered, setIsHovered] = useState(false);
1414
const dropdownRef = useRef<HTMLDivElement>(null);
1515
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
1616

1717
useEffect(() => {
1818
const storedLocale = localStorage.getItem('locale');
1919
if (storedLocale) {
20-
setSelectedLocale(storedLocale);
2120
router.push(asPath, asPath, { locale: storedLocale });
2221
} else {
2322
const systemLocale = navigator.language.toLowerCase().startsWith('zh')
2423
? 'zh'
2524
: 'en';
26-
setSelectedLocale(systemLocale);
2725
localStorage.setItem('locale', systemLocale);
2826
router.push(asPath, asPath, { locale: systemLocale });
2927
}
3028
}, []);
3129

3230
const changeLanguage = (language: string) => {
3331
localStorage.setItem('locale', language);
34-
setSelectedLocale(language);
3532
setIsHovered(false);
3633
router.push(asPath, asPath, { locale: language });
3734
};
@@ -74,7 +71,8 @@ const LanguageSwitcher = (props: LanguageSwitchProps) => {
7471
aria-haspopup='true'
7572
aria-expanded={isHovered ? 'true' : 'false'}
7673
>
77-
{selectedLocale === 'zh' ? '中文' : 'EN'}
74+
<MdTranslate size={16} />
75+
{/* {selectedLocale === 'zh' ? '中文' : 'EN'} */}
7876
</button>
7977
</div>
8078

src/components/buttons/ThemeSwitcher.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ const ThemeSwitcher: React.FC<ThemeSwitchProps> = (props: ThemeSwitchProps) => {
3434
<button
3535
type='button'
3636
onClick={onToggle}
37-
className='rounded-md p-2 transition-colors hover:bg-gray-200 dark:hover:bg-gray-700'
37+
className='h-8 items-center justify-center rounded-md border border-gray-300 bg-white px-2 text-sm font-medium text-gray-700 shadow-sm transition-colors duration-200 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-300 dark:hover:bg-gray-700'
3838
aria-label='Toggle theme'
3939
>
40-
{theme == 'light' ? (
40+
{theme == 'dark' ? (
4141
<svg
4242
className='h-4 w-4'
4343
data-testid='geist-icon'

src/components/layout/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ const Header = () => {
8888
{t('header.submit')}
8989
</button>
9090
</RepoModal>
91-
<LanguageSwitcher />
9291
<ThemeSwitcher />
92+
<LanguageSwitcher />
9393
</div>
9494
</nav>
9595
</div>

src/components/periodical/item.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ const PeriodItem: NextPage<PeriodicalItemProps> = ({ item, index }) => {
7070
</div>
7171

7272
{/* markdown 内容渲染 */}
73-
<MDRender className='markdown-body'>{item.description}</MDRender>
73+
<MDRender className='markdown-body'>
74+
{i18n.language == 'en'
75+
? item.description_en
76+
? item.description_en
77+
: item.description
78+
: item.description}
79+
</MDRender>
7480
{/* 图片预览 */}
7581
{item.image_url && (
7682
<div className='my-2 flex justify-center'>

src/components/respository/Info.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ const Info = ({ repo, t, i18n_lang }: RepositoryProps) => {
349349
href={repo.url}
350350
onClick={() => handleClickLink('source', repo.rid)}
351351
>
352-
<h1 className='max-w-[400px] truncate text-ellipsis text-3xl font-semibold'>
352+
<h1 className='max-w-[320px] truncate text-ellipsis text-3xl font-semibold'>
353353
{repo.full_name.length >= 20 ? repo.name : repo.full_name}
354354
</h1>
355355
</CustomLink>

0 commit comments

Comments
 (0)