client: only catch erroneous key errors in i18n.ts
All checks were successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
All checks were successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
This commit is contained in:
parent
a673647fba
commit
76a8e000a3
1 changed files with 11 additions and 10 deletions
|
@ -20,9 +20,15 @@ class I18n<T extends Record<string, any>> {
|
||||||
// If a pattern is present in the string but not provided in args, it will not be replaced.
|
// If a pattern is present in the string but not provided in args, it will not be replaced.
|
||||||
// If `args` is not provided, no interpolation is performed.
|
// If `args` is not provided, no interpolation is performed.
|
||||||
public t(key: string, args?: Record<string, string | number>): string {
|
public t(key: string, args?: Record<string, string | number>): string {
|
||||||
|
let str;
|
||||||
try {
|
try {
|
||||||
// Resolve dot-delimited names as properties of objects.
|
// Resolve dot-delimited names as properties of objects.
|
||||||
let str = key.split('.').reduce((o, i) => o[i], this.ts) as unknown as string;
|
str = key.split('.').reduce((o, i) => o[i], this.ts) as unknown as string;
|
||||||
|
} catch (err) {
|
||||||
|
// This should normally not happen because of the English language fallback strings, see comment for ts member.
|
||||||
|
console.warn(`missing localization '${key}'`);
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
// Perform string interpolation.
|
// Perform string interpolation.
|
||||||
if (args) {
|
if (args) {
|
||||||
|
@ -32,11 +38,6 @@ class I18n<T extends Record<string, any>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
} catch (err) {
|
|
||||||
// This should normally not happen because of the English language fallback strings, see comment for ts member.
|
|
||||||
console.warn(`missing localization '${key}'`);
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue