React-native-i18n: How to pass variables

Created on 3 Oct 2017  路  2Comments  路  Source: AlexanderZaytsev/react-native-i18n

I have i18n file

en.js
{
  hello: "Hello
}
....

app.js

I18n.t('hello')

In rails you can pass variables like

en.js
{
  hello: "Hello, %name"
}
....
app.js

I18n.t('hello', name: 'SomeDude') 

Output:

Hello SomeDude

Is there any way I can do this in react native? I have tried I18n.t('hello',{ name: 'SomeDude' }) but this is not working :/.

Thanks in advance!

Most helpful comment

NVM, instead of doing %name, documentation says it must be do as {{name}}

All 2 comments

NVM, instead of doing %name, documentation says it must be do as {{name}}

thanks @JulioOrellana this should be documented in the README file

Was this page helpful?
0 / 5 - 0 ratings