Completed options menu and got kokoro to load.

This commit is contained in:
2025-04-05 09:24:24 +00:00
parent c27ba8be6b
commit b50f60e195
13 changed files with 2170 additions and 1889 deletions
+37 -26
View File
@@ -22,20 +22,7 @@ class LocalizationModule extends BaseModule {
this.languageNames = {
'en-us': 'English (US)',
'en-gb': 'English (UK)',
'de': 'Deutsch',
'de-de': 'Deutsch (Deutschland)',
'fr': 'Français',
'fr-fr': 'Français (France)',
'es': 'Español',
'es-es': 'Español (España)',
'it': 'Italiano',
'ja': 'Japanese',
'ko': 'Korean',
'zh': 'Chinese (Simplified)',
'zh-tw': 'Chinese (Traditional)',
'ru': 'Russian',
'pt': 'Portuguese',
'pt-br': 'Portuguese (Brazil)'
'de-de': 'Deutsch (Deutschland)'
};
// Bind methods
@@ -57,23 +44,47 @@ class LocalizationModule extends BaseModule {
try {
this.reportProgress(10, "Initializing localization");
// Load default translations
await this.loadTranslations('en-us');
// Try to load browser locale if available
const browserLocale = navigator.language.toLowerCase();
if (browserLocale && browserLocale !== 'en-us') {
// Get stored locale from persistence manager if available
const persistenceManager = this.getModule('persistence-manager');
let storedLocale = null;
if (persistenceManager) {
try {
this.reportProgress(50, `Loading browser locale: ${browserLocale}`);
await this.loadTranslations(browserLocale);
this.currentLocale = browserLocale;
} catch (localeError) {
console.warn(`Failed to load browser locale ${browserLocale}:`, localeError);
storedLocale = persistenceManager.getPreference('app', 'locale');
if (storedLocale) {
console.log(`Localization: Found stored locale: ${storedLocale}`);
await this.loadTranslations(storedLocale);
this.currentLocale = storedLocale;
} else {
// If no stored locale, ensure English is the default and persist it
console.log('Localization: No stored locale found, defaulting to en-us');
await this.loadTranslations('en-us');
persistenceManager.updatePreference('app', 'locale', 'en-us');
persistenceManager.updatePreference('tts', 'language', 'en-us');
this.currentLocale = 'en-us';
}
} catch (persistError) {
console.warn(`Failed to load stored locale:`, persistError);
}
} else {
// If browser locale is available, just load it as a fallback but keep English as default
const browserLocale = navigator.language.toLowerCase();
if (browserLocale && browserLocale !== 'en-us') {
try {
this.reportProgress(50, `Loading browser locale as fallback: ${browserLocale}`);
await this.loadTranslations(browserLocale);
// Do NOT set browser locale as current - keep English as default
} catch (localeError) {
console.warn(`Failed to load browser locale ${browserLocale}:`, localeError);
}
}
}
// We don't check for persistence manager here to avoid circular dependency
// The persistence manager will update our locale after it initializes if needed
// Dispatch event to notify about loaded locale
document.dispatchEvent(new CustomEvent('localization:languageChanged', {
detail: { locale: this.currentLocale }
}));
this.reportProgress(100, "Localization ready");
return true;