(key: string, params?: Record<string, string | number>)
| 39 | * @param params - Replacement parameters |
| 40 | */ |
| 41 | export function t(key: string, params?: Record<string, string | number>): string { |
| 42 | const translation = translations[currentLocale][key as TranslationKey]; |
| 43 | if (!translation) { |
| 44 | return key; |
| 45 | } |
| 46 | |
| 47 | if (!params) { |
| 48 | return translation; |
| 49 | } |
| 50 | |
| 51 | return translation.replace(/\{(\w+)\}/g, (_, paramKey: string) => { |
| 52 | const value = params[paramKey]; |
| 53 | return value !== undefined ? String(value) : `{${paramKey}}`; |
| 54 | }); |
| 55 | } |
no outgoing calls
no test coverage detected