diff --git a/package.json b/package.json index 00ed8306..85ddd08a 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "license": "BSD-3-Clause", "version": "5.3.3", "dependencies": { + "@eartharoid/i18n": "^1.0.0", "@emotion/react": "^11.4.1", "@emotion/styled": "^11.3.0", "@fontsource/lexend-deca": "4.4.5", diff --git a/src/components/modals/ErrorBoundary.jsx b/src/components/modals/ErrorBoundary.jsx index ee62844f..523fef2b 100644 --- a/src/components/modals/ErrorBoundary.jsx +++ b/src/components/modals/ErrorBoundary.jsx @@ -1,3 +1,4 @@ +import variables from 'modules/variables'; import { PureComponent } from 'react'; import { ErrorOutline } from '@material-ui/icons'; @@ -7,7 +8,6 @@ export default class ErrorBoundary extends PureComponent { this.state = { error: false }; - this.language = window.language.modals.main.error_boundary; } static getDerivedStateFromError(error) { @@ -24,9 +24,9 @@ export default class ErrorBoundary extends PureComponent {
-

{this.language.title}

-

{this.language.message}

- +

{variables.language.getMessage(variables.languagecode, 'modals.main.error_boundary.title')}

+

{variables.language.getMessage(variables.languagecode, 'modals.main.error_boundary.message')}

+
); diff --git a/src/components/modals/feedback/Feedback.jsx b/src/components/modals/feedback/Feedback.jsx index 310c140b..49338492 100644 --- a/src/components/modals/feedback/Feedback.jsx +++ b/src/components/modals/feedback/Feedback.jsx @@ -1,8 +1,12 @@ +import variables from 'modules/variables'; import { PureComponent } from 'react'; import './feedback.scss'; export default class FeedbackModal extends PureComponent { + getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text); + languagecode = variables.languagecode; + constructor() { super(); this.state = { @@ -18,7 +22,6 @@ export default class FeedbackModal extends PureComponent { }, formsubmit: '' }; - this.language = window.language.modals.feedback; } async submitForm(e) { @@ -27,11 +30,11 @@ export default class FeedbackModal extends PureComponent { let question_two_error, question_four_error; if (this.state.question_two.value.length <= 0) { - question_two_error = this.language.not_filled; + question_two_error = this.getMessage(this.languagecode, 'modals.feedback.not_filled'); } if (this.state.question_four.value.length <= 0) { - question_four_error = this.language.not_filled; + question_four_error = this.getMessage(this.languagecode, 'modals.feedback.not_filled'); } if (question_two_error || question_four_error) { @@ -58,7 +61,7 @@ export default class FeedbackModal extends PureComponent { }); this.setState({ - formsubmit: this.language.success + formsubmit: this.getMessage(this.languagecode, 'modals.feedback.success') }); setTimeout(() => { @@ -70,36 +73,36 @@ export default class FeedbackModal extends PureComponent { render() { return (
-

{this.language.title}

+

{this.getMessage(this.languagecode, 'modals.feedback.title')}

×
- +

this.setState({ question_one: e.target.value })}/>
- +