-
Notifications
You must be signed in to change notification settings - Fork 906
Expand file tree
/
Copy pathlanguage.tsx
More file actions
90 lines (86 loc) · 2.67 KB
/
language.tsx
File metadata and controls
90 lines (86 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'use client'
import { useTranslations } from 'next-intl'
import { Item, ItemMedia, ItemContent, ItemTitle, ItemDescription, ItemActions } from '@/components/ui/item'
import { Languages } from 'lucide-react'
import { useI18n } from "@/hooks/useI18n"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
export function LanguageSettings() {
const t = useTranslations('settings.general.interface')
const { currentLocale, changeLanguage } = useI18n()
const getLanguageDisplay = (locale: string) => {
switch (locale) {
case "en":
return "English"
case "zh":
return "中文"
case "zh-TW":
return "繁體中文"
case "pt-BR":
return "Português"
case "ja":
return "日本語"
case "vi":
return "Tiếng Việt"
default:
return "中文"
}
}
return (
<Item variant="outline">
<ItemMedia variant="icon"><Languages className="h-4 w-4" /></ItemMedia>
<ItemContent>
<ItemTitle>{t('language.title')}</ItemTitle>
<ItemDescription>{t('language.desc')}</ItemDescription>
</ItemContent>
<ItemActions>
<Select value={currentLocale} onValueChange={changeLanguage}>
<SelectTrigger className="w-[180px]">
<SelectValue>
<div className="flex items-center gap-2">
<span>{getLanguageDisplay(currentLocale)}</span>
</div>
</SelectValue>
</SelectTrigger>
<SelectContent>
<SelectItem value="zh">
<div className="flex items-center gap-2">
<span>中文</span>
</div>
</SelectItem>
<SelectItem value="zh-TW">
<div className="flex items-center gap-2">
<span>繁體中文</span>
</div>
</SelectItem>
<SelectItem value="en">
<div className="flex items-center gap-2">
<span>English</span>
</div>
</SelectItem>
<SelectItem value="ja">
<div className="flex items-center gap-2">
<span>日本語</span>
</div>
</SelectItem>
<SelectItem value="pt-BR">
<div className="flex items-center gap-2">
<span>Português</span>
</div>
</SelectItem>
<SelectItem value="vi">
<div className="flex items-center gap-2">
<span>Tiếng Việt</span>
</div>
</SelectItem>
</SelectContent>
</Select>
</ItemActions>
</Item>
)
}