feat: improve locale translation not found error (#2853)

This commit is contained in:
Rick Staa
2023-06-19 05:06:24 +02:00
committed by GitHub
parent 03b0ba096c
commit a5260cb38a
+5 -3
View File
@@ -9,15 +9,17 @@ class I18n {
}
t(str) {
const locale = this.locale || this.fallbackLocale;
if (!this.translations[str]) {
throw new Error(`${str} Translation string not found`);
}
if (!this.translations[str][this.locale || this.fallbackLocale]) {
throw new Error(`${str} Translation locale not found`);
if (!this.translations[str][locale]) {
throw new Error(`'${str}' translation not found for locale '${locale}'`);
}
return this.translations[str][this.locale || this.fallbackLocale];
return this.translations[str][locale];
}
}