@@ -835,7 +842,7 @@ function DatabaseList({
operator: FilterOperator.Equals,
unfilteredLabel: t('All'),
selects: [
- { label: t('Database'), value: 'database' },
+ { label: databaseLabel(), value: 'database' },
{ label: t('Semantic Layer'), value: 'semantic_layer' },
],
});
@@ -887,7 +894,8 @@ function DatabaseList({
'changed_by',
createErrorHandler(errMsg =>
t(
- 'An error occurred while fetching dataset datasource values: %s',
+ 'An error occurred while fetching %s values: %s',
+ databaseLabelLower(),
errMsg,
),
),
@@ -990,7 +998,7 @@ function DatabaseList({
description={
<>
- {t('The database')}{' '}
+ {t('The %s', databaseLabelLower())}{' '}
{databaseCurrentlyDeleting.database_name}{' '}
{t(
'is linked to %s charts that appear on %s dashboards and users have %s SQL Lab tabs using this database open. Are you sure you want to continue? Deleting the database will break those objects.',
@@ -1098,7 +1106,7 @@ function DatabaseList({
title={
}
- title={t('Delete Database?')}
+ title={t('Delete %s?', databaseLabel())}
/>
}
/>
diff --git a/superset-frontend/src/pages/DatasetList/index.tsx b/superset-frontend/src/pages/DatasetList/index.tsx
index 66a1f9662ab7..ec5e359cf709 100644
--- a/superset-frontend/src/pages/DatasetList/index.tsx
+++ b/superset-frontend/src/pages/DatasetList/index.tsx
@@ -78,6 +78,13 @@ import DuplicateDatasetModal from 'src/features/datasets/DuplicateDatasetModal';
import type DatasetType from 'src/types/Dataset';
import SemanticViewEditModal from 'src/features/semanticViews/SemanticViewEditModal';
import AddSemanticViewModal from 'src/features/semanticViews/AddSemanticViewModal';
+import {
+ datasetLabel,
+ datasetLabelLower,
+ datasetsLabel,
+ datasetsLabelLower,
+ databaseLabel,
+} from 'src/utils/semanticLayerLabels';
import { useSelector } from 'react-redux';
import { QueryObjectColumns } from 'src/views/CRUD/types';
import { WIDER_DROPDOWN_WIDTH } from 'src/components/ListView/utils';
@@ -169,7 +176,11 @@ const DatasetList: FunctionComponent = ({
state: { bulkSelectEnabled },
hasPerm,
toggleBulkSelect,
- } = useListViewResource('dataset', t('dataset'), addDangerToast);
+ } = useListViewResource(
+ 'dataset',
+ datasetLabelLower(),
+ addDangerToast,
+ );
// Combined endpoint state
const [datasets, setDatasets] = useState([]);
@@ -236,7 +247,9 @@ const DatasetList: FunctionComponent = ({
setDatasetCount(json.count);
})
.catch(() => {
- addDangerToast(t('An error occurred while fetching datasets'));
+ addDangerToast(
+ t('An error occurred while fetching %s', datasetsLabelLower()),
+ );
})
.finally(() => {
setLoading(false);
@@ -300,7 +313,7 @@ const DatasetList: FunctionComponent = ({
const handleDatasetImport = () => {
showImportModal(false);
refreshData();
- addSuccessToast(t('Dataset imported'));
+ addSuccessToast(t('%s imported', datasetLabel()));
};
const canEdit = hasPerm('can_write');
@@ -338,7 +351,10 @@ const DatasetList: FunctionComponent = ({
})
.catch(() => {
addDangerToast(
- t('An error occurred while fetching dataset related data'),
+ t(
+ 'An error occurred while fetching %s related data',
+ datasetLabelLower(),
+ ),
);
});
},
@@ -382,7 +398,12 @@ const DatasetList: FunctionComponent = ({
});
} catch (error) {
setPreparingExport(false);
- addDangerToast(t('There was an issue exporting the selected datasets'));
+ addDangerToast(
+ t(
+ 'There was an issue exporting the selected %s',
+ datasetsLabelLower(),
+ ),
+ );
}
},
[addDangerToast, setPreparingExport],
@@ -485,7 +506,7 @@ const DatasetList: FunctionComponent = ({
original: { database },
},
}: any) => database?.database_name || '-',
- Header: t('Database'),
+ Header: databaseLabel(),
accessor: 'database.database_name',
size: 'xl',
id: 'database.database_name',
@@ -713,7 +734,7 @@ const DatasetList: FunctionComponent = ({
operator: FilterOperator.Equals,
unfilteredLabel: t('All'),
selects: [
- { label: t('Database'), value: 'database' },
+ { label: databaseLabel(), value: 'database' },
{ label: t('Semantic Layer'), value: 'semantic_layer' },
],
},
@@ -763,7 +784,7 @@ const DatasetList: FunctionComponent = ({
},
]),
{
- Header: t('Database'),
+ Header: databaseLabel(),
key: 'database',
id: 'database',
input: 'select',
@@ -773,7 +794,11 @@ const DatasetList: FunctionComponent = ({
'dataset',
'database',
createErrorHandler(errMsg =>
- t('An error occurred while fetching datasets: %s', errMsg),
+ t(
+ 'An error occurred while fetching %s: %s',
+ datasetsLabelLower(),
+ errMsg,
+ ),
),
),
paginate: true,
@@ -807,7 +832,8 @@ const DatasetList: FunctionComponent = ({
'dataset',
createErrorHandler(errMsg =>
t(
- 'An error occurred while fetching dataset owner values: %s',
+ 'An error occurred while fetching %s owner values: %s',
+ datasetLabelLower(),
errMsg,
),
),
@@ -842,7 +868,8 @@ const DatasetList: FunctionComponent = ({
'changed_by',
createErrorHandler(errMsg =>
t(
- 'An error occurred while fetching dataset datasource values: %s',
+ 'An error occurred while fetching %s values: %s',
+ datasetLabelLower(),
errMsg,
),
),
@@ -857,7 +884,7 @@ const DatasetList: FunctionComponent = ({
const menuData: SubMenuProps = {
activeChild: 'Datasets',
- name: t('Datasets'),
+ name: datasetsLabel(),
};
const buttonArr: Array = [];
@@ -867,7 +894,7 @@ const DatasetList: FunctionComponent = ({
name: (
= ({
items: [
{
key: 'dataset',
- label: t('Dataset'),
+ label: datasetLabel(),
onClick: () => history.push('/dataset/add/'),
},
{
@@ -936,7 +963,7 @@ const DatasetList: FunctionComponent = ({
} else {
buttonArr.push({
icon: ,
- name: t('Dataset'),
+ name: datasetLabel(),
onClick: () => {
history.push('/dataset/add/');
},
@@ -1013,7 +1040,11 @@ const DatasetList: FunctionComponent = ({
},
createErrorHandler(errMsg =>
addDangerToast(
- t('There was an issue deleting the selected datasets: %s', errMsg),
+ t(
+ 'There was an issue deleting the selected %s: %s',
+ datasetsLabelLower(),
+ errMsg,
+ ),
),
),
);
@@ -1021,7 +1052,9 @@ const DatasetList: FunctionComponent = ({
const handleDatasetDuplicate = (newDatasetName: string) => {
if (datasetCurrentlyDuplicating === null) {
- addDangerToast(t('There was an issue duplicating the dataset.'));
+ addDangerToast(
+ t('There was an issue duplicating the %s.', datasetLabelLower()),
+ );
}
SupersetClient.post({
@@ -1037,7 +1070,11 @@ const DatasetList: FunctionComponent = ({
},
createErrorHandler(errMsg =>
addDangerToast(
- t('There was an issue duplicating the selected datasets: %s', errMsg),
+ t(
+ 'There was an issue duplicating the selected %s: %s',
+ datasetsLabelLower(),
+ errMsg,
+ ),
),
),
);
@@ -1051,7 +1088,7 @@ const DatasetList: FunctionComponent = ({
description={
<>
- {t('The dataset')}
+ {t('The %s', datasetLabelLower())}
{datasetCurrentlyDeleting.table_name}
{t(
'is linked to %s charts that appear on %s dashboards. Are you sure you want to continue? Deleting the dataset will break those objects.',
@@ -1157,7 +1194,7 @@ const DatasetList: FunctionComponent = ({
}}
onHide={closeDatasetDeleteModal}
open
- title={t('Delete Dataset?')}
+ title={t('Delete %s?', datasetLabel())}
/>
)}
{datasetCurrentlyEditing && (
@@ -1191,7 +1228,8 @@ const DatasetList: FunctionComponent = ({
@@ -1274,7 +1312,7 @@ const DatasetList: FunctionComponent = ({
(legacy: T, semantic: T): T {
+ return isFeatureEnabled(FeatureFlag.SemanticLayers) ? semantic : legacy;
+}
+
+// ---------------------------------------------------------------------------
+// "dataset" family
+// ---------------------------------------------------------------------------
+
+/** Capitalized singular: "Dataset" / "Datasource" */
+export const datasetLabel = () => sl(t('Dataset'), t('Datasource'));
+
+/** Lower-case singular: "dataset" / "datasource" */
+export const datasetLabelLower = () => sl(t('dataset'), t('datasource'));
+
+/** Capitalized plural: "Datasets" / "Datasources" */
+export const datasetsLabel = () => sl(t('Datasets'), t('Datasources'));
+
+/** Lower-case plural: "datasets" / "datasources" */
+export const datasetsLabelLower = () => sl(t('datasets'), t('datasources'));
+
+// ---------------------------------------------------------------------------
+// "database" family
+// ---------------------------------------------------------------------------
+
+/** Capitalized singular: "Database" / "Data connection" */
+export const databaseLabel = () => sl(t('Database'), t('Data connection'));
+
+/** Lower-case singular: "database" / "data connection" */
+export const databaseLabelLower = () => sl(t('database'), t('data connection'));
+
+/** Capitalized plural: "Databases" / "Data connections" */
+export const databasesLabel = () => sl(t('Databases'), t('Data connections'));
+
+/** Lower-case plural: "databases" / "data connections" */
+export const databasesLabelLower = () =>
+ sl(t('databases'), t('data connections'));