From a1e18c3c5be2a81d9475099b8b5c56e42984fe94 Mon Sep 17 00:00:00 2001 From: Anton Antonov Date: Tue, 14 Jul 2026 17:05:10 +0500 Subject: [PATCH] Usage details notification is fixed (#12) --- CHANGELOG.md | 4 ++++ manifest.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/i18n/de.json | 5 +++-- src/i18n/en.json | 5 +++-- src/i18n/es.json | 5 +++-- src/i18n/fr.json | 5 +++-- src/i18n/id.json | 5 +++-- src/i18n/it.json | 5 +++-- src/i18n/ja.json | 5 +++-- src/i18n/ko.json | 5 +++-- src/i18n/pt.json | 5 +++-- src/i18n/zh-CN.json | 5 +++-- src/i18n/zh-TW.json | 5 +++-- src/translator.ts | 39 ++++++++++++++++++++++++--------------- versions.json | 3 ++- 17 files changed, 67 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e572ccc..0a89b2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.2.2] — 2026-07-14 + +- Usage details notification is fixed + ## [1.2.1] — 2026-07-13 - Usage details are added to the Translation complete notification diff --git a/manifest.json b/manifest.json index 3ec5b64..cc73c3d 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "note-ai-translator", "name": "L10n.dev - AI Translator", - "version": "1.2.1", + "version": "1.2.2", "minAppVersion": "1.1.7", "description": "Translate notes into any of 165 languages with AI. Preserves Markdown formatting and structure. Powered by L10n.dev's AI translation API. Supports json, yaml, other plain-text formats.", "author": "l10n.dev", diff --git a/package-lock.json b/package-lock.json index 5db4149..246dad2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-plugin-ai-translator", - "version": "1.2.1", + "version": "1.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-plugin-ai-translator", - "version": "1.2.1", + "version": "1.2.2", "license": "MIT", "dependencies": { "obsidian": "latest" diff --git a/package.json b/package.json index 2eefcae..7122ddc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-plugin-ai-translator", - "version": "1.2.1", + "version": "1.2.2", "description": "Obsidian plugin to translate notes with AI using l10n.dev", "main": "main.js", "type": "module", diff --git a/src/i18n/de.json b/src/i18n/de.json index dab58f6..bfd8cfb 100644 --- a/src/i18n/de.json +++ b/src/i18n/de.json @@ -30,8 +30,9 @@ "noticeInvalidKey": "Ungültiger API-Schlüssel. Erhalten Sie Ihren Schlüssel unter {{url}}", "noticeInsufficientBalance": "Guthaben nicht ausreichend. Laden Sie es unter {{url}} auf.", "noticeTranslationFailed": "Übersetzung fehlgeschlagen. Bitte versuchen Sie es erneut.", - "noticeTranslationComplete": "Übersetzung abgeschlossen. Es wurden {{count}} Zeichen verwendet (Inhalt {{sourceCount}}, Lexikon {{glossaryCount}}, Anweisung {{instructionCount}}, Terminologie {{terminologyCount}})", - "noticeRemainingBalance": " {{count}} Zeichen verbleibend.", + "noticeTranslationComplete": "Übersetzung abgeschlossen. {{count}} Zeichen verwendet. ", + "noticeTranslationCompleteExtended": "Übersetzung abgeschlossen. {{count}} Zeichen verwendet (Inhalt {{sourceCount}}, Lexikon {{glossaryCount}}, Anweisung {{instructionCount}}). ", + "noticeRemainingBalance": "Noch {{count}} Zeichen verfügbar.", "noticeSaveFailed": "Übersetzte Notiz konnte nicht gespeichert werden.", "noticeSetApiKey": "Bitte legen Sie Ihren l10n.dev API-Schlüssel in den Einstellungen fest.", "noticeNoActiveNote": "Keine aktive Notiz zum Übersetzen.", diff --git a/src/i18n/en.json b/src/i18n/en.json index fc36ea8..7534148 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -30,8 +30,9 @@ "noticeInvalidKey": "Invalid API key. Get your key at {{url}}", "noticeInsufficientBalance": "Insufficient balance. Top up at {{url}}", "noticeTranslationFailed": "Translation failed. Please try again.", - "noticeTranslationComplete": "Translation complete. Used {{count}} characters (content {{sourceCount}}, glossary {{glossaryCount}}, instruction {{instructionCount}}, terminology {{terminologyCount}})", - "noticeRemainingBalance": " {{count}} characters remaining.", + "noticeTranslationComplete": "Translation complete. Used {{count}} characters. ", + "noticeTranslationCompleteExtended": "Translation complete. Used {{count}} characters (content {{sourceCount}}, glossary {{glossaryCount}}, instruction {{instructionCount}}). ", + "noticeRemainingBalance": "Remaining {{count}} characters.", "noticeSaveFailed": "Failed to save the translated note.", "noticeSetApiKey": "Please set your l10n.dev API key in settings.", "noticeNoActiveNote": "No active note to translate.", diff --git a/src/i18n/es.json b/src/i18n/es.json index 566762d..7897e9d 100644 --- a/src/i18n/es.json +++ b/src/i18n/es.json @@ -30,8 +30,9 @@ "noticeInvalidKey": "API key no válida. Obtén tu clave en {{url}}", "noticeInsufficientBalance": "Saldo insuficiente. Recarga en {{url}}", "noticeTranslationFailed": "Error en la traducción. Por favor, inténtalo de nuevo.", - "noticeTranslationComplete": "Traducción completada. Se utilizaron {{count}} caracteres (contenido {{sourceCount}}, glosario {{glossaryCount}}, instrucción {{instructionCount}}, terminología {{terminologyCount}})", - "noticeRemainingBalance": " {{count}} caracteres restantes.", + "noticeTranslationComplete": "Traducción completada. Se usaron {{count}} caracteres. ", + "noticeTranslationCompleteExtended": "Traducción completada. Se usaron {{count}} caracteres (contenido {{sourceCount}}, glosario {{glossaryCount}}, instrucción {{instructionCount}}). ", + "noticeRemainingBalance": "Quedan {{count}} caracteres.", "noticeSaveFailed": "Error al guardar la nota traducida.", "noticeSetApiKey": "Por favor, configura tu API key de l10n.dev en los ajustes.", "noticeNoActiveNote": "No hay ninguna nota activa para traducir.", diff --git a/src/i18n/fr.json b/src/i18n/fr.json index 3fbd086..849ed27 100644 --- a/src/i18n/fr.json +++ b/src/i18n/fr.json @@ -30,8 +30,9 @@ "noticeInvalidKey": "Clé API invalide. Obtenez votre clé sur {{url}}", "noticeInsufficientBalance": "Solde insuffisant. Rechargez sur {{url}}", "noticeTranslationFailed": "La traduction a échoué. Veuillez réessayer.", - "noticeTranslationComplete": "Traduction terminée. Utilisé {{count}} caractères (contenu {{sourceCount}}, glossaire {{glossaryCount}}, instruction {{instructionCount}}, terminologie {{terminologyCount}})", - "noticeRemainingBalance": " {{count}} caractères restants.", + "noticeTranslationComplete": "Traduction terminée. {{count}} caractères utilisés. ", + "noticeTranslationCompleteExtended": "Traduction terminée. Utilisation de {{count}} caractères (contenu {{sourceCount}}, glossaire {{glossaryCount}}, instruction {{instructionCount}}). ", + "noticeRemainingBalance": "{{count}} caractères restants.", "noticeSaveFailed": "Échec de l'enregistrement de la note traduite.", "noticeSetApiKey": "Veuillez définir votre clé API l10n.dev dans les paramètres.", "noticeNoActiveNote": "Aucune note active à traduire.", diff --git a/src/i18n/id.json b/src/i18n/id.json index 354ff47..5c7dc32 100644 --- a/src/i18n/id.json +++ b/src/i18n/id.json @@ -30,8 +30,9 @@ "noticeInvalidKey": "API key tidak valid. Dapatkan key Anda di {{url}}", "noticeInsufficientBalance": "Saldo tidak mencukupi. Isi ulang di {{url}}", "noticeTranslationFailed": "Terjemahan gagal. Silakan coba lagi.", - "noticeTranslationComplete": "Terjemahan selesai. Menggunakan {{count}} karakter (konten {{sourceCount}}, glosarium {{glossaryCount}}, instruksi {{instructionCount}}, terminologi {{terminologyCount}})", - "noticeRemainingBalance": " {{count}} karakter tersisa.", + "noticeTranslationComplete": "Terjemahan selesai. Menggunakan {{count}} karakter. ", + "noticeTranslationCompleteExtended": "Terjemahan selesai. Menggunakan {{count}} karakter (konten {{sourceCount}}, glosarium {{glossaryCount}}, instruksi {{instructionCount}}). ", + "noticeRemainingBalance": "Sisa {{count}} karakter.", "noticeSaveFailed": "Gagal menyimpan catatan yang diterjemahkan.", "noticeSetApiKey": "Harap atur API key l10n.dev Anda di pengaturan.", "noticeNoActiveNote": "Tidak ada catatan aktif untuk diterjemahkan.", diff --git a/src/i18n/it.json b/src/i18n/it.json index 204bc65..fd3d285 100644 --- a/src/i18n/it.json +++ b/src/i18n/it.json @@ -30,8 +30,9 @@ "noticeInvalidKey": "Chiave API non valida. Ottieni la tua chiave su {{url}}", "noticeInsufficientBalance": "Saldo insufficiente. Ricarica su {{url}}", "noticeTranslationFailed": "Traduzione non riuscita. Riprova.", - "noticeTranslationComplete": "Traduzione completata. Utilizzati {{count}} caratteri (contenuto {{sourceCount}}, glossario {{glossaryCount}}, istruzione {{instructionCount}}, terminologia {{terminologyCount}})", - "noticeRemainingBalance": " {{count}} caratteri rimanenti.", + "noticeTranslationComplete": "Traduzione completata. Sono stati usati {{count}} caratteri. ", + "noticeTranslationCompleteExtended": "Traduzione completata. Utilizzati {{count}} caratteri (contenuto {{sourceCount}}, glossario {{glossaryCount}}, istruzione {{instructionCount}}). ", + "noticeRemainingBalance": "{{count}} caratteri rimanenti.", "noticeSaveFailed": "Salvataggio della nota tradotta non riuscito.", "noticeSetApiKey": "Imposta la tua chiave API l10n.dev nelle impostazioni.", "noticeNoActiveNote": "Nessuna nota attiva da tradurre.", diff --git a/src/i18n/ja.json b/src/i18n/ja.json index 5be064d..0b4cbfe 100644 --- a/src/i18n/ja.json +++ b/src/i18n/ja.json @@ -30,8 +30,9 @@ "noticeInvalidKey": "無効なAPIキーです。キーの取得はこちら: {{url}}", "noticeInsufficientBalance": "残高不足です。チャージはこちら: {{url}}", "noticeTranslationFailed": "翻訳に失敗しました。もう一度お試しください。", - "noticeTranslationComplete": "翻訳が完了しました。{{count}}文字を使用しました(コンテンツ {{sourceCount}}、用語集 {{glossaryCount}}、指示 {{instructionCount}}、用語 {{terminologyCount}})", - "noticeRemainingBalance": " 残り{{count}}文字です。", + "noticeTranslationComplete": "翻訳が完了しました。{{count}}文字を使用しました。", + "noticeTranslationCompleteExtended": "翻訳が完了しました。{{count}}文字を使用しました(コンテンツ{{sourceCount}}、用語集{{glossaryCount}}、言語指示{{instructionCount}})。", + "noticeRemainingBalance": "残り{{count}}文字。", "noticeSaveFailed": "翻訳されたノートの保存に失敗しました。", "noticeSetApiKey": "設定でl10n.devのAPIキーを設定してください。", "noticeNoActiveNote": "翻訳するアクティブなノートがありません。", diff --git a/src/i18n/ko.json b/src/i18n/ko.json index 0925257..af424bc 100644 --- a/src/i18n/ko.json +++ b/src/i18n/ko.json @@ -30,8 +30,9 @@ "noticeInvalidKey": "유효하지 않은 API 키입니다. 다음에서 키를 발급받으세요: {{url}}", "noticeInsufficientBalance": "잔액이 부족합니다. 다음에서 충전하세요: {{url}}", "noticeTranslationFailed": "번역에 실패했습니다. 다시 시도해 주세요.", - "noticeTranslationComplete": "번역이 완료되었습니다. {{count}}개의 문자를 사용했습니다 (콘텐츠 {{sourceCount}}, 용어집 {{glossaryCount}}, 지침 {{instructionCount}}, 용어 {{terminologyCount}})", - "noticeRemainingBalance": " {{count}} 문자 남음.", + "noticeTranslationComplete": "번역 완료. {{count}}자 사용됨. ", + "noticeTranslationCompleteExtended": "번역이 완료되었습니다. {{count}}자를 사용했습니다 (콘텐츠 {{sourceCount}}, 용어집 {{glossaryCount}}, 지침 {{instructionCount}}). ", + "noticeRemainingBalance": "남은 문자 수: {{count}}자.", "noticeSaveFailed": "번역된 노트를 저장하지 못했습니다.", "noticeSetApiKey": "설정에서 l10n.dev API 키를 설정해 주세요.", "noticeNoActiveNote": "번역할 활성화된 노트가 없습니다.", diff --git a/src/i18n/pt.json b/src/i18n/pt.json index 79fbb65..06c60ca 100644 --- a/src/i18n/pt.json +++ b/src/i18n/pt.json @@ -30,8 +30,9 @@ "noticeInvalidKey": "Chave de API inválida. Obtenha sua chave em {{url}}", "noticeInsufficientBalance": "Saldo insuficiente. Recarregue em {{url}}", "noticeTranslationFailed": "Falha na tradução. Tente novamente.", - "noticeTranslationComplete": "Tradução concluída. Foram usados {{count}} caracteres (conteúdo {{sourceCount}}, glossário {{glossaryCount}}, instrução {{instructionCount}}, terminologia {{terminologyCount}})", - "noticeRemainingBalance": " {{count}} caracteres restantes.", + "noticeTranslationComplete": "Tradução concluída. {{count}} caracteres usados. ", + "noticeTranslationCompleteExtended": "Tradução concluída. {{count}} caracteres usados (conteúdo {{sourceCount}}, glossário {{glossaryCount}}, instrução {{instructionCount}}). ", + "noticeRemainingBalance": "{{count}} caracteres restantes.", "noticeSaveFailed": "Falha ao salvar a nota traduzida.", "noticeSetApiKey": "Por favor, defina sua chave de API l10n.dev nas configurações.", "noticeNoActiveNote": "Nenhuma nota ativa para traduzir.", diff --git a/src/i18n/zh-CN.json b/src/i18n/zh-CN.json index 43ca442..e200647 100644 --- a/src/i18n/zh-CN.json +++ b/src/i18n/zh-CN.json @@ -30,8 +30,9 @@ "noticeInvalidKey": "API密钥无效。请在 {{url}} 获取您的密钥", "noticeInsufficientBalance": "余额不足。请在 {{url}} 充值", "noticeTranslationFailed": "翻译失败。请重试。", - "noticeTranslationComplete": "翻译完成。已使用 {{count}} 个字符(内容 {{sourceCount}},词汇表 {{glossaryCount}},指令 {{instructionCount}},术语 {{terminologyCount}})", - "noticeRemainingBalance": " 剩余 {{count}} 个字符。", + "noticeTranslationComplete": "翻译完成。已使用 {{count}} 个字符。", + "noticeTranslationCompleteExtended": "翻译完成。已使用 {{count}} 个字符(内容 {{sourceCount}},词汇表 {{glossaryCount}},语言指令 {{instructionCount}})。", + "noticeRemainingBalance": "剩余 {{count}} 个字符。", "noticeSaveFailed": "保存翻译后的笔记失败。", "noticeSetApiKey": "请在设置中配置您的l10n.dev API密钥。", "noticeNoActiveNote": "没有可翻译的活动笔记。", diff --git a/src/i18n/zh-TW.json b/src/i18n/zh-TW.json index 606c376..cc17b5d 100644 --- a/src/i18n/zh-TW.json +++ b/src/i18n/zh-TW.json @@ -30,8 +30,9 @@ "noticeInvalidKey": "API 金鑰無效。請至 {{url}} 取得您的金鑰", "noticeInsufficientBalance": "餘額不足。請至 {{url}} 加值", "noticeTranslationFailed": "翻譯失敗。請再試一次。", - "noticeTranslationComplete": "翻譯完成。已使用 {{count}} 個字元(內容 {{sourceCount}}、詞彙表 {{glossaryCount}}、指令 {{instructionCount}}、術語 {{terminologyCount}})", - "noticeRemainingBalance": "剩餘 {{count}} 字元。", + "noticeTranslationComplete": "翻譯完成。使用了 {{count}} 個字元。", + "noticeTranslationCompleteExtended": "翻譯完成。已使用 {{count}} 個字元 (內容 {{sourceCount}}、詞彙表 {{glossaryCount}}、語言指令 {{instructionCount}})。", + "noticeRemainingBalance": "剩餘 {{count}} 個字元。", "noticeSaveFailed": "儲存翻譯後的筆記失敗。", "noticeSetApiKey": "請在設定中設定您的 l10n.dev API 金鑰。", "noticeNoActiveNote": "沒有可翻譯的有效筆記。", diff --git a/src/translator.ts b/src/translator.ts index 8fba2ea..774d32f 100644 --- a/src/translator.ts +++ b/src/translator.ts @@ -117,21 +117,30 @@ async function doTranslate( count: remainingBalance.toLocaleString(), }) : ""; - new Notice( - t("noticeTranslationComplete", { - count: usage.charsUsed.toLocaleString(), - sourceCount: - usage.details.sourceStringsCharCount.toLocaleString(), - glossaryCount: usage.details.glossaryCharCount.toLocaleString(), - instructionCount: - usage.details.instructionCharCount.toLocaleString(), - terminologyCount: - usage.details.terminologyCharCount.toLocaleString(), - }) + - "\r\n\r\n" + - balanceText, - 20000, - ); + + if (usage.charsUsed > usage.details.sourceStringsCharCount) { + new Notice( + t("noticeTranslationCompleteExtended", { + count: usage.charsUsed.toLocaleString(), + sourceCount: + usage.details.sourceStringsCharCount.toLocaleString(), + glossaryCount: + usage.details.glossaryCharCount.toLocaleString(), + instructionCount: + usage.details.instructionCharCount.toLocaleString(), + terminologyCount: + usage.details.terminologyCharCount.toLocaleString(), + }) + (remainingBalance != null ? "\r\n\r\n" + balanceText : ""), + 20000, + ); + } else { + new Notice( + t("noticeTranslationComplete", { + count: usage.charsUsed.toLocaleString(), + }) + balanceText, + 20000, + ); + } } catch { new Notice(t("noticeSaveFailed")); } diff --git a/versions.json b/versions.json index 24a41f5..9b28ead 100644 --- a/versions.json +++ b/versions.json @@ -8,5 +8,6 @@ "1.1.1": "1.1.7", "1.1.2": "1.1.7", "1.2.0": "1.1.7", - "1.2.1": "1.1.7" + "1.2.1": "1.1.7", + "1.2.2": "1.1.7" }