diff --git a/src/components/problem-layout/Problem.js b/src/components/problem-layout/Problem.js index 0aa31fcef60..5d2dfa3628b 100644 --- a/src/components/problem-layout/Problem.js +++ b/src/components/problem-layout/Problem.js @@ -3,7 +3,7 @@ import { withStyles } from "@material-ui/core/styles"; import Button from "@material-ui/core/Button"; import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; -import ProblemCard from "./ProblemCard"; +import ProblemCardWrapper from "./ProblemCardWrapper"; import Grid from "@material-ui/core/Grid"; import { animateScroll as scroll, Element, scroller } from "react-scroll"; import update from "../../models/BKT/BKT-brain.js"; @@ -39,7 +39,7 @@ class Problem extends React.Component { constructor(props, context) { super(props); - const { setLanguage } = this.props; + const { setLanguage } = props; if (props.lesson.courseName == "Matematik 4") { setLanguage('se') } @@ -464,7 +464,7 @@ class Problem extends React.Component { name={idx.toString()} key={`${problem.id}-${step.id}`} > - ( + + {({ setLanguage }) => } + +); + +export default ProblemCardWrapper; diff --git a/src/platform-logic/Platform.js b/src/platform-logic/Platform.js index 0c9d148bc94..a1eaa2f1ec0 100644 --- a/src/platform-logic/Platform.js +++ b/src/platform-logic/Platform.js @@ -76,6 +76,14 @@ class Platform extends React.Component { } componentDidMount() { + const { setLanguage } = this.props; + if (this.props.lessonID == 5) { + setLanguage('se') + } else { + const defaultLocale = localStorage.getItem('defaultLocale'); + setLanguage(defaultLocale) + } + this._isMounted = true; if (this.props.lessonID != null) { console.log("calling selectLesson from componentDidMount...") diff --git a/src/util/useTranslation.js b/src/util/useTranslation.js index ca74aa11633..3615db1478d 100644 --- a/src/util/useTranslation.js +++ b/src/util/useTranslation.js @@ -5,7 +5,7 @@ import translationsEs from "../locales/es.json"; import translationsSe from "../locales/se.json"; export const useTranslation = () => { - const { language } = useLocalization(); + const { language, setLanguage } = useLocalization(); const translationsMap = { en: translationsEn, @@ -19,5 +19,5 @@ export const useTranslation = () => { return key.split(".").reduce((obj, k) => (obj || {})[k], translations); }; - return translate; + return { translate, setLanguage }; }; diff --git a/src/util/withTranslation.js b/src/util/withTranslation.js index b9973a1f247..33ba0917b9e 100644 --- a/src/util/withTranslation.js +++ b/src/util/withTranslation.js @@ -3,8 +3,8 @@ import { useTranslation } from './useTranslation'; const withTranslation = (WrappedComponent) => { return (props) => { - const translate = useTranslation(); - return ; + const { translate, setLanguage } = useTranslation(); + return ; }; };