I am using i18n-js for locales and translations. I am trying to render a react-native component using interpolation.
Following is the code for reference,
// Translate function (exposed using custom hooks)
const translate = useCallback((key, config) => i18n.t(key, config), []);
// locale key with variables to be interpolated
"tnc_text": "Accept {{topUpTnC}} and {{dealsTnC}} to proceed"
// Code which uses translate
<Text>
{translate(
'tnc_text', {
topUpTnC: <Text
style={{color: 'blue'}}
onPress={() => Linking.openURL('https://google.com')}>
Top-Up Terms and Conditions*
</Text>,
dealsTnC: <Text
style={{color: 'blue'}}
onPress={() => Linking.openURL('https://example.com')}>
Deals Terms and Conditions
</Text>,
})}
</Text>
I am expecting something like this:
Accept Top-Up Terms and Conditions* and Deals Terms and Conditions to proceed
But instead, I am getting this:
Accept [object Object] and [object Object] to proceed
Couldn’t find anything in the documentation. Is there a way to replace variables with components in i18n-js?