diff --git a/.storybook/preview.js b/.storybook/preview.js index 6082c8e4..bd4f2e38 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -1,6 +1,5 @@ import Constants from "../src/constants/Constants"; import { addDecorator } from "@storybook/react"; -import IntlContextProvider from "../src/contexts/IntlContextProvider"; import { FormGenContextProvider } from "../src/contexts/FormGenContext"; import { ConfigurationContextProvider } from "../src/contexts/ConfigurationContext"; @@ -107,9 +106,7 @@ const fetchTypeAheadValues = () => { addDecorator((story) => ( - - {story()} - + {story()} )); diff --git a/package-lock.json b/package-lock.json index e1fc5c7d..56d3130c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,6 @@ "prop-types": "^15.7.2", "react-bootstrap": "1.0.1", "react-datepicker": "^4.2.1", - "react-intl": "^5.24.6", "react-loader-spinner": "^5.1.0", "react-select": "^3.1.0", "react-window": "^1.8.5", @@ -1988,92 +1987,6 @@ "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz", "integrity": "sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==" }, - "node_modules/@formatjs/ecma402-abstract": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.11.3.tgz", - "integrity": "sha512-kP/Buv5vVFMAYLHNvvUzr0lwRTU0u2WTy44Tqwku1X3C3lJ5dKqDCYVqA8wL+Y19Bq+MwHgxqd5FZJRCIsLRyQ==", - "dependencies": { - "@formatjs/intl-localematcher": "0.2.24", - "tslib": "^2.1.0" - } - }, - "node_modules/@formatjs/fast-memoize": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-1.2.1.tgz", - "integrity": "sha512-Rg0e76nomkz3vF9IPlKeV+Qynok0r7YZjL6syLz4/urSg0IbjPZCB/iYUMNsYA643gh4mgrX3T7KEIFIxJBQeg==", - "dependencies": { - "tslib": "^2.1.0" - } - }, - "node_modules/@formatjs/icu-messageformat-parser": { - "version": "2.0.18", - "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.0.18.tgz", - "integrity": "sha512-vquIzsAJJmZ5jWVH8dEgUKcbG4yu3KqtyPet+q35SW5reLOvblkfeCXTRW2TpIwNXzdVqsJBwjbTiRiSU9JxwQ==", - "dependencies": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/icu-skeleton-parser": "1.3.5", - "tslib": "^2.1.0" - } - }, - "node_modules/@formatjs/icu-skeleton-parser": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.3.5.tgz", - "integrity": "sha512-Nhyo2/6kG7ZfgeEfo02sxviOuBcvtzH6SYUharj3DLCDJH3A/4OxkKcmx/2PWGX4bc6iSieh+FA94CsKDxnZBQ==", - "dependencies": { - "@formatjs/ecma402-abstract": "1.11.3", - "tslib": "^2.1.0" - } - }, - "node_modules/@formatjs/intl": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@formatjs/intl/-/intl-2.1.0.tgz", - "integrity": "sha512-1iGGqKcCym+ZH+cktHa6YILVGn8Sve+yuYK7hJpN21JiPKCPJuFJViKFY6rDM5jnj5LDCeH8N5YbhQjccDVOVA==", - "dependencies": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/fast-memoize": "1.2.1", - "@formatjs/icu-messageformat-parser": "2.0.18", - "@formatjs/intl-displaynames": "5.4.2", - "@formatjs/intl-listformat": "6.5.2", - "intl-messageformat": "9.11.4", - "tslib": "^2.1.0" - }, - "peerDependencies": { - "typescript": "^4.5" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@formatjs/intl-displaynames": { - "version": "5.4.2", - "resolved": "https://registry.npmjs.org/@formatjs/intl-displaynames/-/intl-displaynames-5.4.2.tgz", - "integrity": "sha512-SLesCDan9NCMqBbHPXMEwqAcPn3tnbQw0sv0rssH1JQDLDUQYwKXL93kz30X3yskTyQS7N+pd47bhoIe3kbXyw==", - "dependencies": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/intl-localematcher": "0.2.24", - "tslib": "^2.1.0" - } - }, - "node_modules/@formatjs/intl-listformat": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/@formatjs/intl-listformat/-/intl-listformat-6.5.2.tgz", - "integrity": "sha512-/IYagQJkzTvpBlhhaysGYNgM3o72WBg1ZWZcpookkgXEJbINwLP5kVagHxmgxffYKs1CDzQ8rmKHghu2qR/7zw==", - "dependencies": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/intl-localematcher": "0.2.24", - "tslib": "^2.1.0" - } - }, - "node_modules/@formatjs/intl-localematcher": { - "version": "0.2.24", - "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.2.24.tgz", - "integrity": "sha512-K/HRGo6EMnCbhpth/y3u4rW4aXkmQNqRe1L2G+Y5jNr3v0gYhvaucV8WixNju/INAMbPBlbsRBRo/nfjnoOnxQ==", - "dependencies": { - "tslib": "^2.1.0" - } - }, "node_modules/@fortawesome/fontawesome-common-types": { "version": "0.2.36", "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.36.tgz", @@ -5843,15 +5756,6 @@ "@types/unist": "*" } }, - "node_modules/@types/hoist-non-react-statics": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz", - "integrity": "sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==", - "dependencies": { - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0" - } - }, "node_modules/@types/html-minifier-terser": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-5.1.2.tgz", @@ -14635,17 +14539,6 @@ "node": ">= 0.10" } }, - "node_modules/intl-messageformat": { - "version": "9.11.4", - "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-9.11.4.tgz", - "integrity": "sha512-77TSkNubIy/hsapz6LQpyR6OADcxhWdhSaboPb5flMaALCVkPvAIxr48AlPqaMl4r1anNcvR9rpLWVdwUY1IKg==", - "dependencies": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/fast-memoize": "1.2.1", - "@formatjs/icu-messageformat-parser": "2.0.18", - "tslib": "^2.1.0" - } - }, "node_modules/invariant": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", @@ -21913,32 +21806,6 @@ "react": "^16.8.4 || ^17.0.0" } }, - "node_modules/react-intl": { - "version": "5.24.7", - "resolved": "https://registry.npmjs.org/react-intl/-/react-intl-5.24.7.tgz", - "integrity": "sha512-URPLwISsEmnzft33honGEb87LcK0QtwkZXCNsXcDYTnrYC8ZyeJRTcPYvuXC3mrN6+DxnW52RfHC416zNxfyIg==", - "dependencies": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/icu-messageformat-parser": "2.0.18", - "@formatjs/intl": "2.1.0", - "@formatjs/intl-displaynames": "5.4.2", - "@formatjs/intl-listformat": "6.5.2", - "@types/hoist-non-react-statics": "^3.3.1", - "@types/react": "16 || 17", - "hoist-non-react-statics": "^3.3.2", - "intl-messageformat": "9.11.4", - "tslib": "^2.1.0" - }, - "peerDependencies": { - "react": "^16.3.0 || 17", - "typescript": "^4.5" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -29472,84 +29339,6 @@ "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz", "integrity": "sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==" }, - "@formatjs/ecma402-abstract": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.11.3.tgz", - "integrity": "sha512-kP/Buv5vVFMAYLHNvvUzr0lwRTU0u2WTy44Tqwku1X3C3lJ5dKqDCYVqA8wL+Y19Bq+MwHgxqd5FZJRCIsLRyQ==", - "requires": { - "@formatjs/intl-localematcher": "0.2.24", - "tslib": "^2.1.0" - } - }, - "@formatjs/fast-memoize": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-1.2.1.tgz", - "integrity": "sha512-Rg0e76nomkz3vF9IPlKeV+Qynok0r7YZjL6syLz4/urSg0IbjPZCB/iYUMNsYA643gh4mgrX3T7KEIFIxJBQeg==", - "requires": { - "tslib": "^2.1.0" - } - }, - "@formatjs/icu-messageformat-parser": { - "version": "2.0.18", - "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.0.18.tgz", - "integrity": "sha512-vquIzsAJJmZ5jWVH8dEgUKcbG4yu3KqtyPet+q35SW5reLOvblkfeCXTRW2TpIwNXzdVqsJBwjbTiRiSU9JxwQ==", - "requires": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/icu-skeleton-parser": "1.3.5", - "tslib": "^2.1.0" - } - }, - "@formatjs/icu-skeleton-parser": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.3.5.tgz", - "integrity": "sha512-Nhyo2/6kG7ZfgeEfo02sxviOuBcvtzH6SYUharj3DLCDJH3A/4OxkKcmx/2PWGX4bc6iSieh+FA94CsKDxnZBQ==", - "requires": { - "@formatjs/ecma402-abstract": "1.11.3", - "tslib": "^2.1.0" - } - }, - "@formatjs/intl": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@formatjs/intl/-/intl-2.1.0.tgz", - "integrity": "sha512-1iGGqKcCym+ZH+cktHa6YILVGn8Sve+yuYK7hJpN21JiPKCPJuFJViKFY6rDM5jnj5LDCeH8N5YbhQjccDVOVA==", - "requires": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/fast-memoize": "1.2.1", - "@formatjs/icu-messageformat-parser": "2.0.18", - "@formatjs/intl-displaynames": "5.4.2", - "@formatjs/intl-listformat": "6.5.2", - "intl-messageformat": "9.11.4", - "tslib": "^2.1.0" - } - }, - "@formatjs/intl-displaynames": { - "version": "5.4.2", - "resolved": "https://registry.npmjs.org/@formatjs/intl-displaynames/-/intl-displaynames-5.4.2.tgz", - "integrity": "sha512-SLesCDan9NCMqBbHPXMEwqAcPn3tnbQw0sv0rssH1JQDLDUQYwKXL93kz30X3yskTyQS7N+pd47bhoIe3kbXyw==", - "requires": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/intl-localematcher": "0.2.24", - "tslib": "^2.1.0" - } - }, - "@formatjs/intl-listformat": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/@formatjs/intl-listformat/-/intl-listformat-6.5.2.tgz", - "integrity": "sha512-/IYagQJkzTvpBlhhaysGYNgM3o72WBg1ZWZcpookkgXEJbINwLP5kVagHxmgxffYKs1CDzQ8rmKHghu2qR/7zw==", - "requires": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/intl-localematcher": "0.2.24", - "tslib": "^2.1.0" - } - }, - "@formatjs/intl-localematcher": { - "version": "0.2.24", - "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.2.24.tgz", - "integrity": "sha512-K/HRGo6EMnCbhpth/y3u4rW4aXkmQNqRe1L2G+Y5jNr3v0gYhvaucV8WixNju/INAMbPBlbsRBRo/nfjnoOnxQ==", - "requires": { - "tslib": "^2.1.0" - } - }, "@fortawesome/fontawesome-common-types": { "version": "0.2.36", "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.36.tgz", @@ -32228,15 +32017,6 @@ "@types/unist": "*" } }, - "@types/hoist-non-react-statics": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz", - "integrity": "sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==", - "requires": { - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0" - } - }, "@types/html-minifier-terser": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-5.1.2.tgz", @@ -39347,17 +39127,6 @@ "integrity": "sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==", "dev": true }, - "intl-messageformat": { - "version": "9.11.4", - "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-9.11.4.tgz", - "integrity": "sha512-77TSkNubIy/hsapz6LQpyR6OADcxhWdhSaboPb5flMaALCVkPvAIxr48AlPqaMl4r1anNcvR9rpLWVdwUY1IKg==", - "requires": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/fast-memoize": "1.2.1", - "@formatjs/icu-messageformat-parser": "2.0.18", - "tslib": "^2.1.0" - } - }, "invariant": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", @@ -44749,23 +44518,6 @@ "prop-types": "^15.0.0" } }, - "react-intl": { - "version": "5.24.7", - "resolved": "https://registry.npmjs.org/react-intl/-/react-intl-5.24.7.tgz", - "integrity": "sha512-URPLwISsEmnzft33honGEb87LcK0QtwkZXCNsXcDYTnrYC8ZyeJRTcPYvuXC3mrN6+DxnW52RfHC416zNxfyIg==", - "requires": { - "@formatjs/ecma402-abstract": "1.11.3", - "@formatjs/icu-messageformat-parser": "2.0.18", - "@formatjs/intl": "2.1.0", - "@formatjs/intl-displaynames": "5.4.2", - "@formatjs/intl-listformat": "6.5.2", - "@types/hoist-non-react-statics": "^3.3.1", - "@types/react": "16 || 17", - "hoist-non-react-statics": "^3.3.2", - "intl-messageformat": "9.11.4", - "tslib": "^2.1.0" - } - }, "react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", diff --git a/package.json b/package.json index 1351f56e..d6d10fd7 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,6 @@ "prop-types": "^15.7.2", "react-bootstrap": "1.0.1", "react-datepicker": "^4.2.1", - "react-intl": "^5.24.6", "react-loader-spinner": "^5.1.0", "react-select": "^3.1.0", "react-window": "^1.8.5", diff --git a/src/components/comment/CommentForm.jsx b/src/components/comment/CommentForm.jsx index defd4445..46764c30 100644 --- a/src/components/comment/CommentForm.jsx +++ b/src/components/comment/CommentForm.jsx @@ -1,15 +1,19 @@ -import React, { useEffect, useRef, useState } from "react"; +import React, { useContext, useEffect, useRef, useState } from "react"; import { Button, Form, Col, Row } from "react-bootstrap"; import PropTypes from "prop-types"; import ArrowRight from "../../styles/icons/ArrowRight"; -import { useIntl } from "react-intl"; +import { ConfigurationContext } from "../../contexts/ConfigurationContext.js"; +import cs from "../../i18n/cs.json"; +import en from "../../i18n/en.json"; const MAX_TEXT_AREA_HEIGHT = "300px"; const CommentForm = (props) => { + const configurationContext = useContext(ConfigurationContext); const [commentValue, setCommentValue] = useState(""); const formInputRef = useRef(null); - const intl = useIntl(); + + const intl = configurationContext.options.intl; useEffect(() => { formInputRef.current.focus(); @@ -62,9 +66,11 @@ const CommentForm = (props) => { className="comment-form-control" name="comment" as="textarea" - placeholder={intl.formatMessage({ - id: "comment.form.placeholder", - })} + placeholder={ + intl.locale !== "en" + ? cs["comment.form.placeholder"] + : en["comment.form.placeholder"] + } required value={commentValue} onChange={handleValueChange} diff --git a/src/contexts/IntlContextProvider.tsx b/src/contexts/IntlContextProvider.tsx deleted file mode 100644 index 3ce7c44e..00000000 --- a/src/contexts/IntlContextProvider.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import React, { ReactNode } from "react"; -import Constants from "../constants/Constants"; -import cs from "../i18n/cs.json"; -import en from "../i18n/en.json"; -import { IntlProvider } from "react-intl"; - -export const IntlContext = React.createContext({}); - -interface Props { - children: ReactNode; - locale?: string; -} - -const IntlContextProvider = ({ - children, - locale = navigator.language, -}: Props) => { - let lang = en; - if (locale === Constants.LANG.cs.locale) { - lang = cs; - } - - return ( - - - {children} - - - ); -}; - -export default IntlContextProvider; diff --git a/src/s-forms.js b/src/s-forms.js index 4fecbfda..79ca7cac 100644 --- a/src/s-forms.js +++ b/src/s-forms.js @@ -11,7 +11,6 @@ import Answer from "./components/Answer"; import HelpIcon from "./components/HelpIcon"; import WizardStep from "./components/wizard/WizardStep"; import QuestionStatic from "./components/QuestionStatic"; -import IntlContextProvider from "./contexts/IntlContextProvider.js"; export default SForms; export { @@ -27,5 +26,4 @@ export { FormQuestionsContext, WizardStep, QuestionStatic, - IntlContextProvider, }; diff --git a/src/stories/CommentForm.stories.tsx b/src/stories/CommentForm.stories.tsx index 33e854b0..7030e104 100644 --- a/src/stories/CommentForm.stories.tsx +++ b/src/stories/CommentForm.stories.tsx @@ -1,6 +1,6 @@ import React from "react"; import { ComponentMeta, ComponentStory } from "@storybook/react"; -import IntlContextProvider from "../contexts/IntlContextProvider"; +import { ConfigurationContextProvider } from "../contexts/ConfigurationContext"; import CommentForm from "../components/comment/CommentForm"; @@ -14,9 +14,17 @@ const Template: ComponentStory = ( { globals: { locale } } ) => { return ( - - - + <> + + + + ); }; diff --git a/src/stories/QuestionCommentIcon.stories.tsx b/src/stories/QuestionCommentIcon.stories.tsx index fefd373b..4e59f099 100644 --- a/src/stories/QuestionCommentIcon.stories.tsx +++ b/src/stories/QuestionCommentIcon.stories.tsx @@ -1,7 +1,6 @@ import React from "react"; import QuestionCommentIcon from "../components/comment/QuestionCommentIcon"; import { ComponentMeta, ComponentStory } from "@storybook/react"; -import IntlContextProvider from "../contexts/IntlContextProvider"; import { ConfigurationContextProvider } from "../contexts/ConfigurationContext"; import question from "./assets/question/question.json"; @@ -31,9 +30,7 @@ const Template: ComponentStory = ( }; return ( - - - + ); }; diff --git a/src/stories/SForms.stories.tsx b/src/stories/SForms.stories.tsx index e76d5587..859bc118 100644 --- a/src/stories/SForms.stories.tsx +++ b/src/stories/SForms.stories.tsx @@ -11,7 +11,6 @@ import occurrenceReportingForm from "./assets/form/occurrenceReportingForm.json" import queryString from "query-string"; import Constants from "../constants/Constants"; -import IntlContextProvider from "../contexts/IntlContextProvider"; import possibleValues from "./assets/possibleValues.json"; const getP = (queryParameterName: string, defaultValue: string) => { @@ -91,13 +90,11 @@ const Template: ComponentStory = ( }; return ( - - - + ); };