A dead simple way to add complex translations (i18n) in a React (DOM/Native) project 🌎🌍🌏
Added ability to escape token characters with a preceding \
.
For example:
'this is *bold* and this \*is not\*'
Added support for React Native 0.57+
Replaced custom rendered text in favor of translated text as string:
<Translator>
{({ translate }) => (
<input
placeholder={translate({
text: 'Enter your age {firstName}',
data: { firstName: 'Sergey' },
})}
/>
)}
</Translator>
Added support for custom rendered text:
<Translate
text='Enter your age {firstName}'
data={{ firstName: 'Sergey' }}
render={({ translatedText }) => (
<input placeholder={translatedText} />
)}
/>
This release comes with some nice behind the scenes functionality. The only notable API change is the removal of the need to tag
templates:
'Hi, {firstName}!': {
- en: tag `Hi, ${'firstName'}!`,
+ en: 'Hi, {firstName}!',
// ...
},