From c562be6f783344bacc9ee8cfe8394b6b0766bf4c Mon Sep 17 00:00:00 2001
From: Sachin Chaurasiya
Date: Thu, 15 Dec 2022 19:24:47 +0530
Subject: [PATCH] UI : Add localization (#9309)
* UI : Add localization
* address comments
---
.../ui/src/components/MyData/MyData.test.tsx | 4 -
.../components/TeamDetails/TeamDetailsV1.tsx | 12 +-
.../ui/src/locale/languages/en-us.json | 32 +-
.../ui/src/locale/languages/fr-fr.json | 2 +-
.../PoliciesDetailPage.test.tsx | 12 +-
.../PoliciesDetailPage/PoliciesDetailPage.tsx | 124 +-----
.../PoliciesDetailsList.component.tsx | 121 ++++++
.../RolesDetailPage/RolesDetailPage.test.tsx | 6 +-
.../RolesDetailPage/RolesDetailPage.tsx | 138 +------
.../RolesDetailPageList.component.tsx | 129 ++++++
.../ui/src/utils/DashboardDetailsUtils.ts | 9 +-
.../ui/src/utils/DatabaseDetailsUtils.ts | 5 +-
.../ui/src/utils/DatasetDetailsUtils.ts | 19 +-
.../resources/ui/src/utils/EntityUtils.tsx | 35 +-
.../ui/src/utils/EntityVersionUtils.tsx | 370 ++----------------
.../main/resources/ui/src/utils/FeedUtils.tsx | 22 +-
.../resources/ui/src/utils/GlossaryUtils.ts | 3 +-
.../main/resources/ui/src/utils/TasksUtils.ts | 5 +-
18 files changed, 418 insertions(+), 630 deletions(-)
create mode 100644 openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesDetailPage/PoliciesDetailsList.component.tsx
create mode 100644 openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesDetailPage/RolesDetailPageList.component.tsx
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/MyData/MyData.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/MyData/MyData.test.tsx
index 0693aaf54b2..c07c832b07c 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/MyData/MyData.test.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/MyData/MyData.test.tsx
@@ -301,10 +301,6 @@ jest.mock(
)
);
-jest.mock('../../utils/EntityVersionUtils', () => ({
- getFeedSummary: jest.fn().mockImplementation(() => EntityVersionUtils
),
-}));
-
jest.mock('../../utils/ServiceUtils', () => ({
getAllServices: jest
.fn()
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx
index f6d69c9798d..78ef856dad8 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx
@@ -286,7 +286,7 @@ const TeamDetailsV1 = ({
disabled={!entityPermissions.EditAll}
icon={
@@ -554,7 +554,7 @@ const TeamDetailsV1 = ({
showErrorToast(
error as AxiosError,
t('server.entity-fetch-error', {
- entity: 'User Permissions',
+ entity: t('label.user-permissions'),
})
);
} finally {
@@ -639,7 +639,9 @@ const TeamDetailsV1 = ({
);
const restoreIcon = useMemo(
- () => ,
+ () => (
+
+ ),
[currentTeam.isJoinable]
);
@@ -1366,7 +1368,7 @@ const TeamDetailsV1 = ({
okText={t('label.confirm')}
title={`${t('label.remove-entity', {
entity: getEntityName(selectedEntity?.record),
- })} ${t('label.from')} ${getEntityName(currentTeam)}`}
+ })} ${t('label.from-lowercase')} ${getEntityName(currentTeam)}`}
visible={!isUndefined(selectedEntity.record)}
onCancel={() => setEntity(undefined)}
onOk={async () => {
@@ -1380,7 +1382,7 @@ const TeamDetailsV1 = ({
{t('label.sure-to-remove')}{' '}
{`${getEntityName(
selectedEntity.record
- )} t('label.from') ${getEntityName(currentTeam)}?`}
+ )} t('label.from-lowercase') ${getEntityName(currentTeam)}?`}
)}
diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json
index 8fba3d0ec8f..9ba224a323c 100644
--- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json
+++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json
@@ -81,7 +81,7 @@
"sure-to-remove": "Are you sure you want to remove the",
"confirm": "Confirm",
"remove-entity": "Remove {{entity}}",
- "from": "from",
+ "from-lowercase": "from",
"add": "Add",
"add-policy": "Add Policy",
"go-back": "Go Back",
@@ -473,6 +473,25 @@
"retention-size": "retention-size",
"clean-up-policies": "clean-up policies",
"maximum-size": "maximum size",
+ "add-term": "Add Term",
+ "accept-suggestion": "Accept Suggestion",
+ "edit-amp-accept-suggestion": "Edit & Accept Suggestion",
+ "to-lowercase": "to",
+ "of-lowercase": "of",
+ "description-lowercase": "description",
+ "started-following": "Started following",
+ "unfollowed": "Unfollowed",
+ "data-asset-has-been-action-type": "Data asset has been {{actionType}}",
+ "deleted-lowercase": "deleted",
+ "restored-lowercase": "restored",
+ "edited": "Edited",
+ "added-lowercase": "added",
+ "updated-lowercase": "updated",
+ "has-been-action-type-lowercase": "has been {{actionType}}",
+ "rules": "Rules",
+ "manage-rule": "Manage Rule",
+ "users": "Users",
+ "user-permissions": "User Permissions",
"openmetadata": "OpenMetadata",
"activity-feeds": "Activity Feeds",
"search": "Search",
@@ -504,13 +523,20 @@
"search-entity": "Search {{entity}}",
"more": "More",
"update": "Update",
+ "reply-in-conversation": "Reply in conversation",
+ "older-reply-lowercase": "older reply",
+ "older-replies-lowercase": "older replies",
+ "created-a-task-lowercase": "created a task",
+ "posted-on-lowercase": "posted on",
+ "announcement": "Announcement",
+ "conversation": "Conversation",
+ "url-lowercase": "url",
+ "schemas": "Schemas",
"deleted": "Deleted {{entity}}",
"test-plural": "Tests",
"test": "Test",
- "profiler": "Profiler",
"here-lowercase": "here",
"insert": "Insert",
- "update": "Update",
"table-profile": "Table Profile",
"column-profile": "Column Profile",
"applied-advanced-search": "Applied advanced search"
diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json
index 03736da792a..33080d371a4 100644
--- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json
+++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json
@@ -81,7 +81,7 @@
"sure-to-remove": "Etes-vous sûr de vouloir supprimer le",
"confirm": "Confirmer",
"remove-entity": "Supprimer {{entity}}",
- "from": "de",
+ "from-lowercase": "de",
"add": "Ajouter",
"add-policy": "Ajouter une Police",
"go-back": "Retour en arrière",
diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesDetailPage/PoliciesDetailPage.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesDetailPage/PoliciesDetailPage.test.tsx
index 2a20f6958f9..02983b6a881 100644
--- a/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesDetailPage/PoliciesDetailPage.test.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesDetailPage/PoliciesDetailPage.test.tsx
@@ -108,6 +108,12 @@ jest.mock('../../../utils/ToastUtils', () => ({
showErrorToast: jest.fn().mockReturnValue(''),
}));
+jest.mock('react-i18next', () => ({
+ useTranslation: jest.fn().mockReturnValue({
+ t: (label: string) => label,
+ }),
+}));
+
describe('Test Policy details page', () => {
it('Should render the policy details page component', async () => {
render();
@@ -118,11 +124,11 @@ describe('Test Policy details page', () => {
const description = await screen.findByTestId('description-data');
- const rulesTab = await screen.findByText('Rules');
+ const rulesTab = await screen.findByText('label.rules');
- const rolesTab = await screen.findByText('Roles');
+ const rolesTab = await screen.findByText('label.roles');
- const teamsTab = await screen.findByText('Teams');
+ const teamsTab = await screen.findByText('label.teams');
expect(container).toBeInTheDocument();
diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesDetailPage/PoliciesDetailPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesDetailPage/PoliciesDetailPage.tsx
index 964dff4d9c2..b464d6918a0 100644
--- a/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesDetailPage/PoliciesDetailPage.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesDetailPage/PoliciesDetailPage.tsx
@@ -21,18 +21,16 @@ import {
Modal,
Row,
Space,
- Table,
Tabs,
Tooltip,
Typography,
} from 'antd';
-import { ColumnsType } from 'antd/lib/table';
import { AxiosError } from 'axios';
import { compare } from 'fast-json-patch';
import { isEmpty, isUndefined, startCase } from 'lodash';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { Link, useHistory, useParams } from 'react-router-dom';
+import { useHistory, useParams } from 'react-router-dom';
import {
getPolicyByName,
getRoleByName,
@@ -54,10 +52,6 @@ import {
GlobalSettingOptions,
GlobalSettingsMenuCategory,
} from '../../../constants/GlobalSettings.constants';
-import {
- NO_PERMISSION_FOR_ACTION,
- NO_PERMISSION_TO_VIEW,
-} from '../../../constants/HelperTextUtil';
import { EntityType } from '../../../enums/entity.enum';
import { Rule } from '../../../generated/api/policies/createPolicy';
import { Policy } from '../../../generated/entity/policies/policy';
@@ -67,105 +61,17 @@ import { DEFAULT_ENTITY_PERMISSION } from '../../../utils/PermissionsUtils';
import {
getAddPolicyRulePath,
getEditPolicyRulePath,
- getRoleWithFqnPath,
getSettingPath,
- getTeamsWithFqnPath,
} from '../../../utils/RouterUtils';
import SVGIcons, { Icons } from '../../../utils/SvgUtils';
import { showErrorToast } from '../../../utils/ToastUtils';
import './PoliciesDetail.less';
+import PoliciesDetailsList from './PoliciesDetailsList.component';
const { TabPane } = Tabs;
type Attribute = 'roles' | 'teams';
-const List = ({
- list,
- type,
- onDelete,
- hasAccess,
-}: {
- list: EntityReference[];
- type: 'role' | 'team';
- onDelete: (record: EntityReference) => void;
- hasAccess: boolean;
-}) => {
- const columns: ColumnsType = useMemo(() => {
- return [
- {
- title: 'Name',
- dataIndex: 'name',
- width: '200px',
- key: 'name',
- render: (_, record) => {
- let link = '';
- switch (type) {
- case 'role':
- link = getRoleWithFqnPath(record.fullyQualifiedName || '');
-
- break;
- case 'team':
- link = getTeamsWithFqnPath(record.fullyQualifiedName || '');
-
- break;
-
- default:
- break;
- }
-
- return (
-
- {getEntityName(record)}
-
- );
- },
- },
- {
- title: 'Description',
- dataIndex: 'description',
- key: 'description',
- render: (_, record) => (
-
- ),
- },
- {
- title: 'Actions',
- dataIndex: 'actions',
- width: '80px',
- key: 'actions',
- render: (_, record) => {
- return (
-
-
-
- );
- },
- },
- ];
- }, []);
-
- return (
-
- );
-};
-
const PoliciesDetailPage = () => {
const { t } = useTranslation();
const history = useHistory();
@@ -191,7 +97,7 @@ const PoliciesDetailPage = () => {
const breadcrumb = useMemo(
() => [
{
- name: 'Policies',
+ name: t('label.policies'),
url: policiesPath,
},
{
@@ -402,8 +308,8 @@ const PoliciesDetailPage = () => {
) : null}
{fieldsAdded?.length > 0 ? (
- {`${isPrefix ? '+ Added' : ''} ${fieldsAdded
+ {`${isPrefix ? `+ ${t('label.added')}` : ''} ${fieldsAdded
.map(summaryFormatter)
- .join(', ')} ${!isPrefix ? `has been added` : ''}`}{' '}
+ .join(', ')} ${
+ !isPrefix
+ ? t('label.has-been-action-type-lowercase', {
+ actionType: t('label.added-lowercase'),
+ })
+ : ''
+ }`}{' '}
) : null}
{fieldsUpdated?.length ? (
- {`${isPrefix ? 'Edited' : ''} ${fieldsUpdated
+ {`${isPrefix ? t('label.edited') : ''} ${fieldsUpdated
.map(summaryFormatter)
- .join(', ')} ${!isPrefix ? `has been updated` : ''}`}{' '}
+ .join(', ')} ${
+ !isPrefix
+ ? t('label.has-been-action-type-lowercase', {
+ actionType: t('label.updated-lowercase'),
+ })
+ : ''
+ }`}{' '}
) : null}
{fieldsDeleted?.length ? (
{`${isPrefix ? '- Removed' : ''} ${fieldsDeleted
.map(summaryFormatter)
- .join(', ')} ${!isPrefix ? `has been Deleted` : ''}`}{' '}
+ .join(', ')} ${
+ !isPrefix
+ ? t('label.has-been-action-type-lowercase', {
+ actionType: t('label.deleted-lowercase'),
+ })
+ : ''
+ }`}{' '}
) : null}
diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx
index c978b2d98d3..b18aa9e592e 100644
--- a/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx
@@ -15,6 +15,7 @@ import { faAngleRight } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { AxiosError } from 'axios';
import { Operation } from 'fast-json-patch';
+import i18next from 'i18next';
import { isEqual } from 'lodash';
import {
EntityFieldThreadCount,
@@ -112,10 +113,15 @@ export const getReplyText = (
singular?: string,
plural?: string
) => {
- if (count === 0) return 'Reply in conversation';
- if (count === 1) return `${count} ${singular ? singular : 'older reply'}`;
+ if (count === 0) return i18next.t('label.reply-in-conversation');
+ if (count === 1)
+ return `${count} ${
+ singular ? singular : i18next.t('label.older-reply-lowercase')
+ }`;
- return `${count} ${plural ? plural : 'older replies'}`;
+ return `${count} ${
+ plural ? plural : i18next.t('label.older-replies-lowercase')
+ }`;
};
export const getEntityFieldThreadCounts = (
@@ -481,10 +487,10 @@ export const updateThreadData = (
export const getFeedAction = (type: ThreadType) => {
if (type === ThreadType.Task) {
- return 'created a task';
+ return i18next.t('label.created-a-task-lowercase');
}
- return 'posted on';
+ return i18next.t('label.posted-on-lowercase');
};
export const prepareFeedLink = (entityType: string, entityFQN: string) => {
@@ -553,11 +559,11 @@ export const getFeedPanelHeaderText = (
) => {
switch (threadType) {
case ThreadType.Announcement:
- return 'Announcement';
+ return i18next.t('label.announcement');
case ThreadType.Task:
- return 'Task';
+ return i18next.t('label.task');
case ThreadType.Conversation:
default:
- return 'Conversation';
+ return i18next.t('label.Conversation');
}
};
diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/GlossaryUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/GlossaryUtils.ts
index 6489591323d..96a4922a3f6 100644
--- a/openmetadata-ui/src/main/resources/ui/src/utils/GlossaryUtils.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/utils/GlossaryUtils.ts
@@ -12,6 +12,7 @@
*/
import { AxiosError } from 'axios';
+import { t } from 'i18next';
import { cloneDeep, isEmpty } from 'lodash';
import { FormattedGlossarySuggestion } from 'Models';
import { DataNode } from 'rc-tree/lib/interface';
@@ -230,7 +231,7 @@ export const updateGlossaryListBySearchedTerms = (
export const getActionsList = () => {
return [
{
- name: 'Add Term',
+ name: t('label.add-term'),
value: 'add_term',
},
];
diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/TasksUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/TasksUtils.ts
index 0f6e3c9913d..40c08235e9c 100644
--- a/openmetadata-ui/src/main/resources/ui/src/utils/TasksUtils.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/utils/TasksUtils.ts
@@ -13,6 +13,7 @@
import { AxiosError } from 'axios';
import { Change, diffWordsWithSpace } from 'diff';
+import { t } from 'i18next';
import { isEqual, isUndefined } from 'lodash';
import { getDashboardByFqn } from '../axiosAPIs/dashboardAPI';
import { getUserSuggestions } from '../axiosAPIs/miscAPI';
@@ -311,11 +312,11 @@ export const fetchEntityDetail = (
export const TASK_ACTION_LIST = [
{
- label: 'Accept Suggestion',
+ label: t('label.accept-suggestion'),
key: TaskActionMode.VIEW,
},
{
- label: 'Edit & Accept Suggestion',
+ label: t('label.edit-amp-accept-suggestion'),
key: TaskActionMode.EDIT,
},
];