MetaMask / MetaMask/metamask-extension
Translation named substitutions
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
### What is this about?
Our localized messages use numeric substitutions (e.g. in the message `Click $1 to see more`, the `$1` is a substitution). These have a few problems:
* It's difficult to understand what each substitution means, both in the localized message and in the codebase
* Removing or adding substitutions can be error prone (e.g. removing the first parameter requires shifting each later param by -1)
* These substitutions can be ambiguous when not separated from other words by spaces (this happens often in certain locales)
We should update our translation substitution system to use named, clearly delimited substations. We can use any alphanumeric string for the substitution name, and we can use `${ }` as a delimiter. For example, in `Click ${seeMoreLink} to see more`, the substitution would be called `seeMoreLink`.
This would also prevent errors caused by a lack of spaces after the substitution, because the `${} delimiter is totally unambiguous about where the substitution name ends.
This also makes our translations more similar to mobile (they use named substitutions as well, though without the curly bracket delimiters).
### Scenario
_No response_
### Design
_No response_
### Technical Details
We could consider adding support for named parameters alongside positional parameters, so that we can gradually introduce them.
### Threat Modeling Framework
_No response_
### Acceptance Criteria
- Named substitutions with clear delimiters are supported by our translation system
### Stakeholder review needed before the work gets merged
- [X] Engineering (needed in most cases)
- [ ] Design
- [ ] Product
- [ ] QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
- [ ] Security
- [ ] Legal
- [ ] Marketing
- [ ] Management (please specify)
- [ ] Other (please specify)
### References
_No response_
Contributor guide
Research direction
No files, tests, or entry points are named. Start by locating the translation substitution system and its current positional-parameter handling, then determine how named ${...} tokens should coexist with or replace numeric substitutions. Done means named, clearly delimited substitutions are supported and validated by the project's automation tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- localization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100