feat(ui): add i18n support for profile dropdown

This commit is contained in:
rustmailer
2025-12-26 14:45:43 +08:00
parent 0f3ad83004
commit e8a15695d8
19 changed files with 151 additions and 6 deletions
+7 -6
View File
@@ -33,13 +33,13 @@ import { useCurrentUser } from '@/hooks/use-current-user';
import useDialogState from '@/hooks/use-dialog-state';
import { useMemo } from 'react';
// import { useTranslation } from 'react-i18next';
import { SignOutDialog } from './sign-out-dialog';
import { Link } from '@tanstack/react-router';
import { useTranslation } from 'react-i18next';
export function ProfileDropdown() {
const [open, setOpen] = useDialogState()
// const { t } = useTranslation()
const { t } = useTranslation()
const { data: user } = useCurrentUser()
@@ -50,6 +50,7 @@ export function ProfileDropdown() {
}, [user]);
const fallbackName = user?.username ? user.username.charAt(0).toUpperCase() : 'U';
return (
<>
<DropdownMenu modal={false}>
@@ -57,7 +58,7 @@ export function ProfileDropdown() {
<Button variant="ghost" className="relative h-8 w-8 rounded-full">
<Avatar className="h-8 w-8">
{avatarSrc ? (
<img src={avatarSrc} alt="Avatar" className="h-full w-full object-cover" />
<img src={avatarSrc} alt={t('profile.avatar_alt')} className="h-full w-full object-cover" />
) : (
<AvatarFallback className="text-xs">{fallbackName}</AvatarFallback>
)}
@@ -77,15 +78,15 @@ export function ProfileDropdown() {
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem asChild>
<Link to='/settings/profile'>Profile</Link>
<Link to='/settings/profile'>{t('profile.menu.profile')}</Link>
</DropdownMenuItem>
<DropdownMenuItem asChild>
<Link to='/settings'>Settings</Link>
<Link to='/settings'>{t('profile.menu.settings')}</Link>
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => setOpen(true)}>
Sign out
{t('profile.menu.sign_out')}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
+8
View File
@@ -1370,5 +1370,13 @@
"title": "لم يتم العثور على أدوار",
"desc": "لم تقم بإنشاء أي أدوار مخصصة بعد."
}
},
"profile": {
"avatar_alt": "الصورة الشخصية",
"menu": {
"profile": "الملف الشخصي",
"settings": "الإعدادات",
"sign_out": "تسجيل الخروج"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "Ingen roller fundet",
"desc": "Du har ikke oprettet nogen brugerdefinerede roller endnu."
}
},
"profile": {
"avatar_alt": "Avatar",
"menu": {
"profile": "Profil",
"settings": "Indstillinger",
"sign_out": "Log ud"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "Keine Rollen gefunden",
"desc": "Sie haben noch keine benutzerdefinierten Rollen erstellt."
}
},
"profile": {
"avatar_alt": "Avatar",
"menu": {
"profile": "Profil",
"settings": "Einstellungen",
"sign_out": "Abmelden"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "No Roles Found",
"desc": "You haven't created any custom roles yet."
}
},
"profile": {
"avatar_alt": "Avatar",
"menu": {
"profile": "Profile",
"settings": "Settings",
"sign_out": "Sign out"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "No se encontraron roles",
"desc": "Aún no ha creado ningún rol personalizado."
}
},
"profile": {
"avatar_alt": "Avatar",
"menu": {
"profile": "Perfil",
"settings": "Configuración",
"sign_out": "Cerrar sesión"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "Rooleja ei löytynyt",
"desc": "Et ole vielä luonut mukautettuja rooleja."
}
},
"profile": {
"avatar_alt": "Profiilikuva",
"menu": {
"profile": "Profiili",
"settings": "Asetukset",
"sign_out": "Kirjaudu ulos"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "Aucun rôle trouvé",
"desc": "Vous n'avez pas encore créé de rôles personnalisés."
}
},
"profile": {
"avatar_alt": "Avatar",
"menu": {
"profile": "Profil",
"settings": "Paramètres",
"sign_out": "Se déconnecter"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "Nessun ruolo trovato",
"desc": "Non hai ancora creato alcun ruolo personalizzato."
}
},
"profile": {
"avatar_alt": "Avatar",
"menu": {
"profile": "Profilo",
"settings": "Impostazioni",
"sign_out": "Disconnetti"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "ロールが見つかりません",
"desc": "カスタムロールがまだ作成されていません。"
}
},
"profile": {
"avatar_alt": "アバター",
"menu": {
"profile": "プロフィール",
"settings": "設定",
"sign_out": "ログアウト"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "역할을 찾을 수 없음",
"desc": "사용자 정의 역할이 아직 생성되지 않았습니다."
}
},
"profile": {
"avatar_alt": "아바타",
"menu": {
"profile": "프로필",
"settings": "설정",
"sign_out": "로그아웃"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "Geen rollen gevonden",
"desc": "U heeft nog geen aangepaste rollen gemaakt."
}
},
"profile": {
"avatar_alt": "Avatar",
"menu": {
"profile": "Profiel",
"settings": "Instellingen",
"sign_out": "Uitloggen"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "Ingen roller funnet",
"desc": "Du har ikke opprettet noen egendefinerte roller ennå."
}
},
"profile": {
"avatar_alt": "Avatar",
"menu": {
"profile": "Profil",
"settings": "Innstillinger",
"sign_out": "Logg ut"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "Nie znaleziono ról",
"desc": "Nie utworzyłeś jeszcze żadnych własnych ról."
}
},
"profile": {
"avatar_alt": "Awatar",
"menu": {
"profile": "Profil",
"settings": "Ustawienia",
"sign_out": "Wyloguj się"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "Nenhuma função encontrada",
"desc": "Você ainda não criou funções personalizadas."
}
},
"profile": {
"avatar_alt": "Avatar",
"menu": {
"profile": "Perfil",
"settings": "Configurações",
"sign_out": "Sair"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "Роли не найдены",
"desc": "Вы еще не создали ни одной кастомной роли."
}
},
"profile": {
"avatar_alt": "Аватар",
"menu": {
"profile": "Профиль",
"settings": "Настройки",
"sign_out": "Выйти"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "Inga roller hittades",
"desc": "Du har inte skapat några anpassade roller än."
}
},
"profile": {
"avatar_alt": "Avatar",
"menu": {
"profile": "Profil",
"settings": "Inställningar",
"sign_out": "Logga ut"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "未找到角色",
"desc": "您尚未建立任何自定義角色。點擊下方按鈕開始新增新角色。"
}
},
"profile": {
"avatar_alt": "頭像",
"menu": {
"profile": "個人資料",
"settings": "設定",
"sign_out": "登出"
}
}
}
+8
View File
@@ -1370,5 +1370,13 @@
"title": "未找到角色",
"desc": "您尚未创建任何自定义角色。点击下方按钮开始添加新角色。"
}
},
"profile": {
"avatar_alt": "头像",
"menu": {
"profile": "个人资料",
"settings": "设置",
"sign_out": "退出登录"
}
}
}