Fix language code detection: load supported languages on module init

Ensure SUPPORTED_LANGUAGES in language-constants.js is populated with all 55 codes
before event handlers run, so isLanguageCode() works correctly. Prevents duplicate
language codes like [hr:|hr:|...] by properly detecting language codes vs parameters.
This commit is contained in:
diodiogod
2025-10-31 18:38:58 -03:00
parent 4e75e5ffe0
commit da223f49f7
2 changed files with 6 additions and 2 deletions
+2 -2
View File
@@ -215,8 +215,8 @@ export function attachAllEventHandlers(
if (isLanguageCode(beforeColon)) {
// It's already a language tag - only update if language is different
if (beforeColon === lang) {
// Same language already exists, don't add duplicate
return null;
// Same language already exists, return unchanged
return tagContent;
} else {
// Replace the language part with new language
const charPart = firstPart.substring(colonIndex + 1);
+4
View File
@@ -5,6 +5,10 @@
*/
import { TagUtilities } from "./tag-utilities.js";
import { loadSupportedLanguages } from "./language-constants.js";
// Load supported languages into memory on module load
loadSupportedLanguages();
export function buildHistorySection(state, storageKey) {
const historySection = document.createElement("div");