diff --git a/products/ASC.Files/Client/src/components/panels/EmbeddingPanel/i18n.js b/products/ASC.Files/Client/src/components/panels/EmbeddingPanel/i18n.js new file mode 100644 index 0000000000..c12c54bf75 --- /dev/null +++ b/products/ASC.Files/Client/src/components/panels/EmbeddingPanel/i18n.js @@ -0,0 +1,44 @@ +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 languages = ["en", "ru"]; + +const newInstance = i18n.createInstance(); + +newInstance.use(Backend).init({ + lng: localStorage.getItem(LANGUAGE) || "en", + supportedLngs: languages, + whitelist: languages, + 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}}/EmbeddingPanel.json`, + }, + + ns: ["EmbeddingPanel"], + defaultNS: "EmbeddingPanel", + + react: { + useSuspense: false, + }, +}); + +export default newInstance; diff --git a/products/ASC.Files/Client/src/components/panels/EmbeddingPanel/index.js b/products/ASC.Files/Client/src/components/panels/EmbeddingPanel/index.js index 2f0f5c6360..cc71201877 100644 --- a/products/ASC.Files/Client/src/components/panels/EmbeddingPanel/index.js +++ b/products/ASC.Files/Client/src/components/panels/EmbeddingPanel/index.js @@ -9,7 +9,7 @@ import Link from "@appserver/components/link"; import TextInput from "@appserver/components/text-input"; import Textarea from "@appserver/components/textarea"; import toastr from "studio/toastr"; -import { withTranslation } from "react-i18next"; +import { withTranslation, I18nextProvider } from "react-i18next"; import { StyledEmbeddingPanel, StyledContent, @@ -17,6 +17,7 @@ import { StyledBody, } from "../StyledPanels"; import copy from "copy-to-clipboard"; +import i18n from "./i18n"; class EmbeddingPanelComponent extends React.Component { constructor(props) { @@ -215,4 +216,12 @@ EmbeddingPanelComponent.propTypes = { onClose: PropTypes.func, }; -export default withTranslation("EmbeddingPanel")(EmbeddingPanelComponent); +const EmbeddingPanel = withTranslation("EmbeddingPanel")( + EmbeddingPanelComponent +); + +export default (props) => ( + + + +);