Skip to content

Commit ee6a2be

Browse files
committed
Fix unsafeTranslate function
This first tests key, then toCamelCase(key)
1 parent d7ee942 commit ee6a2be

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

frontend/src/lib/utils/i18n.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import { toCamelCase } from '$lib/utils/locales';
88
* @param options The options to pass to the translation function.
99
*/
1010
export function unsafeTranslate(key: string, params = {}, options = {}): string | undefined {
11-
key = toCamelCase(key);
1211
if (Object.hasOwn(m, key)) {
1312
return m[key](params, options);
1413
}
14+
if (Object.hasOwn(m, toCamelCase(key))) {
15+
return m[toCamelCase(key)](params, options);
16+
}
1517
}
1618

1719
/**
@@ -21,5 +23,5 @@ export function unsafeTranslate(key: string, params = {}, options = {}): string
2123
* @param options The options to pass to the translation function.
2224
*/
2325
export function safeTranslate(key: string, params = {}, options = {}): string {
24-
return unsafeTranslate(key) || key;
26+
return unsafeTranslate(key, params, options) || key;
2527
}

0 commit comments

Comments
 (0)