Skip to content

Instantly share code, notes, and snippets.

@zonzujiro
Created July 11, 2019 13:21
Show Gist options
  • Save zonzujiro/e8525fac4b703d06e78372057a31e0b4 to your computer and use it in GitHub Desktop.
Save zonzujiro/e8525fac4b703d06e78372057a31e0b4 to your computer and use it in GitHub Desktop.
const state = {
translations: {
currentLocale: 'english',
english: {
mainPage: {
submitButton: 'Submit',
},
},
russian: {
mainPage: {
submitButton: 'Отправить',
},
},
},
};
const getCurrentLocale = state => state.currentLocale;
const getTranslation = (state, path) => {
const { currentLocale } = state.translations;
return _.get(state.translations[currentLocale], path);
}
const mapStateToProps = state => {
submitButtonText: getTranslation(state, 'mainPage.submitButton')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment