Skip to content

Conversation

@susnux
Copy link
Contributor

@susnux susnux commented Feb 1, 2025

It makes no sense for the singular translate method to allow both at the same time. It causes developers to add a undefined just to be able to pass option. So allow one of both as the third parameter and deprecate the 5-parameters overload so we can remove it in v4.

Before:

translate('app', 'Number: %n', undefined, 4)
translate('app', 'Hello {name}', { name: 'John' })
translate('app', 'See our {linkStart}documentation{linkEnd}.', { ... }, undefined, { escape: false })

After:

translate('app', 'Number: %n', 4)
translate('app', 'Hello {name}', { name: 'John' })
translate('app', 'See our {linkStart}documentation{linkEnd}.', { ... }, { escape: false })

…er as third arg

It makes no sense for the singular translate method to allow both at the
same time. It causes developers to add a `undefined` just to be able to
pass option. So allow one of both as the third parameter and deprecate
the 5-parameters overload so we can remove it in v4.

Before:
```js
translate('app', 'Number: %n', undefined, 4)
translate('app', 'Hello {name}', { name: 'John' })
translate('app', 'See our {linkStart}documentation{linkEnd}.', { ... }, undefined, { escape: false })
```

After:
```js
translate('app', 'Number: %n', 4)
translate('app', 'Hello {name}', { name: 'John' })
translate('app', 'See our {linkStart}documentation{linkEnd}.', { ... }, { escape: false })
```

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux added type: enhancement 🚀 New feature or request 3. to review 3️⃣ Waiting for reviews labels Feb 1, 2025
@susnux susnux merged commit 1cc2694 into main Feb 4, 2025
13 checks passed
@susnux susnux deleted the feat/overload-translate branch February 4, 2025 11:18
@susnux susnux mentioned this pull request Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review 3️⃣ Waiting for reviews type: enhancement 🚀 New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants