Web: People: MyProfile: Fix translations loading

This commit is contained in:
Alexey Safronov 2021-05-20 11:45:13 +03:00
parent fc822e5ad5
commit f5372bbba8
2 changed files with 42 additions and 2 deletions

View File

@ -0,0 +1,40 @@
import i18n from "i18next";
import Backend from "i18next-http-backend";
import { LANGUAGE } from "@appserver/common/constants";
import config from "../../../package.json";
const homepage = config.homepage;
//import LanguageDetector from "i18next-browser-languagedetector";
// not like to use this?
// have a look at the Quick start guide
// for passing in lng and translations on init
const newInstance = i18n.createInstance();
newInstance.use(Backend).init({
lng: localStorage.getItem(LANGUAGE) || "en",
fallbackLng: "en",
load: "languageOnly",
//debug: true,
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
format: function (value, format) {
if (format === "lowercase") return value.toLowerCase();
return value;
},
},
backend: {
loadPath: `${homepage}/locales/{{lng}}/{{ns}}.json`,
},
ns: ["Profile", "ProfileAction"],
defaultNS: "Profile",
react: {
useSuspense: false,
},
});
export default newInstance;

View File

@ -1,5 +1,5 @@
import React from "react";
import MyProfileI18n from "../../i18n";
import MyProfileI18n from "./i18n";
import PeopleStore from "../../store/PeopleStore";
import PropTypes from "prop-types";
@ -101,7 +101,7 @@ const MyProfile = withRouter(
resetProfile: peopleStore.targetUserStore.resetTargetUser,
fetchProfile: peopleStore.targetUserStore.getTargetUser,
profile: peopleStore.targetUserStore.targetUser,
}))(observer(withTranslation("Profile")(My)))
}))(withTranslation(["Profile", "ProfileAction"])(observer(My)))
);
const peopleStore = new PeopleStore();