From dcc6602056bfdd6ea86384108aa3bb15ed0c525a Mon Sep 17 00:00:00 2001 From: DominikDoom Date: Fri, 21 Apr 2023 10:32:52 +0200 Subject: [PATCH] Allow translations directly in extra file QoL feature so you don't need to switch files for the small extra sets Closes #164 --- javascript/tagAutocomplete.js | 14 +++++++++----- tags/extra-quality-tags.csv | 12 ++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index 3278604..efb729a 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -93,6 +93,10 @@ async function loadTags(c) { if (c.extra.extraFile && c.extra.extraFile !== "None") { try { extras = await loadCSV(`${tagBasePath}/${c.extra.extraFile}`); + // Add translations to the main translation map for extra tags that have them + extras.forEach(e => { + if (e[4]) translations.set(e[0], e[4]); + }); } catch (e) { console.error("Error loading extra file: " + e); return; @@ -174,16 +178,16 @@ async function syncOptions() { newCFG.alias.searchByAlias = true; // if only show translation, enable search by translation is necessary } - // Reload tags if the tag file changed - if (!CFG || newCFG.tagFile !== CFG.tagFile || newCFG.extra.extraFile !== CFG.extra.extraFile) { - allTags = []; - await loadTags(newCFG); - } // Reload translations if the translation file changed if (!CFG || newCFG.translation.translationFile !== CFG.translation.translationFile) { translations.clear(); await loadTranslations(newCFG); } + // Reload tags if the tag file changed (after translations so extra tag translations get re-added) + if (!CFG || newCFG.tagFile !== CFG.tagFile || newCFG.extra.extraFile !== CFG.extra.extraFile) { + allTags = []; + await loadTags(newCFG); + } // Update CSS if maxResults changed if (CFG && newCFG.maxResults !== CFG.maxResults) { diff --git a/tags/extra-quality-tags.csv b/tags/extra-quality-tags.csv index ba10bcb..0c7779a 100644 --- a/tags/extra-quality-tags.csv +++ b/tags/extra-quality-tags.csv @@ -1,6 +1,6 @@ -masterpiece,5,Quality tag, -best_quality,5,Quality tag, -high_quality,5,Quality tag, -normal_quality,5,Quality tag, -low_quality,5,Quality tag, -worst_quality,5,Quality tag, +masterpiece,5,Quality tag,, +best_quality,5,Quality tag,, +high_quality,5,Quality tag,, +normal_quality,5,Quality tag,, +low_quality,5,Quality tag,, +worst_quality,5,Quality tag,,