Skip to content

Commit 978413e

Browse files
authored
feat(i18n): complete missing translations (#85)
1 parent a8d9db5 commit 978413e

11 files changed

Lines changed: 348 additions & 20 deletions

File tree

apps/web/src/components/ui/date-range-indicator/DateRangeIndicator.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { AnimatePresence, m } from 'motion/react'
22
import { memo } from 'react'
3+
import { useTranslation } from 'react-i18next'
34

45
import { useMobile } from '~/hooks/useMobile'
56
import { clsxm } from '~/lib/cn'
@@ -14,6 +15,11 @@ interface DateRangeIndicatorProps {
1415

1516
export const DateRangeIndicator = memo(
1617
({ dateRange, location, isVisible, className }: DateRangeIndicatorProps) => {
18+
const { t } = useTranslation()
19+
const translateDay = (day: string | number) => t(`date.day.${day}` as any)
20+
const translateMonth = (month: string | number) =>
21+
t(`date.month.${month}` as any)
22+
1723
// 解析日期范围,提取主要的日期信息
1824
const parseMainDate = (range: string) => {
1925
// 匹配跨年日期范围格式 "2022年3月 - 2023年5月"
@@ -22,7 +28,8 @@ export const DateRangeIndicator = memo(
2228
)
2329
if (crossYearMatch) {
2430
const [, startYear, startMonth, endYear, endMonth] = crossYearMatch
25-
return `${startMonth}${startYear}${endMonth}${endYear}`
31+
// return `${startMonth}月 ${startYear} – ${endMonth}月 ${endYear}`
32+
return `${translateMonth(startMonth)} ${startYear} - ${translateMonth(endMonth)} ${endYear}`
2633
}
2734

2835
// 匹配类似 "2022年3月30日 - 5月2日" 的格式
@@ -32,21 +39,24 @@ export const DateRangeIndicator = memo(
3239
if (singleYearDayMatch) {
3340
const [, year, startMonth, startDay, endMonth, endDay] =
3441
singleYearDayMatch
35-
return `${startMonth}${startDay}日–${endMonth}${endDay}日, ${year}`
42+
// return `${startMonth}月${startDay}日–${endMonth}月${endDay}日, ${year}`
43+
return `${translateMonth(startMonth)} ${translateDay(startDay)} - ${translateMonth(endMonth)} ${translateDay(endDay)} ${year}`
3644
}
3745

3846
// 匹配类似 "2022年3月 - 5月" 的格式
3947
const monthRangeMatch = range.match(/(\d{4})(\d+)\s*-\s*(\d+)/)
4048
if (monthRangeMatch) {
4149
const [, year, startMonth, endMonth] = monthRangeMatch
42-
return `${startMonth}月–${endMonth}月, ${year}`
50+
// return `${startMonth}月–${endMonth}月, ${year}`
51+
return `${translateMonth(startMonth)} - ${translateMonth(endMonth)} ${year}`
4352
}
4453

4554
// 匹配单个日期
4655
const singleDateMatch = range.match(/(\d{4})(\d+)(\d+)/)
4756
if (singleDateMatch) {
4857
const [, year, month, day] = singleDateMatch
49-
return `${month}${day}日, ${year}`
58+
// return `${month}月${day}日, ${year}`
59+
return `${translateMonth(month)} ${translateDay(day)} ${year}`
5060
}
5161

5262
// 默认返回原始字符串

apps/web/src/components/ui/map/ClusterPhotoGrid.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ export const ClusterPhotoGrid = ({
1818
// 最多显示 6 张照片
1919
const displayPhotos = photos.slice(0, 6)
2020
const remainingCount = Math.max(0, photos.length - 6)
21-
const { i18n } = useTranslation()
21+
const { t, i18n } = useTranslation()
2222

2323
return (
2424
<div className="space-y-3">
2525
{/* 标题 */}
2626
<div className="flex items-center justify-between">
2727
<h3 className="text-text text-sm font-semibold">
28-
{photos.length} 张照片
28+
{t('explory.cluster.photos', { count: photos.length })}
2929
</h3>
30-
<div className="text-text-secondary text-xs">点击查看详情</div>
30+
<div className="text-text-secondary text-xs">{t('explory.cluster.click.details')}</div>
3131
</div>
3232

3333
{/* 照片网格 */}
@@ -104,7 +104,7 @@ export const ClusterPhotoGrid = ({
104104
<div className="text-text text-lg font-bold">
105105
+{remainingCount}
106106
</div>
107-
<div className="text-text-secondary text-xs">更多</div>
107+
<div className="text-text-secondary text-xs">{t('explory.cluster.more')}</div>
108108
</div>
109109
</m.div>
110110
)}

apps/web/src/components/ui/map/shared/MapControls.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { m } from 'motion/react'
2+
import { useTranslation } from 'react-i18next'
23
import { useMap } from 'react-map-gl/maplibre'
34

45
import type { MapControlsProps } from './types'
56

67
export const MapControls = ({ onGeolocate }: MapControlsProps) => {
78
const { current: map } = useMap()
9+
const { t } = useTranslation()
810

911
const handleZoomIn = () => {
1012
if (map) {
@@ -66,7 +68,7 @@ export const MapControls = ({ onGeolocate }: MapControlsProps) => {
6668
type="button"
6769
onClick={handleZoomIn}
6870
className="group hover:bg-fill-secondary active:bg-fill-tertiary flex h-12 w-12 items-center justify-center transition-colors"
69-
title="放大"
71+
title={t('explory.controls.zoom.in')}
7072
>
7173
<i className="i-mingcute-add-line text-text size-5 transition-transform group-hover:scale-110 group-active:scale-95" />
7274
</button>
@@ -79,7 +81,7 @@ export const MapControls = ({ onGeolocate }: MapControlsProps) => {
7981
type="button"
8082
onClick={handleZoomOut}
8183
className="group hover:bg-fill-secondary active:bg-fill-tertiary flex h-12 w-12 items-center justify-center transition-colors"
82-
title="缩小"
84+
title={t('explory.controls.zoom.out')}
8385
>
8486
<i className="i-mingcute-minimize-line text-text size-5 transition-transform group-hover:scale-110 group-active:scale-95" />
8587
</button>
@@ -91,7 +93,7 @@ export const MapControls = ({ onGeolocate }: MapControlsProps) => {
9193
type="button"
9294
onClick={handleCompass}
9395
className="group hover:bg-fill-secondary active:bg-fill-tertiary flex h-12 w-12 items-center justify-center transition-colors"
94-
title="重置方向"
96+
title={t('explory.controls.compass')}
9597
>
9698
<i className="i-mingcute-navigation-line text-text size-5 transition-transform group-hover:scale-110 group-active:scale-95" />
9799
</button>
@@ -103,7 +105,7 @@ export const MapControls = ({ onGeolocate }: MapControlsProps) => {
103105
type="button"
104106
onClick={handleGeolocate}
105107
className="group hover:bg-fill-secondary active:bg-fill-tertiary flex h-12 w-12 items-center justify-center transition-colors"
106-
title="定位到我的位置"
108+
title={t('explory.controls.locate')}
107109
>
108110
<i className="i-mingcute-location-fill text-text size-5 transition-transform group-hover:scale-110 group-active:scale-95" />
109111
</button>

apps/web/src/components/ui/slider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ export const Slider = ({
174174

175175
{/* 当前值显示 */}
176176
<div className="mt-8 text-center text-sm font-medium text-gray-700 dark:text-gray-300">
177-
{value === 'auto' ? finalAutoLabel : `${value} 列`}
177+
{value === 'auto'
178+
? finalAutoLabel
179+
: t('slider.columns', { count: value } as any)}
178180
</div>
179181
</div>
180182
)

apps/web/src/pages/explory/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ const ExploryPageSkeleton = () => {
5858
}
5959

6060
const ExploryPageError = () => {
61+
const { t } = useTranslation()
62+
6163
return (
6264
<m.div
6365
className="flex h-full w-full items-center justify-center"
@@ -80,15 +82,15 @@ const ExploryPageError = () => {
8082
animate={{ opacity: 1, y: 0 }}
8183
transition={{ duration: 0.3, delay: 0.2 }}
8284
>
83-
地图加载失败
85+
{t('explory.map.error.title')}
8486
</m.div>
8587
<m.p
8688
className="text-sm text-red-600 dark:text-red-400"
8789
initial={{ opacity: 0, y: 5 }}
8890
animate={{ opacity: 1, y: 0 }}
8991
transition={{ duration: 0.3, delay: 0.3 }}
9092
>
91-
请检查网络连接或刷新页面重试
93+
{t('explory.map.error.description')}
9294
</m.p>
9395
</div>
9496
</m.div>

locales/app/en.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,49 @@
2626
"action.tag.not-found": "No tags match your search",
2727
"action.tag.search": "Search Tags",
2828
"action.view.github": "View GitHub Repository",
29+
"date.day.1": "1st",
30+
"date.day.10": "10th",
31+
"date.day.11": "11th",
32+
"date.day.12": "12th",
33+
"date.day.13": "13th",
34+
"date.day.14": "14th",
35+
"date.day.15": "15th",
36+
"date.day.16": "16th",
37+
"date.day.17": "17th",
38+
"date.day.18": "18th",
39+
"date.day.19": "19th",
40+
"date.day.2": "2nd",
41+
"date.day.20": "20th",
42+
"date.day.21": "21st",
43+
"date.day.22": "22nd",
44+
"date.day.23": "23rd",
45+
"date.day.24": "24th",
46+
"date.day.25": "25th",
47+
"date.day.26": "26th",
48+
"date.day.27": "27th",
49+
"date.day.28": "28th",
50+
"date.day.29": "29th",
51+
"date.day.3": "3rd",
52+
"date.day.30": "30th",
53+
"date.day.31": "31st",
54+
"date.day.4": "4th",
55+
"date.day.5": "5th",
56+
"date.day.6": "6th",
57+
"date.day.7": "7th",
58+
"date.day.8": "8th",
59+
"date.day.9": "9th",
60+
"date.month.1": "Jan",
61+
"date.month.10": "Oct",
62+
"date.month.11": "Nov",
63+
"date.month.12": "Dec",
64+
"date.month.2": "Feb",
65+
"date.month.3": "Mar",
66+
"date.month.4": "Apr",
67+
"date.month.5": "May",
68+
"date.month.6": "Jun",
69+
"date.month.7": "Jul",
70+
"date.month.8": "Aug",
71+
"date.month.9": "Sep",
2972
"error.feedback": "Still having this issue? Please provide feedback on Github, thank you!",
3073
"error.reload": "Reload",
3174
"error.submit.issue": "Submit Issue",
@@ -232,6 +275,14 @@
232275
"exif.white.balance.title": "White Balance",
233276
"explory.back.to.gallery": "Back to Gallery",
234277
"explory.clear.selection": "Clear Selection",
278+
"explory.cluster.click.details": "Click to view details",
279+
"explory.cluster.more": "More",
280+
"explory.cluster.photos_one": "{{count}} photo",
281+
"explory.cluster.photos_other": "{{count}} photos",
282+
"explory.controls.compass": "Reset bearing",
283+
"explory.controls.locate": "Locate me",
284+
"explory.controls.zoom.in": "Zoom in",
285+
"explory.controls.zoom.out": "Zoom out",
235286
"explory.explore.map": "Explore Map",
236287
"explory.found.locations": "Found {{count}} shooting locations",
237288
"explory.loading.map": "Loading Map...",
@@ -285,6 +336,7 @@
285336
"photo.webgl.unavailable": "WebGL is unavailable, unable to render image",
286337
"photo.zoom.hint": "Double-tap or pinch to zoom",
287338
"slider.auto": "Auto",
339+
"slider.columns": "{{count}} column",
288340
"video.codec.keyword": "Encoder",
289341
"video.conversion.cached.result": "Using cached result",
290342
"video.conversion.codec.fallback": "No MP4 codec found that supports this resolution. Falling back to WebM.",

locales/app/jp.json

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,49 @@
2626
"action.tag.not-found": "検索に一致するタグがありません",
2727
"action.tag.search": "タグ検索",
2828
"action.view.github": "GitHub リポジトリを表示",
29+
"date.day.1": "1日",
30+
"date.day.10": "10日",
31+
"date.day.11": "11日",
32+
"date.day.12": "12日",
33+
"date.day.13": "13日",
34+
"date.day.14": "14日",
35+
"date.day.15": "15日",
36+
"date.day.16": "16日",
37+
"date.day.17": "17日",
38+
"date.day.18": "18日",
39+
"date.day.19": "19日",
40+
"date.day.2": "2日",
41+
"date.day.20": "20日",
42+
"date.day.21": "21日",
43+
"date.day.22": "22日",
44+
"date.day.23": "23日",
45+
"date.day.24": "24日",
46+
"date.day.25": "25日",
47+
"date.day.26": "26日",
48+
"date.day.27": "27日",
49+
"date.day.28": "28日",
50+
"date.day.29": "29日",
51+
"date.day.3": "3日",
52+
"date.day.30": "30日",
53+
"date.day.31": "31日",
54+
"date.day.4": "4日",
55+
"date.day.5": "5日",
56+
"date.day.6": "6日",
57+
"date.day.7": "7日",
58+
"date.day.8": "8日",
59+
"date.day.9": "9日",
60+
"date.month.1": "1月",
61+
"date.month.10": "10月",
62+
"date.month.11": "11月",
63+
"date.month.12": "12月",
64+
"date.month.2": "2月",
65+
"date.month.3": "3月",
66+
"date.month.4": "4月",
67+
"date.month.5": "5月",
68+
"date.month.6": "6月",
69+
"date.month.7": "7月",
70+
"date.month.8": "8月",
71+
"date.month.9": "9月",
2972
"error.feedback": "まだ問題が解決しませんか?GitHub でフィードバックをお願いします。",
3073
"error.reload": "再読み込み",
3174
"error.submit.issue": "問題を報告",
@@ -231,6 +274,14 @@
231274
"exif.white.balance.title": "ホワイトバランス",
232275
"explory.back.to.gallery": "ギャラリーに戻る",
233276
"explory.clear.selection": "選択をクリア",
277+
"explory.cluster.click.details": "クリックして詳細を表示",
278+
"explory.cluster.more": "もっと",
279+
"explory.cluster.photos_one": "写真{{count}}枚",
280+
"explory.cluster.photos_other": "写真{{count}}枚",
281+
"explory.controls.compass": "方向をリセット",
282+
"explory.controls.locate": "現在地を取得",
283+
"explory.controls.zoom.in": "拡大",
284+
"explory.controls.zoom.out": "縮小",
234285
"explory.explore.map": "マップを探索",
235286
"explory.found.locations": "{{count}} 個の撮影場所を発見",
236287
"explory.loading.map": "マップを読み込み中...",
@@ -281,6 +332,7 @@
281332
"photo.webgl.unavailable": "WebGL が利用できないため、画像をレンダリングできません",
282333
"photo.zoom.hint": "ダブルタップまたはピンチしてズーム",
283334
"slider.auto": "自動",
335+
"slider.columns": "{{count}} 列",
284336
"video.codec.keyword": "エンコーダー",
285337
"video.conversion.cached.result": "キャッシュされた結果を使用",
286338
"video.conversion.codec.fallback": "この解像度でサポートされている MP4 コーデックが見つかりません。WebM にフォールバックします。",
@@ -298,4 +350,4 @@
298350
"video.conversion.webcodecs.not.supported": "このブラウザは WebCodecs をサポートしていません",
299351
"video.format.mov.not.supported": "ブラウザが MOV 形式をサポートしていないため、変換が必要です",
300352
"video.format.mov.supported": "ブラウザが MOV 形式をネイティブでサポートしているため、変換をスキップします"
301-
}
353+
}

0 commit comments

Comments
 (0)