1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-06 14:20:56 +00:00
* Fixed: Locales failing to load due to missing `day.js` support.
* Fixed: Locales failing to load due to capitalization.
* Changed: Use a slightly newer API for constructing an audio compressor object for better compatibility.
This commit is contained in:
SirStendec 2022-04-25 13:47:10 -04:00
parent 2af7d5618b
commit 3ea07abb0e
4 changed files with 47 additions and 10 deletions

View file

@ -451,6 +451,10 @@ export class TranslationManager extends Module {
}
get dayjsLocale() {
return this._?._dayjs_locale;
}
get locale() {
return this._ && this._.locale;
}
@ -661,6 +665,9 @@ export class TranslationManager extends Module {
async loadLocale(locale, chunk = null) {
// Normalize the locale.
locale = locale.toLowerCase();
if ( locale === 'en' )
return {};
@ -710,12 +717,13 @@ export class TranslationManager extends Module {
}
async setLocale(new_locale) {
// Normalize the locale.
new_locale = new_locale.toLowerCase();
const old_locale = this._.locale;
if ( new_locale === old_locale )
return [];
await this.loadDayjsLocale(new_locale);
this._.locale = new_locale;
this._.clear();
this.log.info(`Changed Locale: ${new_locale} -- Old: ${old_locale}`);
@ -726,15 +734,27 @@ export class TranslationManager extends Module {
// All the built-in messages are English. We don't need special
// logic to load the translations.
this.emit(':loaded', []);
this._._dayjs_locale = 'en';
return [];
}
const data = this.localeData[new_locale];
const phrases = await this.loadLocale(data?.id || new_locale);
let djs;
try {
djs = data?.dayjs_override || new_locale;
await this.loadDayjsLocale(djs);
} catch (err) {
this.log.warn(`Unable to load DayJS locale for ${new_locale}`);
djs = 'en';
}
if ( this._.locale !== new_locale )
throw new Error('locale has changed since we started loading');
this._._dayjs_locale = djs;
const added = this._.extend(phrases);
if ( added.length ) {
this.log.info(`Loaded Locale: ${new_locale} -- Phrases: ${added.length}`);