Files
DeepTutor/web/components/sidebar/ResourcesNavigation.tsx
Botong dd29ff5a0a fix(i18n): sync frontend output language and remove zh-only UI fallbacks
Align frontend model-output language propagation and eliminate Simplified-Chinese-only UI shortcuts across chat, settings, books, reading, memory, and workspace surfaces:

- Preserve Traditional Chinese (zh-tw/zh-hk/zh-mo/zh-hant) and native aliases in resolveResponseLanguage(), and introduce shared effectiveResponseLanguage() and subscribeResponseLanguage() helpers.
- Sync response_language with language in SettingsStore when both were aligned, while preserving intentional divergence and clearing auto-synced pending response_language if an external desktop menu overrides language.
- Preserve per-conversation replyLanguageOverride when regenerating without a replay snapshot and subscribe ChatWorkspace's default reply-language label to live response_language changes.
- Route Book Creator, Book Chat fallback, Memory evolution/update, and Reading extension actions through effectiveResponseLanguage() instead of the UI language, and preserve zh-Hant in translationTarget().
- Route remaining zh ? ... : t(...) branches, hardcoded Memory labels, and binary zh/en date formatting through i18next and normalizeLanguage() so Traditional Chinese and all non-Simplified locales render through catalogs without modifying locale JSON files.

Related to #2933
Related to #684
2026-11-29 02:13:55 -06:00

58 lines
1.9 KiB
TypeScript

'use client'
import { useTranslation } from 'react-i18next'
import { NavigationRow, OverviewRow, Section } from './NavigationPrimitives'
import { PersonalizationShelfIcon, ResourcesShelfIcon } from './ShelfIcons'
import {
DASHBOARD_GROUPS,
PERSONALIZATION_GROUPS,
visibleGroups,
type DashboardGroup,
} from '@/components/space/dashboard-groups'
import { useCapabilityFilter } from '@/features/capabilities/useCapabilityCatalog'
import { navVisibleUnderPolicy } from './nav-entries'
function Shelf({ groups, titled }: { groups: DashboardGroup[]; titled: boolean }) {
const { t } = useTranslation()
const available = useCapabilityFilter()
return visibleGroups(groups, available).map(group => {
const rows = group.items.map(row => (
<NavigationRow key={row.key} href={row.href} label={t(row.title.en)} icon={row.icon} />
))
return titled ? (
<Section key={group.label.en} title={t(group.label.en)}>
{rows}
</Section>
) : (
<div key={group.label.en} className="dt-navigation-section">
{rows}
</div>
)
})
}
/** The workspace's materials. */
export function ResourcesNavigation() {
const { t } = useTranslation()
return (
<>
<OverviewRow href="/space" label={t('navigation.allResources')} icon={ResourcesShelfIcon} />
<Shelf groups={DASHBOARD_GROUPS} titled />
</>
)
}
/** What travels with the account into every workspace. */
export function PersonalizationNavigation({ allowedSurfaces }: { allowedSurfaces: readonly string[] | null }) {
const { t } = useTranslation()
const groups = PERSONALIZATION_GROUPS.map(group => ({
...group,
items: group.items.filter(item => item.href !== '/agents' || navVisibleUnderPolicy(item.href, allowedSurfaces)),
}))
return (
<>
<OverviewRow href="/personalization" label={t('navigation.allPersonalization')} icon={PersonalizationShelfIcon} />
<Shelf groups={groups} titled={false} />
</>
)
}