From b093ed2b4fcda19b70fca0293a63ceefca0ced28 Mon Sep 17 00:00:00 2001 From: goddonebianu Date: Tue, 6 Jan 2026 16:04:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- messages/de-DE.json | 28 +++++++++++++++++ messages/en-US.json | 28 +++++++++++++++++ messages/fr-FR.json | 28 +++++++++++++++++ messages/it-IT.json | 28 +++++++++++++++++ messages/ja-JP.json | 28 +++++++++++++++++ messages/ko-KR.json | 28 +++++++++++++++++ messages/ug-CN.json | 28 +++++++++++++++++ messages/zh-CN.json | 28 +++++++++++++++++ .../(features)/dictionary/DictionaryEntry.tsx | 2 +- .../(features)/dictionary/DictionaryPage.tsx | 28 +++++++++++------ src/app/(features)/dictionary/SearchForm.tsx | 31 +++++++++++-------- .../(features)/dictionary/SearchResult.tsx | 26 +++++++++------- src/app/(features)/dictionary/constants.ts | 14 ++++----- 13 files changed, 282 insertions(+), 43 deletions(-) diff --git a/messages/de-DE.json b/messages/de-DE.json index 0d468af..ef9b558 100644 --- a/messages/de-DE.json +++ b/messages/de-DE.json @@ -190,5 +190,33 @@ "error": "Textpaar konnte nicht zum Ordner hinzugefügt werden" }, "autoSave": "Automatisch speichern" + }, + "dictionary": { + "title": "Wörterbuch", + "description": "Wörter und Ausdrücke mit detaillierten Definitionen und Beispielen nachschlagen", + "searchPlaceholder": "Wort oder Ausdruck zum Nachschlagen eingeben...", + "searching": "Suche...", + "search": "Suchen", + "languageSettings": "Spracheinstellungen", + "queryLanguage": "Abfragesprache", + "queryLanguageHint": "Welche Sprache hat das Wort/die Phrase, die Sie nachschlagen möchten", + "definitionLanguage": "Definitionssprache", + "definitionLanguageHint": "In welcher Sprache möchten Sie die Definitionen sehen", + "otherLanguagePlaceholder": "Oder eine andere Sprache eingeben...", + "currentSettings": "Aktuelle Einstellungen: Abfrage {queryLang}, Definition {definitionLang}", + "relookup": "Neu suchen", + "saveToFolder": "In Ordner speichern", + "loading": "Laden...", + "noResults": "Keine Ergebnisse gefunden", + "tryOtherWords": "Versuchen Sie andere Wörter oder Ausdrücke", + "welcomeTitle": "Willkommen beim Wörterbuch", + "welcomeHint": "Geben Sie oben im Suchfeld ein Wort oder einen Ausdruck ein, um zu suchen", + "lookupFailed": "Suche fehlgeschlagen, bitte später erneut versuchen", + "relookupSuccess": "Erfolgreich neu gesucht", + "relookupFailed": "Wörterbuch Neu-Suche fehlgeschlagen", + "pleaseLogin": "Bitte melden Sie sich zuerst an", + "pleaseCreateFolder": "Bitte erstellen Sie zuerst einen Ordner", + "savedToFolder": "Im Ordner gespeichert: {folderName}", + "saveFailed": "Speichern fehlgeschlagen, bitte später erneut versuchen" } } diff --git a/messages/en-US.json b/messages/en-US.json index c8ffa3f..60cee7c 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -190,5 +190,33 @@ "error": "Failed to add text pair to folder" }, "autoSave": "Auto Save" + }, + "dictionary": { + "title": "Dictionary", + "description": "Look up words and phrases with detailed definitions and examples", + "searchPlaceholder": "Enter a word or phrase to look up...", + "searching": "Searching...", + "search": "Search", + "languageSettings": "Language Settings", + "queryLanguage": "Query Language", + "queryLanguageHint": "What language is the word/phrase you want to look up", + "definitionLanguage": "Definition Language", + "definitionLanguageHint": "What language do you want the definitions in", + "otherLanguagePlaceholder": "Or enter another language...", + "currentSettings": "Current settings: Query {queryLang}, Definition {definitionLang}", + "relookup": "Re-search", + "saveToFolder": "Save to folder", + "loading": "Loading...", + "noResults": "No results found", + "tryOtherWords": "Try other words or phrases", + "welcomeTitle": "Welcome to Dictionary", + "welcomeHint": "Enter a word or phrase in the search box above to start looking up", + "lookupFailed": "Search failed, please try again later", + "relookupSuccess": "Re-searched successfully", + "relookupFailed": "Dictionary re-search failed", + "pleaseLogin": "Please log in first", + "pleaseCreateFolder": "Please create a folder first", + "savedToFolder": "Saved to folder: {folderName}", + "saveFailed": "Save failed, please try again later" } } diff --git a/messages/fr-FR.json b/messages/fr-FR.json index 6e4427e..762258d 100644 --- a/messages/fr-FR.json +++ b/messages/fr-FR.json @@ -190,5 +190,33 @@ "error": "Échec de l'ajout de la paire de textes au dossier" }, "autoSave": "Sauvegarde automatique" + }, + "dictionary": { + "title": "Dictionnaire", + "description": "Rechercher des mots et des phrases avec des définitions détaillées et des exemples", + "searchPlaceholder": "Entrez un mot ou une phrase à rechercher...", + "searching": "Recherche...", + "search": "Rechercher", + "languageSettings": "Paramètres linguistiques", + "queryLanguage": "Langue de requête", + "queryLanguageHint": "Quelle est la langue du mot/phrase que vous souhaitez rechercher", + "definitionLanguage": "Langue de définition", + "definitionLanguageHint": "Dans quelle langue souhaitez-vous voir les définitions", + "otherLanguagePlaceholder": "Ou entrez une autre langue...", + "currentSettings": "Paramètres actuels : Requête {queryLang}, Définition {definitionLang}", + "relookup": "Rechercher à nouveau", + "saveToFolder": "Enregistrer dans le dossier", + "loading": "Chargement...", + "noResults": "Aucun résultat trouvé", + "tryOtherWords": "Essayez d'autres mots ou phrases", + "welcomeTitle": "Bienvenue dans le dictionnaire", + "welcomeHint": "Entrez un mot ou une phrase dans la zone de recherche ci-dessus pour commencer", + "lookupFailed": "Recherche échouée, veuillez réessayer plus tard", + "relookupSuccess": "Recherche répétée avec succès", + "relookupFailed": "Nouvelle recherche de dictionnaire échouée", + "pleaseLogin": "Veuillez d'abord vous connecter", + "pleaseCreateFolder": "Veuillez d'abord créer un dossier", + "savedToFolder": "Enregistré dans le dossier : {folderName}", + "saveFailed": "Échec de l'enregistrement, veuillez réessayer plus tard" } } diff --git a/messages/it-IT.json b/messages/it-IT.json index 58edb65..82c3140 100644 --- a/messages/it-IT.json +++ b/messages/it-IT.json @@ -190,5 +190,33 @@ "error": "Impossibile aggiungere la coppia di testi alla cartella" }, "autoSave": "Salvataggio automatico" + }, + "dictionary": { + "title": "Dizionario", + "description": "Cerca parole e frasi con definizioni dettagliate ed esempi", + "searchPlaceholder": "Inserisci una parola o frase da cercare...", + "searching": "Ricerca...", + "search": "Cerca", + "languageSettings": "Impostazioni lingua", + "queryLanguage": "Lingua di interrogazione", + "queryLanguageHint": "Quale è la lingua della parola/frase che vuoi cercare", + "definitionLanguage": "Lingua di definizione", + "definitionLanguageHint": "In quale lingua vuoi vedere le definizioni", + "otherLanguagePlaceholder": "Oppure inserisci un'altra lingua...", + "currentSettings": "Impostazioni attuali: Interrogazione {queryLang}, Definizione {definitionLang}", + "relookup": "Ricerca di nuovo", + "saveToFolder": "Salva nella cartella", + "loading": "Caricamento...", + "noResults": "Nessun risultato trovato", + "tryOtherWords": "Prova altre parole o frasi", + "welcomeTitle": "Benvenuto nel dizionario", + "welcomeHint": "Inserisci una parola o frase nella casella di ricerca sopra per iniziare", + "lookupFailed": "Ricerca fallita, riprova più tardi", + "relookupSuccess": "Ricerca ripetuta con successo", + "relookupFailed": "Nuova ricerca del dizionario fallita", + "pleaseLogin": "Accedi prima", + "pleaseCreateFolder": "Crea prima una cartella", + "savedToFolder": "Salvato nella cartella: {folderName}", + "saveFailed": "Salvataggio fallito, riprova più tardi" } } diff --git a/messages/ja-JP.json b/messages/ja-JP.json index d725da8..6179ff8 100644 --- a/messages/ja-JP.json +++ b/messages/ja-JP.json @@ -190,5 +190,33 @@ "error": "テキストペアの追加に失敗しました" }, "autoSave": "自動保存" + }, + "dictionary": { + "title": "辞書", + "description": "詳細な定義と例で単語やフレーズを検索", + "searchPlaceholder": "検索する単語やフレーズを入力...", + "searching": "検索中...", + "search": "検索", + "languageSettings": "言語設定", + "queryLanguage": "クエリ言語", + "queryLanguageHint": "検索する単語/フレーズの言語", + "definitionLanguage": "定義言語", + "definitionLanguageHint": "定義を表示する言語", + "otherLanguagePlaceholder": "または他の言語を入力...", + "currentSettings": "現在の設定:クエリ {queryLang}、定義 {definitionLang}", + "relookup": "再検索", + "saveToFolder": "フォルダに保存", + "loading": "読み込み中...", + "noResults": "結果が見つかりません", + "tryOtherWords": "他の単語やフレーズを試してください", + "welcomeTitle": "辞書へようこそ", + "welcomeHint": "上の検索ボックスに単語やフレーズを入力して検索を開始", + "lookupFailed": "検索に失敗しました。後でもう一度お試しください", + "relookupSuccess": "再検索しました", + "relookupFailed": "辞書の再検索に失敗しました", + "pleaseLogin": "まずログインしてください", + "pleaseCreateFolder": "まずフォルダを作成してください", + "savedToFolder": "フォルダに保存しました:{folderName}", + "saveFailed": "保存に失敗しました。後でもう一度お試しください" } } diff --git a/messages/ko-KR.json b/messages/ko-KR.json index cdc3035..1a90a59 100644 --- a/messages/ko-KR.json +++ b/messages/ko-KR.json @@ -190,5 +190,33 @@ "error": "텍스트 쌍 추가 실패" }, "autoSave": "자동 저장" + }, + "dictionary": { + "title": "사전", + "description": "상세한 정의와 예제로 단어 및 구문 검색", + "searchPlaceholder": "검색할 단어나 구문을 입력하세요...", + "searching": "검색 중...", + "search": "검색", + "languageSettings": "언어 설정", + "queryLanguage": "쿼리 언어", + "queryLanguageHint": "검색하려는 단어/구문의 언어", + "definitionLanguage": "정의 언어", + "definitionLanguageHint": "정의를 표시할 언어", + "otherLanguagePlaceholder": "또는 다른 언어를 입력하세요...", + "currentSettings": "현재 설정: 쿼리 {queryLang}, 정의 {definitionLang}", + "relookup": "재검색", + "saveToFolder": "폴더에 저장", + "loading": "로드 중...", + "noResults": "결과를 찾을 수 없습니다", + "tryOtherWords": "다른 단어나 구문을 시도하세요", + "welcomeTitle": "사전에 오신 것을 환영합니다", + "welcomeHint": "위 검색 상자에 단어나 구문을 입력하여 검색을 시작하세요", + "lookupFailed": "검색 실패, 나중에 다시 시도하세요", + "relookupSuccess": "재검색했습니다", + "relookupFailed": "사전 재검색 실패", + "pleaseLogin": "먼저 로그인하세요", + "pleaseCreateFolder": "먼저 폴더를 만드세요", + "savedToFolder": "폴더에 저장됨: {folderName}", + "saveFailed": "저장 실패, 나중에 다시 시도하세요" } } diff --git a/messages/ug-CN.json b/messages/ug-CN.json index 194c3fa..5d9d79f 100644 --- a/messages/ug-CN.json +++ b/messages/ug-CN.json @@ -190,5 +190,33 @@ "error": "تېكىست جۈپىنى قىسقۇچقا قوشۇش مەغلۇب بولدى" }, "autoSave": "ئاپتوماتىك ساقلاش" + }, + "dictionary": { + "title": "لۇغەت", + "description": "تەپسىلىي ئىلمىيى ۋە مىساللار بىلەن سۆز ۋە ئىبارە ئىزدەش", + "searchPlaceholder": "ئىزدەيدىغان سۆز ياكى ئىبارە كىرگۈزۈڭ...", + "searching": "ئىزدەۋاتىدۇ...", + "search": "ئىزدە", + "languageSettings": "تىل تەڭشىكى", + "queryLanguage": "سۈرەشتۈرۈش تىلى", + "queryLanguageHint": "ئىزدەمدەكچى بولغان سۆز/ئىبارە قايسى تىلدا", + "definitionLanguage": "ئىلمىيى تىلى", + "definitionLanguageHint": "ئىلمىيىنى قايسى تىلدا كۆرۈشنى ئويلىشىسىز", + "otherLanguagePlaceholder": "ياكى باشقا تىل كىرگۈزۈڭ...", + "currentSettings": "نۆۋەتتىكى تەڭشەك: سۈرەشتۈرۈش {queryLang}، ئىلمىيى {definitionLang}", + "relookup": "قايتا ئىزدە", + "saveToFolder": "قىسقۇچقا ساقلا", + "loading": "يۈكلىۋاتىدۇ...", + "noResults": "نەتىجە تېپىلمىدى", + "tryOtherWords": "باشقا سۆز ياكى ئىبارە سىناڭ", + "welcomeTitle": "لۇغەتكە مەرھەمەت", + "welcomeHint": "ئىزدەشنى باشلاش ئۈچۈن يۇقىرىدىكى ئىزدەش رامكىسىغا سۆز ياكى ئىبارە كىرگۈزۈڭ", + "lookupFailed": "ئىزدەش مەغلۇب بولدى، كېيىنرەك قايتا سىناڭ", + "relookupSuccess": "مۇۋەپپەقىيەتلىك قايتا ئىزدىدى", + "relookupFailed": "لۇغەت قايتا ئىزدىشى مەغلۇب بولدى", + "pleaseLogin": "ئاۋۋال تىزىملىتىڭ", + "pleaseCreateFolder": "ئاۋۋال قىسقۇچ قۇرۇڭ", + "savedToFolder": "قىسقۇچقا ساقلاندى: {folderName}", + "saveFailed": "ساقلاش مەغلۇب بولدى، كېيىنرەك قايتا سىناڭ" } } diff --git a/messages/zh-CN.json b/messages/zh-CN.json index cb100b9..63376be 100644 --- a/messages/zh-CN.json +++ b/messages/zh-CN.json @@ -190,5 +190,33 @@ "error": "添加文本对到文件夹失败" }, "autoSave": "自动保存" + }, + "dictionary": { + "title": "词典", + "description": "查询单词和短语,提供详细的释义和例句", + "searchPlaceholder": "输入要查询的单词或短语...", + "searching": "查询中...", + "search": "查询", + "languageSettings": "语言设置", + "queryLanguage": "查询语言", + "queryLanguageHint": "你要查询的单词/短语是什么语言", + "definitionLanguage": "释义语言", + "definitionLanguageHint": "你希望用什么语言查看释义", + "otherLanguagePlaceholder": "或输入其他语言...", + "currentSettings": "当前设置:查询 {queryLang},释义 {definitionLang}", + "relookup": "重新查询", + "saveToFolder": "保存到文件夹", + "loading": "加载中...", + "noResults": "未找到结果", + "tryOtherWords": "尝试其他单词或短语", + "welcomeTitle": "欢迎使用词典", + "welcomeHint": "在上方搜索框中输入单词或短语开始查询", + "lookupFailed": "查询失败,请稍后重试", + "relookupSuccess": "已重新查询", + "relookupFailed": "词典重新查询失败", + "pleaseLogin": "请先登录", + "pleaseCreateFolder": "请先创建文件夹", + "savedToFolder": "已保存到文件夹:{folderName}", + "saveFailed": "保存失败,请稍后重试" } } diff --git a/src/app/(features)/dictionary/DictionaryEntry.tsx b/src/app/(features)/dictionary/DictionaryEntry.tsx index b06495f..a76f3b5 100644 --- a/src/app/(features)/dictionary/DictionaryEntry.tsx +++ b/src/app/(features)/dictionary/DictionaryEntry.tsx @@ -17,7 +17,7 @@ export function DictionaryEntry({ entry }: DictionaryEntryProps) {
{wordEntry.ipa && ( - {wordEntry.ipa} + [{wordEntry.ipa}] )} {wordEntry.partOfSpeech && ( diff --git a/src/app/(features)/dictionary/DictionaryPage.tsx b/src/app/(features)/dictionary/DictionaryPage.tsx index c5ff2e5..9da7805 100644 --- a/src/app/(features)/dictionary/DictionaryPage.tsx +++ b/src/app/(features)/dictionary/DictionaryPage.tsx @@ -10,8 +10,11 @@ import { getFoldersByUserId } from "@/lib/server/services/folderService"; import { DictLookUpResponse, isDictErrorResponse } from "./types"; import { SearchForm } from "./SearchForm"; import { SearchResult } from "./SearchResult"; +import { useTranslations } from "next-intl"; +import { POPULAR_LANGUAGES } from "./constants"; export default function Dictionary() { + const t = useTranslations("dictionary"); const [searchQuery, setSearchQuery] = useState(""); const [searchResult, setSearchResult] = useState(null); const [isSearching, setIsSearching] = useState(false); @@ -36,6 +39,11 @@ export default function Dictionary() { } }, [session, selectedFolderId]); + // 将 code 转换为 nativeName + const getNativeName = (code: string) => { + return POPULAR_LANGUAGES.find(l => l.code === code)?.nativeName || code; + }; + const handleSearch = async (e: React.FormEvent) => { e.preventDefault(); if (!searchQuery.trim()) return; @@ -45,12 +53,11 @@ export default function Dictionary() { setSearchResult(null); try { - // 使用查询语言和释义语言 - // const result = await lookUp(searchQuery, queryLang, definitionLang); + // 使用查询语言和释义语言的 nativeName const result = await lookUp({ text: searchQuery, - definitionLang: definitionLang, - queryLang: queryLang, + definitionLang: getNativeName(definitionLang), + queryLang: getNativeName(queryLang), forceRelook: false }) @@ -63,7 +70,7 @@ export default function Dictionary() { } } catch (error) { console.error("词典查询失败:", error); - toast.error("查询失败,请稍后重试"); + toast.error(t("lookupFailed")); setSearchResult(null); } finally { setIsSearching(false); @@ -94,14 +101,14 @@ export default function Dictionary() { {isSearching && (
-

加载中...

+

{t("loading")}

)} {!isSearching && hasSearched && !searchResult && (
-

未找到结果

-

尝试其他单词或短语

+

{t("noResults")}

+

{t("tryOtherWords")}

)} @@ -116,14 +123,15 @@ export default function Dictionary() { onFolderSelect={setSelectedFolderId} onResultUpdate={setSearchResult} onSearchingChange={setIsSearching} + getNativeName={getNativeName} /> )} {!hasSearched && (
📚
-

欢迎使用词典

-

在上方搜索框中输入单词或短语开始查询

+

{t("welcomeTitle")}

+

{t("welcomeHint")}

)} diff --git a/src/app/(features)/dictionary/SearchForm.tsx b/src/app/(features)/dictionary/SearchForm.tsx index 46cc10c..3720992 100644 --- a/src/app/(features)/dictionary/SearchForm.tsx +++ b/src/app/(features)/dictionary/SearchForm.tsx @@ -1,5 +1,6 @@ import { LightButton } from "@/components/ui/buttons"; import { POPULAR_LANGUAGES } from "./constants"; +import { useTranslations } from "next-intl"; interface SearchFormProps { searchQuery: string; @@ -22,15 +23,17 @@ export function SearchForm({ definitionLang, onDefinitionLangChange, }: SearchFormProps) { + const t = useTranslations("dictionary"); + return ( <> {/* 页面标题 */}

- 词典 + {t("title")}

- 查询单词和短语,提供详细的释义和例句 + {t("description")}

@@ -40,7 +43,7 @@ export function SearchForm({ type="text" value={searchQuery} onChange={(e: React.ChangeEvent) => onSearchQueryChange(e.target.value)} - placeholder="输入要查询的单词或短语..." + placeholder={t("searchPlaceholder")} className="flex-1 px-4 py-3 text-lg text-gray-800 focus:outline-none border-b-2 border-gray-600 bg-white/90 rounded" /> - {isSearching ? "查询中..." : "查询"} + {isSearching ? t("searching") : t("search")} {/* 语言设置 */}
- 语言设置 + {t("languageSettings")}
{/* 查询语言 */}
{POPULAR_LANGUAGES.map((lang) => ( @@ -72,7 +75,7 @@ export function SearchForm({ onClick={() => onQueryLangChange(lang.code)} className="text-sm px-3 py-1" > - {lang.name} + {lang.nativeName} ))}
@@ -80,7 +83,7 @@ export function SearchForm({ type="text" value={queryLang} onChange={(e) => onQueryLangChange(e.target.value)} - placeholder="或输入其他语言..." + placeholder={t("otherLanguagePlaceholder")} className="w-full px-3 py-2 text-sm text-gray-800 focus:outline-none border-b-2 border-gray-600 bg-white/90 rounded" />
@@ -88,7 +91,7 @@ export function SearchForm({ {/* 释义语言 */}
{POPULAR_LANGUAGES.map((lang) => ( @@ -98,7 +101,7 @@ export function SearchForm({ onClick={() => onDefinitionLangChange(lang.code)} className="text-sm px-3 py-1" > - {lang.name} + {lang.nativeName} ))}
@@ -106,15 +109,17 @@ export function SearchForm({ type="text" value={definitionLang} onChange={(e) => onDefinitionLangChange(e.target.value)} - placeholder="或输入其他语言..." + placeholder={t("otherLanguagePlaceholder")} className="w-full px-3 py-2 text-sm text-gray-800 focus:outline-none border-b-2 border-gray-600 bg-white/90 rounded" />
{/* 当前设置显示 */}
- 当前设置:查询 {POPULAR_LANGUAGES.find(l => l.code === queryLang)?.name || queryLang} - ,释义 {POPULAR_LANGUAGES.find(l => l.code === definitionLang)?.name || definitionLang} + {t("currentSettings", { + queryLang: POPULAR_LANGUAGES.find(l => l.code === queryLang)?.nativeName || queryLang, + definitionLang: POPULAR_LANGUAGES.find(l => l.code === definitionLang)?.nativeName || definitionLang + })}
diff --git a/src/app/(features)/dictionary/SearchResult.tsx b/src/app/(features)/dictionary/SearchResult.tsx index d4c50b4..37498e7 100644 --- a/src/app/(features)/dictionary/SearchResult.tsx +++ b/src/app/(features)/dictionary/SearchResult.tsx @@ -13,6 +13,7 @@ import { } from "./types"; import { DictionaryEntry } from "./DictionaryEntry"; import { POPULAR_LANGUAGES } from "./constants"; +import { useTranslations } from "next-intl"; interface SearchResultProps { searchResult: DictWordResponse | DictPhraseResponse; @@ -24,6 +25,7 @@ interface SearchResultProps { onFolderSelect: (folderId: number | null) => void; onResultUpdate: (newResult: DictWordResponse | DictPhraseResponse) => void; onSearchingChange: (isSearching: boolean) => void; + getNativeName: (code: string) => string; } export function SearchResult({ @@ -36,7 +38,9 @@ export function SearchResult({ onFolderSelect, onResultUpdate, onSearchingChange, + getNativeName, }: SearchResultProps) { + const t = useTranslations("dictionary"); const { data: session } = authClient.useSession(); const handleRelookup = async () => { @@ -45,8 +49,8 @@ export function SearchResult({ try { const result = await lookUp({ text: searchQuery, - definitionLang: definitionLang, - queryLang: queryLang, + definitionLang: getNativeName(definitionLang), + queryLang: getNativeName(queryLang), forceRelook: true }); @@ -54,11 +58,11 @@ export function SearchResult({ toast.error(result.error); } else { onResultUpdate(result); - toast.success("已重新查询"); + toast.success(t("relookupSuccess")); } } catch (error) { console.error("词典重新查询失败:", error); - toast.error("查询失败,请稍后重试"); + toast.error(t("lookupFailed")); } finally { onSearchingChange(false); } @@ -66,11 +70,11 @@ export function SearchResult({ const handleSave = () => { if (!session) { - toast.error("请先登录"); + toast.error(t("pleaseLogin")); return; } if (!selectedFolderId) { - toast.error("请先创建文件夹"); + toast.error(t("pleaseCreateFolder")); return; } @@ -88,11 +92,11 @@ export function SearchResult({ }, }) .then(() => { - const folderName = folders.find(f => f.id === selectedFolderId)?.name; - toast.success(`已保存到文件夹:${folderName}`); + const folderName = folders.find(f => f.id === selectedFolderId)?.name || "Unknown"; + toast.success(t("savedToFolder", { folderName })); }) .catch(() => { - toast.error("保存失败,请稍后重试"); + toast.error(t("saveFailed")); }); }; @@ -123,7 +127,7 @@ export function SearchResult({ @@ -146,7 +150,7 @@ export function SearchResult({ className="flex items-center gap-2 px-4 py-2 text-sm text-gray-700 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors" > - 重新查询 + {t("relookup")}
diff --git a/src/app/(features)/dictionary/constants.ts b/src/app/(features)/dictionary/constants.ts index e0c6791..ebbcb06 100644 --- a/src/app/(features)/dictionary/constants.ts +++ b/src/app/(features)/dictionary/constants.ts @@ -1,10 +1,8 @@ export const POPULAR_LANGUAGES = [ - { code: "english", name: "英语" }, - { code: "chinese", name: "中文" }, - { code: "japanese", name: "日语" }, - { code: "korean", name: "韩语" }, - { code: "french", name: "法语" }, - { code: "german", name: "德语" }, - { code: "italian", name: "意大利语" }, - { code: "spanish", name: "西班牙语" }, + { code: "english", name: "英语", nativeName: "English" }, + { code: "chinese", name: "中文", nativeName: "中文" }, + { code: "japanese", name: "日语", nativeName: "日本語" }, + { code: "korean", name: "韩语", nativeName: "한국어" }, + { code: "italian", name: "意大利语", nativeName: "Italiano" }, + { code: "uyghur", name: "维吾尔语", nativeName: "ئۇيغۇرچە" }, ] as const;