Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify way to provide locale #195

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -107,9 +106,7 @@ const fetchTypeAheadValues = () => {
addDecorator((story) => (
<ConfigurationContextProvider options={options}>
<FormGenContextProvider fetchTypeAheadValues={fetchTypeAheadValues}>
<IntlContextProvider locale={globalTypes.locale.defaultValue}>
{story()}
</IntlContextProvider>
{story()}
</FormGenContextProvider>
</ConfigurationContextProvider>
));
248 changes: 0 additions & 248 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 12 additions & 6 deletions src/components/comment/CommentForm.jsx
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ufff ... this is not very nice, can we put it to a function? and call the function instead of having this?

? cs["comment.form.placeholder"]
: en["comment.form.placeholder"]
}
required
value={commentValue}
onChange={handleValueChange}
Expand Down
Loading