parent
316069c3d9
commit
591823f90e
|
@ -11,7 +11,6 @@ export default new class LocaleManager {
|
||||||
get defaultLocale() {return "en-US";}
|
get defaultLocale() {return "en-US";}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.locale = "";
|
|
||||||
this.strings = Utilities.extend({}, Locales[this.defaultLocale]);
|
this.strings = Utilities.extend({}, Locales[this.defaultLocale]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,16 +20,13 @@ export default new class LocaleManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
setLocale() {
|
setLocale() {
|
||||||
let newStrings;
|
// Reset to the default locale in case a language is incomplete
|
||||||
if (this.discordLocale != this.defaultLocale) {
|
Utilities.extend(this.strings, Locales[this.defaultLocale]);
|
||||||
newStrings = Locales[this.discordLocale];
|
|
||||||
if (!newStrings) return this.setLocale(this.defaultLocale);
|
// Get the strings of the new language and extend if a translation exists
|
||||||
}
|
const newStrings = Locales[this.discordLocale];
|
||||||
else {
|
if (newStrings) Utilities.extendTruthy(this.strings, newStrings);
|
||||||
newStrings = Locales[this.defaultLocale];
|
|
||||||
}
|
|
||||||
this.locale = this.discordLocale;
|
|
||||||
Utilities.extendTruthy(this.strings, newStrings);
|
|
||||||
Events.emit("strings-updated");
|
Events.emit("strings-updated");
|
||||||
}
|
}
|
||||||
};
|
};
|
Loading…
Reference in New Issue