diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index d88fad2..ed27599 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -202,6 +202,7 @@ async function syncOptions() { translationFile: opts["tac_translation.translationFile"], oldFormat: opts["tac_translation.oldFormat"], searchByTranslation: opts["tac_translation.searchByTranslation"], + liveTranslation: opts["tac_translation.liveTranslation"], }, // Extra file settings extra: { @@ -238,6 +239,13 @@ async function syncOptions() { }); } + // Remove ruby div if live preview was disabled + if (newCFG.translation.liveTranslation === false) { + [...gradioApp().querySelectorAll('.acRuby')].forEach(r => { + r.remove(); + }); + } + // Apply changes CFG = newCFG; @@ -587,6 +595,8 @@ function updateSelectionStyle(textArea, newIndex, oldIndex) { } function updateRuby(textArea, prompt) { + if (!CFG.translation.liveTranslation) return; + let ruby = gradioApp().querySelector('.acRuby' + getTextAreaIdentifier(textArea)); if (!ruby) { let textAreaId = getTextAreaIdentifier(textArea); diff --git a/scripts/tag_autocomplete_helper.py b/scripts/tag_autocomplete_helper.py index b370c42..fc1dd8c 100644 --- a/scripts/tag_autocomplete_helper.py +++ b/scripts/tag_autocomplete_helper.py @@ -298,6 +298,7 @@ def on_ui_settings(): shared.opts.add_option("tac_translation.translationFile", shared.OptionInfo("None", "Translation filename", gr.Dropdown, lambda: {"choices": csv_files_withnone}, refresh=update_tag_files, section=TAC_SECTION)) shared.opts.add_option("tac_translation.oldFormat", shared.OptionInfo(False, "Translation file uses old 3-column translation format instead of the new 2-column one", section=TAC_SECTION)) shared.opts.add_option("tac_translation.searchByTranslation", shared.OptionInfo(True, "Search by translation", section=TAC_SECTION)) + shared.opts.add_option("tac_translation.liveTranslation", shared.OptionInfo(False, "Show live tag translation below prompt", section=TAC_SECTION)) # Extra file settings shared.opts.add_option("tac_extra.extraFile", shared.OptionInfo("extra-quality-tags.csv", "Extra filename (for small sets of custom tags)", gr.Dropdown, lambda: {"choices": csv_files_withnone}, refresh=update_tag_files, section=TAC_SECTION)) shared.opts.add_option("tac_extra.addMode", shared.OptionInfo("Insert before", "Mode to add the extra tags to the main tag list", gr.Dropdown, lambda: {"choices": ["Insert before","Insert after"]}, section=TAC_SECTION))