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:
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user