I18N for HTML fragments #46
Comments
Though, Solving this would also require this plugin to include an extractor too (which is a good idea overall), as other tools would not know how to extract it. |
@aikar If you have time and interest to give it a shot please feel free to do so 😛 |
I have another idea to solve this without the necessary to modify the plugin. And you can use it directly in React: render() {
<div>
...
{assembleAsArray(__('Hello ${user}, Please ${call} or ${email} us for support'), {user: user, call : <a href={dial}>__('call')</a>, email: <a href={mailto}>__('email')</a>})}
...
</div>
} If you are not using React and just want to assemble strings, you can use it as well: |
@xiao-hu In my understanding, your idea won't solve the problem, because
|
Given this mapping: This code: Should return: |
per #26
It's almost guaranteed anyone doing a serious I18N roll out will run into a scenario like this:
This plugin currently offers no native way to create this as a single i18n string for translation.
Breaking it up into
Is not a valid solution as the order of the words are likely to change in other languages.
This needs to be handled as a single string.
In React, I created a work around seen here: #26 (comment)
But this required us to use the dangerous inner html of React and uglifies the code writing HTML inside of strings.
We need a solution for this problem so that this plugin can be a complete i18n solution (along with #6)
Proposal:
JS comment tags?
JSX example
Or maybe support:
Then of course no react environments would need consideration too.
The text was updated successfully, but these errors were encountered: