From 6e162ec297e31d41fcbec9621a258f1ece9f5c4f Mon Sep 17 00:00:00 2001 From: yangdx Date: Tue, 8 Apr 2025 14:59:20 +0800 Subject: [PATCH] Add fallback support for translation missing --- .../src/components/graph/Legend.tsx | 21 +------------------ lightrag_webui/src/i18n.ts | 7 +++++-- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/lightrag_webui/src/components/graph/Legend.tsx b/lightrag_webui/src/components/graph/Legend.tsx index 6e02a4fe..d26d11a3 100644 --- a/lightrag_webui/src/components/graph/Legend.tsx +++ b/lightrag_webui/src/components/graph/Legend.tsx @@ -4,23 +4,6 @@ import { useGraphStore } from '@/stores/graph' import { Card } from '@/components/ui/Card' import { ScrollArea } from '@/components/ui/ScrollArea' -// Predefined node types list -const PREDEFINED_TYPES = [ - 'person', - 'category', - 'geo', - 'location', - 'organization', - 'event', - 'equipment', - 'weapon', - 'animal', - 'unknown', - 'object', - 'group', - 'technology', -] - interface LegendProps { className?: string } @@ -45,9 +28,7 @@ const Legend: React.FC = ({ className }) => { style={{ backgroundColor: color }} /> - {PREDEFINED_TYPES.includes(type.toLowerCase()) - ? t(`graphPanel.nodeTypes.${type.toLowerCase()}`) - : type} + {t(`graphPanel.nodeTypes.${type.toLowerCase()}`, type)} ))} diff --git a/lightrag_webui/src/i18n.ts b/lightrag_webui/src/i18n.ts index d2753a0e..15978ebe 100644 --- a/lightrag_webui/src/i18n.ts +++ b/lightrag_webui/src/i18n.ts @@ -29,11 +29,14 @@ i18n fr: { translation: fr }, ar: { translation: ar } }, - lng: getStoredLanguage(), // 使用存储的语言设置 + lng: getStoredLanguage(), // Use stored language settings fallbackLng: 'en', interpolation: { escapeValue: false - } + }, + // Configuration to handle missing translations + returnEmptyString: false, + returnNull: false, }) // Subscribe to language changes