* Refactor translation imports and update text for localization across settings and system monitor routes - Changed translation import from 'react-i18next' to '@/i18n/react-i18next-compat' in multiple files. - Updated various text strings to use translation keys for better localization support in: - Local API Server settings - MCP Servers settings - Privacy settings - Provider settings - Shortcuts settings - System Monitor - Thread details - Ensured consistent use of translation keys for all user-facing text. Update web-app/src/routes/settings/appearance.tsx Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Update web-app/src/routes/settings/appearance.tsx Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Update web-app/src/locales/vn/settings.json Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Update web-app/src/containers/dialogs/DeleteMCPServerConfirm.tsx Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Update web-app/src/locales/id/common.json Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * Add Chinese (Simplified and Traditional) localization files for various components - Created `tools.json`, `updater.json`, `assistants.json`, `chat.json`, `common.json`, `hub.json`, `logs.json`, `mcp-servers.json`, `provider.json`, `providers.json`, `settings.json`, `setup.json`, `system-monitor.json`, `tool-approval.json` in both `zh-CN` and `zh-TW` locales. - Added translations for tool approval, updater notifications, assistant management, chat interface, common UI elements, hub interactions, logging messages, MCP server configurations, provider management, settings options, setup instructions, and system monitoring. * Refactor localization strings for improved clarity and consistency in English, Indonesian, and Vietnamese settings files * Fix missing key and reword * fix pr comment --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { useGeneralSetting } from '@/hooks/useGeneralSetting'
|
|
import { useAppTranslation } from '@/i18n'
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from '@/components/ui/dropdown-menu'
|
|
import { cn } from '@/lib/utils'
|
|
|
|
const LANGUAGES = [
|
|
{ value: 'en', label: 'English' },
|
|
{ value: 'id', label: 'Bahasa' },
|
|
{ value: 'vn', label: 'Tiếng Việt' },
|
|
{ value: 'zh-CN', label: '简体中文' },
|
|
{ value: 'zh-TW', label: '繁體中文' },
|
|
]
|
|
|
|
export default function LanguageSwitcher() {
|
|
const { i18n, t } = useAppTranslation()
|
|
const { setCurrentLanguage, currentLanguage } = useGeneralSetting()
|
|
|
|
const changeLanguage = (lng: string) => {
|
|
i18n.changeLanguage(lng)
|
|
setCurrentLanguage(lng as Language)
|
|
}
|
|
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<span
|
|
title={t('common:changeLanguage')}
|
|
className="flex cursor-pointer items-center gap-1 px-2 py-1 rounded-sm bg-main-view-fg/15 text-sm outline-none text-main-view-fg font-medium"
|
|
>
|
|
{LANGUAGES.find(
|
|
(lang: { value: string; label: string }) =>
|
|
lang.value === currentLanguage
|
|
)?.label || t('common:english')}
|
|
</span>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-24">
|
|
{LANGUAGES.map((lang) => (
|
|
<DropdownMenuItem
|
|
key={lang.value}
|
|
className={cn(
|
|
'cursor-pointer my-0.5',
|
|
currentLanguage === lang.value && 'bg-main-view-fg/5'
|
|
)}
|
|
onClick={() => changeLanguage(lang.value)}
|
|
>
|
|
{lang.label}
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
}
|