Adding support for nested component inside Trans #784
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Please consider my PR for improve functionality of react-i18next.
added support for nested components, like dynamic lists just on place in Trans component
For now to include, for example,
<ul>
with several<li>
we need to create additional Component and it makes supporting of code much more complicated (several components within one file... looks like hell ).So with this PR now Trans works like this
<Trans i18nKey="key" components={[<ul>{['one', 'two'].map((item) => <li>{item}</li>}</ul>]} >
added support for values from translation message.
Another issue that really annoying me that for components we need to provide some value.
for now:
<Trans i18nKey="test" values={{v: 'some value'}} components={[
<span>{''}</span>
]} />I propose additional format:
<Trans i18nKey="test" values={{v: 'some value'}} components={[
<span />
]} />and translation message will be without changes:
"test": "some message <0>{{v}}</0>"