People.Client: ChangeEmailDialog: changed redux to localStorage for storing language value

This commit is contained in:
Daniil Senkiv 2020-01-21 09:36:08 +03:00
parent 57d9678b92
commit 2b961dd144
2 changed files with 9 additions and 12 deletions

View File

@ -1,6 +1,8 @@
import i18n from "i18next";
import Backend from "i18next-xhr-backend";
import config from "../../../../package.json";
import { constants } from 'asc-web-common';
const { LANGUAGE } = constants;
const newInstance = i18n.createInstance();
@ -8,7 +10,7 @@ if (process.env.NODE_ENV === "production") {
newInstance
.use(Backend)
.init({
lng: 'en',
lng: localStorage.getItem(LANGUAGE) || 'en',
fallbackLng: "en",
interpolation: {
@ -39,7 +41,7 @@ if (process.env.NODE_ENV === "production") {
newInstance.init({
resources: resources,
lng: 'en',
lng: localStorage.getItem(LANGUAGE) || 'en',
fallbackLng: "en",
debug: true,

View File

@ -1,5 +1,4 @@
import React from "react";
import { connect } from "react-redux";
import PropTypes from "prop-types";
import { withRouter } from "react-router";
import {
@ -13,14 +12,15 @@ import {
import { withTranslation } from "react-i18next";
import i18n from "./i18n";
import ModalDialogContainer from '../ModalDialogContainer';
import { api } from "asc-web-common";
import { api, utils } from "asc-web-common";
const { sendInstructionsToChangeEmail } = api.people;
const { changeLanguage } = utils;
class ChangeEmailDialogComponent extends React.Component {
constructor(props) {
super(props);
const { user, language } = props;
const { user } = props;
const { email } = user;
this.state = {
@ -32,7 +32,7 @@ class ChangeEmailDialogComponent extends React.Component {
emailErrors: []
};
i18n.changeLanguage(language);
changeLanguage(i18n);
}
componentDidMount() {
@ -169,10 +169,5 @@ ChangeEmailDialog.propTypes = {
user: PropTypes.object.isRequired
};
function mapStateToProps(state) {
return {
language: state.auth.user.cultureName || state.auth.settings.culture,
};
}
export default connect(mapStateToProps, {})(withRouter(ChangeEmailDialog));
export default withRouter(ChangeEmailDialog);