- Added language-constants.js with API-driven language list (fallback to hardcoded) - Added /api/tts-audio-suite/available-languages endpoint in __init__.py - Updated widget-ui-builder.js to use getSupportedLanguages() - Updated widget-event-handlers.js to use isLanguageCode() for detection - Fixes issue where [seed:5|steps:3] now correctly becomes [de:|seed:5|steps:3] instead of [de:5|steps:3] by properly detecting language codes vs parameters
30 lines
929 B
JavaScript
30 lines
929 B
JavaScript
/**
|
|
* 🌍 Language Constants
|
|
* Single source of truth for supported languages - fetched from backend API
|
|
*/
|
|
|
|
let SUPPORTED_LANGUAGES = ["en", "de", "fr", "ja", "es", "it", "pt", "th", "no"]; // fallback
|
|
|
|
export async function loadSupportedLanguages() {
|
|
try {
|
|
const response = await fetch("/api/tts-audio-suite/available-languages");
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
if (data.languages && Array.isArray(data.languages)) {
|
|
SUPPORTED_LANGUAGES = data.languages;
|
|
}
|
|
}
|
|
} catch (err) {
|
|
console.warn("Could not load supported languages from API, using fallback:", err);
|
|
}
|
|
return SUPPORTED_LANGUAGES;
|
|
}
|
|
|
|
export function getSupportedLanguages() {
|
|
return SUPPORTED_LANGUAGES;
|
|
}
|
|
|
|
export function isLanguageCode(code) {
|
|
return SUPPORTED_LANGUAGES.includes(code.toLowerCase());
|
|
}
|