I have the following code:
import I18n from 'react-native-i18n'
class Demo extends React.Component {
render () {
return (
<Text>{I18n.t('DASHBOARD.AVAILABLE_BALANCE')}</Text>
// I get the following error here: [missing "en.AVAILABLE_BALANCE" translation]
)
}
}
I18n.translations = {
'en': {
'DASHBOARD.AVAILABLE_BALANCE': Hi!'
}
}
Any solution?
Hi there,
it doesn't seem like a repository issue so you should open this in stack overflow instead :)
Now, if you plan to use just 'en' and without the country part (i.e. en_GB) you need to enable fallbacks as per the README file.
Lastly your I18n.translations object can be written in a better way and you are also missing a quote in word 'Hi!'.
You code can be modified to this:
```
I18n.fallbacks = true;
I18n.translations = {
'en': {
'DASHBOARD': {
'AVAILABLE_BALANCE': 'Hi!'
}
}
};
Hi I have a Missing Translation error i call the translation like this
const dayHeadings = [
'days.sun',
'days.mon',
'days.tue',
'days.wed',
'days.thu',
'days.fri',
'days.sat',
].map(day => i18n.t(day));
and my translation is like this:
"days": {
"sun": "Sun",
"mon": "Mon",
"tue": "Tue",
"wed": "Wed",
"thu": "Thur",
"fri": "Fri",
"sat": "Sat"
}
What happens is that it says that the translation is missing but if I have the hot reload active and I save a random page the translation works
This is on the first try: as you can see the translation is there.

And here is when it hot reload

im using :
"react": "16.0.0-alpha.6",
"react-native": "0.44.0",
"react-native-i18n": "^1.0.0",
EDIT: My bad it sees it works on class component it gave this error on a stateless component
@AhsanAk @jaycee425 This is only because your are using dots in the translations keys.
You can change it with I18n.defaultSeparator = '/' or the string of your choice.
If you don't want to change it, you can use, like @marudy said:
I18n.translations = {
'en': {
'DASHBOARD': {
'AVAILABLE_BALANCE': 'Hi!'
}
}
};
Most helpful comment
Hi there,
it doesn't seem like a repository issue so you should open this in stack overflow instead :)
Now, if you plan to use just 'en' and without the country part (i.e. en_GB) you need to enable fallbacks as per the README file.
Lastly your I18n.translations object can be written in a better way and you are also missing a quote in word 'Hi!'.
You code can be modified to this:
```
I18n.fallbacks = true;
I18n.translations = {
'en': {
'DASHBOARD': {
'AVAILABLE_BALANCE': 'Hi!'
}
}
};