Skip to content

Instantly share code, notes, and snippets.

@zmnv
Last active December 2, 2019 11:57
Show Gist options
  • Save zmnv/53729aace40af35e429e10691ee9e218 to your computer and use it in GitHub Desktop.
Save zmnv/53729aace40af35e429e10691ee9e218 to your computer and use it in GitHub Desktop.
RN i18next example with false warning
import React, { PureComponent } from 'react';
import { View } from 'react-native';
import { connect } from 'react-redux';
import i18n from '@app/i18n';
// or import withTranslation('calibration')(Component);
import { ButtonBottom } from '@app/theme/components/Button';
class Component extends PureComponent {
...
render() {
return (
<View style={styles.root}>
<Text>{i18n.t('calibration:hello')}</Text>
</View>
);
}
}
const mapStateToProps = { ... };
const mapDispatchToProps = { ... };
export default connect(
mapStateToProps,
mapDispatchToProps,
)(Component);
import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
import { calibrationLocalesFiles } from '@app/apps/DeviceCalibrationWizard/locales';
import i18nextOptions from './i18nextOptions';
const i18n = i18next.createInstance();
i18n
.use(initReactI18next)
.init(i18nextOptions({
resources: {
en: {
calibration: calibrationLocalesFiles.en,
},
ru: {
calibration: calibrationLocalesFiles.ru,
}
},
react: {
wait: true
}
}))
;
export default i18n;
import '@app/i18n';
....
AppRegistry.registerComponent('appName', () => App);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment