From e624a45264843ed5bc5e13055b1ab86024395e5d Mon Sep 17 00:00:00 2001 From: CJ Pais Date: Thu, 19 Feb 2026 17:26:14 +0800 Subject: [PATCH] toast if exists --- src/components/settings/CustomWords.tsx | 12 ++++++++++-- src/i18n/locales/ar/translation.json | 3 ++- src/i18n/locales/cs/translation.json | 3 ++- src/i18n/locales/de/translation.json | 3 ++- src/i18n/locales/en/translation.json | 3 ++- src/i18n/locales/es/translation.json | 3 ++- src/i18n/locales/fr/translation.json | 3 ++- src/i18n/locales/it/translation.json | 3 ++- src/i18n/locales/ja/translation.json | 3 ++- src/i18n/locales/ko/translation.json | 3 ++- src/i18n/locales/pl/translation.json | 3 ++- src/i18n/locales/pt/translation.json | 3 ++- src/i18n/locales/ru/translation.json | 3 ++- src/i18n/locales/tr/translation.json | 3 ++- src/i18n/locales/uk/translation.json | 3 ++- src/i18n/locales/vi/translation.json | 3 ++- src/i18n/locales/zh-TW/translation.json | 3 ++- src/i18n/locales/zh/translation.json | 3 ++- 18 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/components/settings/CustomWords.tsx b/src/components/settings/CustomWords.tsx index bdb9e14..0137d87 100644 --- a/src/components/settings/CustomWords.tsx +++ b/src/components/settings/CustomWords.tsx @@ -1,5 +1,6 @@ import React, { useState } from "react"; import { useTranslation } from "react-i18next"; +import { toast } from "sonner"; import { useSettings } from "../../hooks/useSettings"; import { Input } from "../ui/Input"; import { Button } from "../ui/Button"; @@ -23,9 +24,16 @@ export const CustomWords: React.FC = React.memo( if ( sanitizedWord && !sanitizedWord.includes(" ") && - sanitizedWord.length <= 50 && - !customWords.includes(sanitizedWord) + sanitizedWord.length <= 50 ) { + if (customWords.includes(sanitizedWord)) { + toast.error( + t("settings.advanced.customWords.duplicate", { + word: sanitizedWord, + }), + ); + return; + } updateSetting("custom_words", [...customWords, sanitizedWord]); setNewWord(""); } diff --git a/src/i18n/locales/ar/translation.json b/src/i18n/locales/ar/translation.json index 5c197fc..5202c19 100644 --- a/src/i18n/locales/ar/translation.json +++ b/src/i18n/locales/ar/translation.json @@ -294,7 +294,8 @@ "description": ".أضف الكلمات التي غالباً ما يتم فهمها بشكل خاطئ أو كتابتها بشكل خاطئ أثناء التفريغ. سيقوم النظام تلقائياً بتصحيح الكلمات ذات الصوت المماثل لتطابق قائمتك", "placeholder": "أضف كلمة", "add": "إضافة", - "remove": "إزالة {{word}}" + "remove": "إزالة {{word}}", + "duplicate": "\"{{word}}\" موجود بالفعل" } }, "postProcessing": { diff --git a/src/i18n/locales/cs/translation.json b/src/i18n/locales/cs/translation.json index afc25a4..1193b9f 100644 --- a/src/i18n/locales/cs/translation.json +++ b/src/i18n/locales/cs/translation.json @@ -316,7 +316,8 @@ "description": "Přidejte slova, která jsou při přepisu často špatně rozpoznána nebo napsána. Systém automaticky opraví podobně znějící slova podle vašeho seznamu.", "placeholder": "Přidat slovo", "add": "Přidat", - "remove": "Odebrat {{word}}" + "remove": "Odebrat {{word}}", + "duplicate": "\"{{word}}\" již existuje" } }, "postProcessing": { diff --git a/src/i18n/locales/de/translation.json b/src/i18n/locales/de/translation.json index 60d45f5..07a3c3f 100644 --- a/src/i18n/locales/de/translation.json +++ b/src/i18n/locales/de/translation.json @@ -316,7 +316,8 @@ "description": "Wörter hinzufügen, die oft falsch gehört oder geschrieben werden. Das System korrigiert automatisch ähnlich klingende Wörter entsprechend deiner Liste.", "placeholder": "Wort hinzufügen", "add": "Hinzufügen", - "remove": "{{word}} entfernen" + "remove": "{{word}} entfernen", + "duplicate": "\"{{word}}\" existiert bereits" } }, "postProcessing": { diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json index 69fd796..e3bdde1 100644 --- a/src/i18n/locales/en/translation.json +++ b/src/i18n/locales/en/translation.json @@ -316,7 +316,8 @@ "description": "Add words that are often misheard or misspelled during transcription. The system will automatically correct similar-sounding words to match your list.", "placeholder": "Add a word", "add": "Add", - "remove": "Remove {{word}}" + "remove": "Remove {{word}}", + "duplicate": "\"{{word}}\" already exists" } }, "postProcessing": { diff --git a/src/i18n/locales/es/translation.json b/src/i18n/locales/es/translation.json index af397c6..04a0069 100644 --- a/src/i18n/locales/es/translation.json +++ b/src/i18n/locales/es/translation.json @@ -316,7 +316,8 @@ "description": "Agrega palabras que a menudo se escuchan mal o se escriben incorrectamente durante la transcripción. El sistema corregirá automáticamente palabras similares para que coincidan con tu lista.", "placeholder": "Agregar una palabra", "add": "Agregar", - "remove": "Eliminar {{word}}" + "remove": "Eliminar {{word}}", + "duplicate": "\"{{word}}\" ya existe" } }, "postProcessing": { diff --git a/src/i18n/locales/fr/translation.json b/src/i18n/locales/fr/translation.json index cc01fda..8e1501b 100644 --- a/src/i18n/locales/fr/translation.json +++ b/src/i18n/locales/fr/translation.json @@ -316,7 +316,8 @@ "description": "Ajoutez des mots souvent mal entendus ou mal orthographiés lors de la transcription. Le système corrigera automatiquement les mots similaires pour correspondre à votre liste.", "placeholder": "Ajouter un mot", "add": "Ajouter", - "remove": "Supprimer {{word}}" + "remove": "Supprimer {{word}}", + "duplicate": "\"{{word}}\" existe déjà" } }, "postProcessing": { diff --git a/src/i18n/locales/it/translation.json b/src/i18n/locales/it/translation.json index c167910..f349584 100644 --- a/src/i18n/locales/it/translation.json +++ b/src/i18n/locales/it/translation.json @@ -316,7 +316,8 @@ "description": "Aggiungi parole che vengono spesso fraintese o scritte in modo errato durante la trascrizione. Il sistema correggerà automaticamente le parole dal suono simile in modo che corrispondano al tuo elenco.", "placeholder": "Aggiungi una parola", "add": "Aggiungi", - "remove": "Rimuovi {{word}}" + "remove": "Rimuovi {{word}}", + "duplicate": "\"{{word}}\" esiste già" } }, "postProcessing": { diff --git a/src/i18n/locales/ja/translation.json b/src/i18n/locales/ja/translation.json index 738ff02..c62a7e3 100644 --- a/src/i18n/locales/ja/translation.json +++ b/src/i18n/locales/ja/translation.json @@ -316,7 +316,8 @@ "description": "よく誤認識または誤入力される単語を追加します。システムは自動的に類似した発音の単語をリストに合わせて修正します。", "placeholder": "単語を追加", "add": "追加", - "remove": "{{word}}を削除" + "remove": "{{word}}を削除", + "duplicate": "「{{word}}」は既に存在します" } }, "postProcessing": { diff --git a/src/i18n/locales/ko/translation.json b/src/i18n/locales/ko/translation.json index 8e91f31..70950a4 100644 --- a/src/i18n/locales/ko/translation.json +++ b/src/i18n/locales/ko/translation.json @@ -316,7 +316,8 @@ "description": "녹음 중 자주 잘못 들리거나 철자가 틀리는 단어를 추가하세요. 시스템이 유사한 소리의 단어를 목록과 일치하도록 자동으로 수정합니다.", "placeholder": "단어 추가", "add": "추가", - "remove": "{{word}} 제거" + "remove": "{{word}} 제거", + "duplicate": "\"{{word}}\"이(가) 이미 존재합니다" } }, "postProcessing": { diff --git a/src/i18n/locales/pl/translation.json b/src/i18n/locales/pl/translation.json index 015b3be..2ef5a7b 100644 --- a/src/i18n/locales/pl/translation.json +++ b/src/i18n/locales/pl/translation.json @@ -316,7 +316,8 @@ "description": "Dodaj słowa, które często są źle rozpoznawane lub zapisywane podczas transkrypcji. System automatycznie poprawi podobnie brzmiące słowa, aby pasowały do Twojej listy.", "placeholder": "Dodaj słowo", "add": "Dodaj", - "remove": "Usuń {{word}}" + "remove": "Usuń {{word}}", + "duplicate": "\"{{word}}\" już istnieje" } }, "postProcessing": { diff --git a/src/i18n/locales/pt/translation.json b/src/i18n/locales/pt/translation.json index 80917ed..914bee1 100644 --- a/src/i18n/locales/pt/translation.json +++ b/src/i18n/locales/pt/translation.json @@ -316,7 +316,8 @@ "description": "Adicione palavras que são frequentemente mal ouvidas ou mal escritas durante a transcrição. O sistema irá automaticamente corrigir palavras semelhantes para corresponder à sua lista.", "placeholder": "Adicionar uma palavra", "add": "Adicionar", - "remove": "Remover {{word}}" + "remove": "Remover {{word}}", + "duplicate": "\"{{word}}\" já existe" } }, "postProcessing": { diff --git a/src/i18n/locales/ru/translation.json b/src/i18n/locales/ru/translation.json index adcca9a..144c703 100644 --- a/src/i18n/locales/ru/translation.json +++ b/src/i18n/locales/ru/translation.json @@ -316,7 +316,8 @@ "description": "Добавить слова, которые часто неправильно слышатся или пишутся с ошибками во время транскрипции. Система автоматически исправит похожие по звучанию слова, чтобы они соответствовали вашему списку.", "placeholder": "Добавить слово", "add": "Добавлять", - "remove": "Удалить {{word}}" + "remove": "Удалить {{word}}", + "duplicate": "\"{{word}}\" уже существует" } }, "postProcessing": { diff --git a/src/i18n/locales/tr/translation.json b/src/i18n/locales/tr/translation.json index dd1d424..9f908f7 100644 --- a/src/i18n/locales/tr/translation.json +++ b/src/i18n/locales/tr/translation.json @@ -316,7 +316,8 @@ "description": "Transkripsiyon sırasında sıkça yanlış duyulan veya yanlış yazılan kelimeleri ekleyin. Sistem, benzer sesli kelimeleri listenize göre otomatik olarak düzeltir.", "placeholder": "Kelime ekle", "add": "Ekle", - "remove": "{{word}} Kaldır" + "remove": "{{word}} Kaldır", + "duplicate": "\"{{word}}\" zaten mevcut" } }, "postProcessing": { diff --git a/src/i18n/locales/uk/translation.json b/src/i18n/locales/uk/translation.json index e9d3f3c..15c7ad5 100644 --- a/src/i18n/locales/uk/translation.json +++ b/src/i18n/locales/uk/translation.json @@ -316,7 +316,8 @@ "description": "Додайте слова, які часто неправильно розпізнаються під час транскрипції. Система автоматично виправлятиме схожі за звучанням слова відповідно до вашого списку.", "placeholder": "Додати слово", "add": "Додати", - "remove": "Видалити {{word}}" + "remove": "Видалити {{word}}", + "duplicate": "\"{{word}}\" вже існує" } }, "postProcessing": { diff --git a/src/i18n/locales/vi/translation.json b/src/i18n/locales/vi/translation.json index ec486ac..da24d80 100644 --- a/src/i18n/locales/vi/translation.json +++ b/src/i18n/locales/vi/translation.json @@ -316,7 +316,8 @@ "description": "Thêm các từ thường bị nghe nhầm hoặc viết sai trong quá trình chuyển đổi. Hệ thống sẽ tự động sửa các từ có âm thanh tương tự để khớp với danh sách của bạn.", "placeholder": "Thêm một từ", "add": "Thêm", - "remove": "Xóa {{word}}" + "remove": "Xóa {{word}}", + "duplicate": "\"{{word}}\" đã tồn tại" } }, "postProcessing": { diff --git a/src/i18n/locales/zh-TW/translation.json b/src/i18n/locales/zh-TW/translation.json index 7c0611d..1197792 100644 --- a/src/i18n/locales/zh-TW/translation.json +++ b/src/i18n/locales/zh-TW/translation.json @@ -316,7 +316,8 @@ "description": "新增經常被誤聽或拼寫錯誤的詞彙。系統會自動將發音相似的詞彙修正為您列表中的詞彙", "placeholder": "新增詞彙", "add": "新增", - "remove": "刪除 {{word}}" + "remove": "刪除 {{word}}", + "duplicate": "「{{word}}」已存在" } }, "postProcessing": { diff --git a/src/i18n/locales/zh/translation.json b/src/i18n/locales/zh/translation.json index 5744ad9..bf39682 100644 --- a/src/i18n/locales/zh/translation.json +++ b/src/i18n/locales/zh/translation.json @@ -316,7 +316,8 @@ "description": "添加经常被误听或拼写错误的词汇。系统将自动将发音相似的词汇修正为您列表中的词汇。", "placeholder": "添加词汇", "add": "添加", - "remove": "删除 {{word}}" + "remove": "删除 {{word}}", + "duplicate": "\"{{word}}\" 已存在" } }, "postProcessing": {