* Interpolate values into a string template * Supports {{key}} syntax * @param template - String template with {{key}} placeholders * @param values - Values to interpolate * @returns Interpolated string
(template: string, values?: TranslationValues)
| 65 | * @returns Interpolated string |
| 66 | */ |
| 67 | private interpolate(template: string, values?: TranslationValues): string { |
| 68 | if (!values) { |
| 69 | return template; |
| 70 | } |
| 71 | |
| 72 | return template.replace(/\{\{(\w+)\}\}/g, (match, key) => { |
| 73 | const value = values[key]; |
| 74 | return value !== undefined ? String(value) : match; |
| 75 | }); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Add or update translations for a specific locale |