From ae297e9cd64a328649d32d81349e25cc5f719262 Mon Sep 17 00:00:00 2001 From: eric-intuitem <71850047+eric-intuitem@users.noreply.github.com> Date: Sat, 21 Dec 2024 21:20:33 +0100 Subject: [PATCH] Update i18n.ts --- frontend/src/lib/utils/i18n.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/utils/i18n.ts b/frontend/src/lib/utils/i18n.ts index 8e555956c..0edc699e5 100644 --- a/frontend/src/lib/utils/i18n.ts +++ b/frontend/src/lib/utils/i18n.ts @@ -11,9 +11,11 @@ export function unsafeTranslate(key: string, params = {}, options = {}): string if (Object.hasOwn(m, key)) { return m[key](params, options); } - let res = key.match('^([^:]+):([^:]+)$'); - if (res) { - return (Object.hasOwn(m, res[1]) ? m[res[1]](params, options) : res[1]) + ':' + res[2]; + if (typeof key === 'string' && key) { + let res = key.match('^([^:]+):([^:]+)$'); + if (res) { + return (Object.hasOwn(m, res[1]) ? m[res[1]](params, options) : res[1]) + ':' + res[2]; + } } if (Object.hasOwn(m, toCamelCase(key))) { return m[toCamelCase(key)](params, options);