feat(i18n): integrate internationalization into sidebar, title bar, and settings components

- Added useI18n hook to Sidebar and TitleBar components for translation support.
- Updated sidebar navigation items to use translation keys instead of hardcoded labels.
- Enhanced TitleBar buttons with localized titles for minimize, maximize, and close actions.
- Expanded i18n constants to include new namespaces for sidebar and login.
- Implemented translation messages for sidebar, settings, and login components in English, Chinese, and Japanese.
- Refactored Knowledge and Skills pages to utilize useLocale for locale management.
- Updated Login page to display localized text for form labels, placeholders, and error messages.
- Enhanced Account and General settings panels with localized titles and descriptions.
- Modified SettingMenu to use translation keys for menu items.
This commit is contained in:
DEV_DSW
2026-04-17 17:16:18 +08:00
parent bc3de923ed
commit eca70425cf
16 changed files with 533 additions and 141 deletions

View File

@@ -1,5 +1,6 @@
import { useLocation, useNavigate } from 'react-router-dom';
import { Book, Clock, Code, Cpu, House, Puzzle, Settings } from 'lucide-react';
import { useI18n } from '../../i18n';
import { NAV_ITEMS, normalizeWorkspacePath } from '../../router/routes';
const MENU_MARKS: Record<string, typeof House> = {
@@ -15,6 +16,7 @@ const MENU_MARKS: Record<string, typeof House> = {
export default function Sidebar() {
const location = useLocation();
const navigate = useNavigate();
const { t } = useI18n();
const currentId = normalizeWorkspacePath(location.pathname);
return (
@@ -53,7 +55,7 @@ export default function Sidebar() {
className="mt-[4px] mb-[8px] text-[14px] hover:text-[#2B7FFF]"
style={{ color: active ? '#2B7FFF' : '#525866' }}
>
{item.label}
{t(item.labelKey)}
</div>
</button>
</div>

View File

@@ -1,8 +1,11 @@
import { useI18n } from '../../i18n';
type TitleBarProps = {
variant?: 'default' | 'light';
};
export default function TitleBar({ variant = 'default' }: TitleBarProps) {
const { t } = useI18n();
const platform = (window as any).api?.platform ?? '';
if (platform === 'linux') return null;
@@ -34,7 +37,7 @@ export default function TitleBar({ variant = 'default' }: TitleBarProps) {
className={['flex h-full w-11 items-center justify-center hover:bg-[#999] hover:text-white transition-colors', iconColorClass].join(
' ',
)}
title="Minimize"
title={t('window.minimize')}
onClick={() => {
(window as any).api?.windowMinimize?.();
}}
@@ -46,7 +49,7 @@ export default function TitleBar({ variant = 'default' }: TitleBarProps) {
className={['flex h-full w-11 items-center justify-center hover:bg-[#999] hover:text-white transition-colors', iconColorClass].join(
' ',
)}
title="Maximize"
title={t('window.maximize')}
onClick={() => {
(window as any).api?.windowMaximize?.();
}}
@@ -58,7 +61,7 @@ export default function TitleBar({ variant = 'default' }: TitleBarProps) {
className={['flex h-full w-11 items-center justify-center hover:bg-[#ff0000] hover:text-white transition-colors', iconColorClass].join(
' ',
)}
title="Close"
title={t('window.close')}
onClick={() => {
(window as any).api?.windowClose?.();
}}