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

Introduce internationalization to some additoinal places #55

Open
wants to merge 4 commits into
base: main
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
1 change: 1 addition & 0 deletions packages/jv-input-controls/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const conf: Config = {
transform: {
"^.+\\.tsx?$": "ts-jest",
},
setupFilesAfterEnv: ["./test/env.setup.ts"],
};

export default conf;
3 changes: 2 additions & 1 deletion packages/jv-input-controls/src/assets/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"translation": {
"error": "Error",
"not.yet.implemented": "This resource contains controls that are not yet supported."
"not.yet.implemented": "This resource contains controls that are not yet supported.",
"error.not.matching.pattern": "This field does not match the required pattern."
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { JVMessage, JVTypography, JVIcon } from "@jaspersoft/jv-ui-components";
import { useTranslation } from "react-i18next";
import i18n from "../i18n";

export default function NotYetImplementedMessage() {
const { t } = useTranslation() as { t: (k: string) => string };
const t = i18n.t;
return (
<JVMessage
type="error"
Expand Down
7 changes: 3 additions & 4 deletions packages/jv-input-controls/src/controls/hooks/useErrorMsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getBaseInputControlProps,
} from "../BaseInputControl";
import { useEffectAfterInitial } from "./useEffectAfterInitial";
import i18n from "../../i18n";

interface UseMandatoryMsgProps {
textValue: string | string[];
Expand All @@ -20,6 +21,7 @@ export const useErrorMsg = ({
props,
minAndMaxDate,
}: UseMandatoryMsgProps) => {
const t = i18n.t;
const [msg, setMsg] = useState<string>(defaultValue);

const validateTextValue = (textToValidate: string): string => {
Expand All @@ -32,10 +34,7 @@ export const useErrorMsg = ({
const regex = new RegExp(props.dataType.pattern);
regex.lastIndex = 0;
const isMatch = regex.test(textToValidate);
// TODO: we will need to translate this message once we add the i18n support:
theMsg = !isMatch
? "This field does not match the required pattern."
: "";
theMsg = isMatch ? "" : t("error.not.matching.pattern");
}
let isError = false;
if (!theMsg.trim() && minAndMaxDate) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright © 2005-2024. Cloud Software Group, Inc. All rights reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc End User License Agreement.
*/

import { useState } from "react";

const DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getBaseInputControlProps,
} from "../BaseInputControl";
import { useEffectAfterInitial } from "./useEffectAfterInitial";
import { useTranslation } from "react-i18next";

interface UseNumberErrorMsgProps {
textValue: string;
Expand All @@ -16,8 +17,8 @@ export const useNumberErrorMsg = ({
textValue,
props,
}: UseNumberErrorMsgProps) => {
const { t } = useTranslation() as { t: (k: string) => string };
const [msg, setMsg] = useState<string>("");

useEffectAfterInitial(() => {
// Determine the message based on:
// 1. whether the field is a number or not
Expand All @@ -44,10 +45,7 @@ export const useNumberErrorMsg = ({
const regex = new RegExp(`${props.dataType.pattern}`);
regex.lastIndex = 0;
const isMatch = regex.test(textValue);
// TODO: we will need to translate this message once we add the i18n support:
theMsg = !isMatch
? "This field does not match the required pattern."
: "";
theMsg = isMatch ? "" : t("error.not.matching.pattern");
}
const valAsNumber = +textValue;
if (!theMsg.trim()) {
Expand Down
5 changes: 0 additions & 5 deletions packages/jv-input-controls/src/utils/DateInputControlUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright © 2005-2024. Cloud Software Group, Inc. All rights reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc End User License Agreement.
*/

import { ICDataType, ICValidationRule } from "../controls/BaseInputControl";
import { getValueForVerificationText } from "./NumberUtils";
import { isEmptyObject } from "./ObjectUtils";
Expand Down
5 changes: 0 additions & 5 deletions packages/jv-input-controls/src/utils/ErrorMessageUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright © 2005-2024. Cloud Software Group, Inc. All rights reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc End User License Agreement.
*/

import { ICValidationRule } from "../controls/BaseInputControl";

export const getMandatoryErrorMessage = (
Expand Down
5 changes: 0 additions & 5 deletions packages/jv-input-controls/src/utils/NumberUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright © 2005-2024. Cloud Software Group, Inc. All rights reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc End User License Agreement.
*/

import { ICDataType } from "../controls/BaseInputControl";

const DECIMAL_SEPARATOR = "\\.";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright © 2005-2024. Cloud Software Group, Inc. All rights reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc End User License Agreement.
*/

import { renderHook } from "@testing-library/react";
import { useLiveDateFormattedState } from "../../../src/controls/hooks/useLiveDateFormattedState";

Expand Down
16 changes: 16 additions & 0 deletions packages/jv-input-controls/test/env.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
beforeEach(() => {
jest.mock("react-i18next", () => ({
useTranslation: () => {
return {
t: (str: any) => str,
i18n: {
changeLanguage: () => new Promise(() => {}),
},
};
},
initReactI18next: {
type: "3rdParty",
init: () => {},
},
}));
});
5 changes: 0 additions & 5 deletions packages/jv-input-controls/test/panels/BasePanel.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright © 2005-2024. Cloud Software Group, Inc. All rights reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc End User License Agreement.
*/

import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import BasePanel from "../../src/panels/BasePanel";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright (C) 2005 - 2023. Cloud Software Group, Inc. All Rights Reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc. End User License Agreement.
*/

import React from "react";
import { JVTypography } from "@jaspersoft/jv-ui-components";

Expand Down
5 changes: 0 additions & 5 deletions packages/jv-scheduler/src/components/Stepper/StepIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright (C) 2005 - 2023. Cloud Software Group, Inc. All Rights Reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc. End User License Agreement.
*/

import React from "react";
import { JVIcon } from "@jaspersoft/jv-ui-components";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright (C) 2005 - 2023. Cloud Software Group, Inc. All Rights Reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc. End User License Agreement.
*/

import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { setApiFailure } from "../../actions/action";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright (C) 2005 - 2023. Cloud Software Group, Inc. All Rights Reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc. End User License Agreement.
*/

import React from "react";
import {
JVIcon,
Expand Down
4 changes: 0 additions & 4 deletions packages/jv-scheduler/src/components/common/ErrorDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Copyright (C) 2005 - 2023. Cloud Software Group, Inc. All Rights Reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc. End User License Agreement.
*/
import React from "react";

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
/*
* Copyright (C) 2005 - 2023. Cloud Software Group, Inc. All Rights Reserved.
* http://www.jaspersoft.com.
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

export default {
resourceIdNotSupportedSymbols:
"[~!#\\$%^|\\s`@&*()\\-+={}\\[\\]:;\"'\\<\\>,?/\\|\\\\]",
Expand Down
5 changes: 0 additions & 5 deletions packages/jv-scheduler/src/hooks/useStoreUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright (C) 2005 - 2023. Cloud Software Group, Inc. All Rights Reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc. End User License Agreement.
*/

import { useDispatch, useSelector } from "react-redux";
import { stateValidator } from "../validations/scheduleValidators";
import {
Expand Down
5 changes: 0 additions & 5 deletions packages/jv-scheduler/src/store/store.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright (C) 2005 - 2023. Cloud Software Group, Inc. All Rights Reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc. End User License Agreement.
*/

import { applyMiddleware, createStore } from "redux";
import thunk from "redux-thunk";
import { rootReducer } from "../reducer/reducer";
Expand Down
5 changes: 0 additions & 5 deletions packages/jv-scheduler/src/validations/scheduleValidators.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright (C) 2005 - 2023. Cloud Software Group, Inc. All Rights Reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc. End User License Agreement.
*/

import _ from "underscore";
// @ts-ignore
import XRegExp from "xregexp";
Expand Down
5 changes: 0 additions & 5 deletions packages/jv-ui-components/material-ui/Date/Date.Utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright © 2005-2024. Cloud Software Group, Inc. All rights reserved. Confidential & Proprietary.
* Licensed pursuant to commercial Cloud Software Group, Inc End User License Agreement.
*/

import dayjs from "dayjs";

const castValueIfNeeded = (theValue: dayjs.Dayjs): dayjs.Dayjs => {
Expand Down
39 changes: 13 additions & 26 deletions packages/jv-ui-components/scss/_button.scss
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
/*!
* Copyright (C) 2005 - 2022 TIBCO Software Inc. All rights reserved.
* http://www.jaspersoft.com.
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* =========================================
/*! =========================================
BUTTON MODULE STYLESHEET
Last modified date: Oct 21, 2022
Last modified by: Anna Leeg
Expand Down Expand Up @@ -251,7 +230,9 @@
}

.jv-mButtonToolPlain.jv {
} // does not have state styling
}

// does not have state styling

.jv-mButtonTool.jv > .jv-mButton-icon.jv {
font-size: 16px; // new base font size
Expand Down Expand Up @@ -610,18 +591,24 @@
.jv-mButtonError.jv:focus,
.jv-mButtonError.jv:hover {
background-color: $color-errorDark;
} //broken
}

//broken

.jv-mButtonError.jv[disabled]:hover,
.jv-mButtonError.jv-isHovered[disabled].jv {
background-color: $color-errorMedium;
} //broken
}

//broken

.jv-mButtonAttention.jv-isHovered.jv,
.jv-mButtonAttention.jv:focus,
.jv-mButtonAttention.jv:hover {
background-color: $color-attentionDark;
} //broken
}

//broken

.jv-mButtonAttention.jv[disabled]:hover,
.jv-mButtonAttention.jv-isHovered[disabled].jv {
Expand Down
Loading
Loading