1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-27 21:05:53 +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

@ -1,7 +1,7 @@
{
"name": "frankerfacez",
"author": "Dan Salvato LLC",
"version": "4.33.0",
"version": "4.33.1",
"description": "FrankerFaceZ is a Twitch enhancement suite.",
"private": true,
"license": "Apache-2.0",

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}`);

View file

@ -1541,14 +1541,30 @@ export default class PlayerBase extends Module {
src.connect(ctx.destination);
comp = video._ffz_compressor = ctx.createDynamicsCompressor();
try {
comp = video._ffz_compressor = new DynamicsCompressorNode(ctx);
} catch (err) {
this.log.info('Unable to uew new DynamicsCompressorNode. Falling back to old method.');
comp = video._ffz_compressor = ctx.createDynamicsCompressor();
}
if ( this.settings.get('player.gain.enable') ) {
const gain = video._ffz_gain = ctx.createGain();
let gain;
let value = video._ffz_gain_value;
if ( value == null )
value = this.settings.get('player.gain.default');
gain.gain.value = value;
try {
gain = video._ffz_gain = new GainNode(ctx, {
gain: value
});
} catch(err) {
this.log.info('Unable to uew new GainNode. Falling back to old method.');
gain = video._ffz_gain = ctx.createGain();
gain.gain.value = value;
}
comp.connect(gain);
}

View file

@ -204,6 +204,7 @@ export default class TranslationCore {
this.warn = options.warn;
this._locale = options.locale || 'en';
this._dayjs_locale = options.dayjsLocale || 'en';
this.defaultLocale = options.defaultLocale || this._locale;
this.transformation = null;
@ -250,7 +251,7 @@ export default class TranslationCore {
without_suffix = f === 'plain';
try {
return d.locale(this._locale).fromNow(without_suffix);
return d.locale(this._dayjs_locale).fromNow(without_suffix);
} catch(err) {
return d.fromNow(without_suffix);
}
@ -286,7 +287,7 @@ export default class TranslationCore {
if ( format && ! this.formats.date[format] ) {
const d = dayjs(value);
try {
return d.locale(this._locale).format(format);
return d.locale(this._dayjs_locale).format(format);
} catch(err) {
return d.format(format);
}
@ -305,7 +306,7 @@ export default class TranslationCore {
if ( format && ! this.formats.time[format] ) {
const d = dayjs(value);
try {
return d.locale(this._locale).format(format);
return d.locale(this._dayjs_locale).format(format);
} catch(err) {
return d.format(format);
}
@ -324,7 +325,7 @@ export default class TranslationCore {
if ( format && ! this.formats.datetime[format] ) {
const d = dayjs(value);
try {
return d.locale(this._locale).format(format);
return d.locale(this._dayjs_locale).format(format);
} catch(err) {
return d.format(format);
}