Bug 312967
| Summary: | Two adjacent placeholders for the i18n replacement are wrongly replaced. | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Kanaru Sato <i.am.kanaru.sato> |
| Component: | WebKit Extensions | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | timothy, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 26 | ||
| Hardware: | Mac (Apple Silicon) | ||
| OS: | macOS 26 | ||
Kanaru Sato
Named placeholder substitution in WebExtensions localization (`i18n.getMessage`) fails when two placeholders are adjacent.
Step to reproduce:
- set a message in messages.json as follows:
```
"adjacent_named": {
"message": "$prefix$$suffix$",
"placeholders": {
"prefix": { "content": "$1" },
"suffix": { "content": "$2" }
}
}
```
- Then call like this from JavaScript.
```
const args = ["3", "4"];
console.log(browser.i18n.getMessage("adjacent_named", args));
```
Expected Result:
- it shows `34`.
Actual result:
- it shows `3$SUFFIX$`.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/175315700>
Kanaru Sato
See also: https://github.com/WebKit/WebKit/pull/62313
EWS
Committed 311769@main (9d2313b02b23): <https://commits.webkit.org/311769@main>
Reviewed commits have been landed. Closing PR #63298 and removing active labels.