mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-05-31 20:17:22 +00:00
feat: improve locale translation not found error (#2853)
This commit is contained in:
+5
-3
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user