From 2bcc3ec32666dec1cd6ca5dafd07fa9794aa10d7 Mon Sep 17 00:00:00 2001 From: Tyler Chamberlain Date: Wed, 21 Feb 2024 11:05:16 -0600 Subject: [PATCH] add `Block Untranslated Messages` option Didn't want to see spam from messages in the target language already, so added an option to block them. --- PolyglotTranslator.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/PolyglotTranslator.lua b/PolyglotTranslator.lua index 846b68e..66abb4f 100644 --- a/PolyglotTranslator.lua +++ b/PolyglotTranslator.lua @@ -1,7 +1,7 @@ --[[ --- START OF VERSION --- MAJOR:1 MINOR:5 -PATCH:1 +PATCH:2 CHANGELOG - Fixed broken ChatGPT translation method. - Fixed broken restoring of translation method upon script startup. @@ -11,6 +11,7 @@ CHANGELOG - Refactoring and code cleanup. - Added Portuguese localization. - Credits to all contributors. +- Added `Block Untranslated Messages` option --- END OF VERSION --- ]] -- LEGACY @@ -586,7 +587,13 @@ TranslationMethodOptions = { function moduleExports.translateText(text, targetLang, translationMethod, onSuccess) if translationMethods[translationMethod] then translationMethods[translationMethod](text, targetLang, function(translation, sourceLang) - onSuccess(translation, sourceLang:lower()) + if (Config.blockUntranslatedMessages) then + if translation ~= text then + onSuccess(translation, sourceLang:lower()) + end + else + onSuccess(translation, sourceLang:lower()) + end end) end end @@ -910,6 +917,8 @@ local engTranslations = { translateYourselfD = "Translate messages sent by yourself", translatedMessageDisplay = "Translated Message Display", translatedMessageDisplayD = "Location of translated Message. You need to click to apply change", + blockUntranslatedMessages = "Block Untranslated Messages", + blockUntranslatedMessagesD = "Only show messages where the translated text is different from the original", scriptSettings = "Other Settings For Polyglot Translator", scriptSettingsD = "Including color settings and updates", playerNameColor = "Player Name Color", @@ -1568,6 +1577,7 @@ Config = { translateOn = true, translateSelf = false, + blockUntranslatedMessages = false, translatedMsgLocation = 5, @@ -1598,6 +1608,9 @@ menu.my_root():list_select(LOC.translatedMessageDisplay, {}, LOC.translatedMessa TranslatedMsgLocationOptions, #TranslatedMsgLocationOptions, function(index, option, prevIndex, clickType) Config.translatedMsgLocation = index end) +menu.my_root():toggle(LOC.blockUntranslatedMessages, {}, LOC.blockUntranslatedMessagesD, + function(on) Config.blockUntranslatedMessages = on end) + -- CommandRef|CommandUniqPtr menu.list(CommandRef parent, Label menu_name, table command_names = {}, Label help_text = "", ?function on_click = nil, ?function on_back = nil, ?function on_active_list_update = nil) local settingTranslationMenu = menu.list(menu.my_root(), LOC.scriptSettings, {}, LOC.scriptSettingsD) local colorTranslation = menu.list(settingTranslationMenu, LOC.playerNameColor) @@ -2180,4 +2193,4 @@ json = require "src.lib.external.json" polyglotUtils = require "src.lib.utils" LOC = require "src.lib.localization" -require "src.lib.menus" \ No newline at end of file +require "src.lib.menus"