Fix getUserLanguagePreference to check UNCLOSEAI_LANGUAGE for intro generation
This commit is contained in:
parent
0aaba4c7c0
commit
2fecc5848a
1 changed files with 12 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
// Import translations from individual language files
|
||||
import { UI_TRANSLATIONS } from "./languages/index.js";
|
||||
import { normalizeLanguageCode } from "./config.js";
|
||||
|
||||
// Export UI_TRANSLATIONS for use in other modules
|
||||
export { UI_TRANSLATIONS };
|
||||
|
|
@ -22,7 +23,18 @@ export function getUIText(key, params = {}) {
|
|||
}
|
||||
|
||||
// Language preference management
|
||||
// Priority: window.UNCLOSEAI_LANGUAGE (forced by embed) > localStorage > "en"
|
||||
export function getUserLanguagePreference() {
|
||||
// Check for forced language from embed config first
|
||||
const rawEmbedLang = (typeof window !== "undefined" && window.UNCLOSEAI_LANGUAGE) ? window.UNCLOSEAI_LANGUAGE : null;
|
||||
if (rawEmbedLang) {
|
||||
const normalizedLang = normalizeLanguageCode(rawEmbedLang);
|
||||
if (normalizedLang) {
|
||||
return normalizedLang;
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to localStorage
|
||||
try {
|
||||
return localStorage.getItem("uncloseai_language") || "en";
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue