3 ms·
With formatjs [0], you don't have to split the sentence for interpolation. The same example as in the article can be implemented as: const message = define
by dheerajvs 3y ago
With formatjs [0], you don't have to split the sentence for interpolation. The same example as in the article can be implemented as:
const message = defineMessage({
defaultMessage: 'Learn more about <a>supported images</a>.',
description: 'Footer text containing a hyperlink',
})
and the anchor element can be interpolated as:
formatMessage(message, {
a: (chunks: ReactNode) => <a href="#link">{chunks}</a>,
})
[0]: https://formatjs.io https://formatjs.io
- Cthulhu_ 3y agoMy weapon of choice is i18next, which elegantly handles inline markup, even nested translations really well (although this example has less than ideal keys) <Trans i18nKey="userMessagesUnread" count={count}> Hello <strong title={t('nameTitle')}>{{name}}</strong>, you have {{count}} unread message. <Link to="/msgs">Go to messages</Link>. </Trans>
- thanatropism 3y agoMy biggest issue with i18n is not the grammar. It's the sheer uncanny valley of it. There are translations to "Hello" in Portuguese but I'd cringe at being greeted with them by a webmail client instead of the more formal Good Morning/Afternoon. The formal/informal gradient is very culture-bound and even hard to pin to a scalar space of possibilities. In a work environment people will fluently code-switch too -- say, between ranks or in the middle of a tiresome meeting when everyone takes five minutes to kick back and comment on lighter matters. It's hard to situate a computer in this social context.