Fix i18n placeholder replacement to handle repeated occurrences
Use replaceAll instead of replace to substitute all instances of a placeholder in translation strings, not just the first one.
This commit is contained in:
parent
afc9b2e9f2
commit
6a791cec48
1 changed files with 1 additions and 1 deletions
|
|
@ -233,7 +233,7 @@ export function useI18n() {
|
||||||
function t(key: string, params: Record<string, string | number> = {}): string {
|
function t(key: string, params: Record<string, string | number> = {}): string {
|
||||||
let str = messages[settings.locale]?.[key] || messages['fr'][key] || key
|
let str = messages[settings.locale]?.[key] || messages['fr'][key] || key
|
||||||
for (const [k, v] of Object.entries(params)) {
|
for (const [k, v] of Object.entries(params)) {
|
||||||
str = str.replace(`{${k}}`, String(v))
|
str = str.replaceAll(`{${k}}`, String(v))
|
||||||
}
|
}
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue