2025-07-27 10:05:37 -07:00
|
|
|
"use client";
|
2025-04-07 23:47:06 -07:00
|
|
|
|
2025-07-27 10:05:37 -07:00
|
|
|
import type { LucideIcon } from "lucide-react";
|
2025-07-27 10:41:15 -07:00
|
|
|
import type * as React from "react";
|
2025-08-02 21:20:36 -07:00
|
|
|
import { useMemo } from "react";
|
feat(i18n): Add next-intl framework with full bilingual support (EN/ZH)
- Implement next-intl framework for scalable i18n
- Add complete Chinese (Simplified) localization
- Support 400+ translated strings across all pages
- Add language switcher with persistent preference
- Zero breaking changes to existing functionality
Framework additions:
- i18n routing and middleware
- LocaleContext for client-side state
- LanguageSwitcher component
- Translation files (en.json, zh.json)
Translated components:
- Homepage: Hero, features, CTA, navbar
- Auth: Login, register
- Dashboard: Main page, layout
- Connectors: Management, add page (all categories)
- Documents: Upload, manage, filters
- Settings: LLM configs, role assignments
- Onboarding: Add provider, assign roles
- Logs: Task logs viewer
Adding a new language now requires only:
1. Create messages/<locale>.json
2. Add locale to i18n/routing.ts
2025-10-26 14:05:46 +08:00
|
|
|
import { useTranslations } from "next-intl";
|
2025-04-07 23:47:06 -07:00
|
|
|
|
|
|
|
|
import {
|
2025-07-27 10:05:37 -07:00
|
|
|
SidebarGroup,
|
2025-07-27 10:41:15 -07:00
|
|
|
SidebarGroupLabel,
|
2025-07-27 10:05:37 -07:00
|
|
|
SidebarMenu,
|
|
|
|
|
SidebarMenuButton,
|
|
|
|
|
SidebarMenuItem,
|
|
|
|
|
} from "@/components/ui/sidebar";
|
2025-04-07 23:47:06 -07:00
|
|
|
|
2025-08-02 21:20:36 -07:00
|
|
|
interface NavSecondaryItem {
|
|
|
|
|
title: string;
|
|
|
|
|
url: string;
|
|
|
|
|
icon: LucideIcon;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-07 23:47:06 -07:00
|
|
|
export function NavSecondary({
|
2025-07-27 10:05:37 -07:00
|
|
|
items,
|
|
|
|
|
...props
|
2025-04-07 23:47:06 -07:00
|
|
|
}: {
|
2025-08-02 21:20:36 -07:00
|
|
|
items: NavSecondaryItem[];
|
2025-04-07 23:47:06 -07:00
|
|
|
} & React.ComponentPropsWithoutRef<typeof SidebarGroup>) {
|
feat(i18n): Add next-intl framework with full bilingual support (EN/ZH)
- Implement next-intl framework for scalable i18n
- Add complete Chinese (Simplified) localization
- Support 400+ translated strings across all pages
- Add language switcher with persistent preference
- Zero breaking changes to existing functionality
Framework additions:
- i18n routing and middleware
- LocaleContext for client-side state
- LanguageSwitcher component
- Translation files (en.json, zh.json)
Translated components:
- Homepage: Hero, features, CTA, navbar
- Auth: Login, register
- Dashboard: Main page, layout
- Connectors: Management, add page (all categories)
- Documents: Upload, manage, filters
- Settings: LLM configs, role assignments
- Onboarding: Add provider, assign roles
- Logs: Task logs viewer
Adding a new language now requires only:
1. Create messages/<locale>.json
2. Add locale to i18n/routing.ts
2025-10-26 14:05:46 +08:00
|
|
|
const t = useTranslations('sidebar');
|
|
|
|
|
|
2025-08-02 21:20:36 -07:00
|
|
|
// Memoize items to prevent unnecessary re-renders
|
|
|
|
|
const memoizedItems = useMemo(() => items, [items]);
|
|
|
|
|
|
2025-07-27 10:05:37 -07:00
|
|
|
return (
|
|
|
|
|
<SidebarGroup {...props}>
|
feat(i18n): Add next-intl framework with full bilingual support (EN/ZH)
- Implement next-intl framework for scalable i18n
- Add complete Chinese (Simplified) localization
- Support 400+ translated strings across all pages
- Add language switcher with persistent preference
- Zero breaking changes to existing functionality
Framework additions:
- i18n routing and middleware
- LocaleContext for client-side state
- LanguageSwitcher component
- Translation files (en.json, zh.json)
Translated components:
- Homepage: Hero, features, CTA, navbar
- Auth: Login, register
- Dashboard: Main page, layout
- Connectors: Management, add page (all categories)
- Documents: Upload, manage, filters
- Settings: LLM configs, role assignments
- Onboarding: Add provider, assign roles
- Logs: Task logs viewer
Adding a new language now requires only:
1. Create messages/<locale>.json
2. Add locale to i18n/routing.ts
2025-10-26 14:05:46 +08:00
|
|
|
<SidebarGroupLabel>{t('search_space')}</SidebarGroupLabel>
|
2025-07-27 10:05:37 -07:00
|
|
|
<SidebarMenu>
|
2025-08-02 21:20:36 -07:00
|
|
|
{memoizedItems.map((item, index) => (
|
2025-07-27 10:05:37 -07:00
|
|
|
<SidebarMenuItem key={`${item.title}-${index}`}>
|
2025-08-02 21:20:36 -07:00
|
|
|
<SidebarMenuButton asChild size="sm" aria-label={item.title}>
|
2025-07-27 10:05:37 -07:00
|
|
|
<a href={item.url}>
|
|
|
|
|
<item.icon />
|
|
|
|
|
<span>{item.title}</span>
|
|
|
|
|
</a>
|
|
|
|
|
</SidebarMenuButton>
|
|
|
|
|
</SidebarMenuItem>
|
|
|
|
|
))}
|
|
|
|
|
</SidebarMenu>
|
|
|
|
|
</SidebarGroup>
|
|
|
|
|
);
|
2025-04-07 23:47:06 -07:00
|
|
|
}
|