From c839d0daf50af4e974572b3a261eae5582951bbd Mon Sep 17 00:00:00 2001
From: Artem Shumeiko <53895552+artemonsh@users.noreply.github.com>
Date: Mon, 30 Jan 2023 19:20:43 +0300
Subject: [PATCH] chore: Localization of superset pt. 2 (#22772)
---
.../ColumnConfigControl/constants.tsx | 2 +-
.../src/Calendar.js | 6 ++-
.../src/vendor/cal-heatmap.js | 8 +--
.../src/Histogram.jsx | 2 +-
.../src/Sunburst.js | 8 ++-
.../src/Radar/controlPanel.tsx | 2 +-
.../Timeseries/Regular/Bar/controlPanel.tsx | 28 +++++-----
.../src/PivotTableChart.tsx | 3 +-
.../src/react-pivottable/TableRenderers.jsx | 15 +++---
.../DataTable/components/SelectPageSize.tsx | 5 +-
.../plugin-chart-table/src/TableChart.tsx | 2 +-
.../src/SqlLab/actions/sqlLab.js | 5 +-
.../components/QueryStateLabel/index.tsx | 6 ++-
.../src/SqlLab/components/ResultSet/index.tsx | 4 +-
.../src/SqlLab/components/SouthPane/index.tsx | 3 +-
superset-frontend/src/SqlLab/constants.ts | 20 +++++++
.../src/components/DatabaseSelector/index.tsx | 3 +-
.../Datasource/ChangeDatasourceModal.tsx | 2 +-
.../Datasource/DatasourceEditor.jsx | 12 ++---
.../components/Datasource/DatasourceModal.tsx | 2 +
.../components/ListView/Filters/DateRange.tsx | 3 +-
superset-frontend/src/constants.ts | 4 +-
.../src/dashboard/actions/dashboardState.js | 5 +-
.../src/dashboard/components/SaveModal.tsx | 2 +-
.../menu/BackgroundStyleDropdown.tsx | 5 +-
.../FiltersConfigForm/DatasetSelect.tsx | 1 +
.../FiltersConfigForm/FiltersConfigForm.tsx | 4 +-
.../src/dashboard/util/newComponentFactory.js | 2 +-
superset-frontend/src/explore/constants.ts | 40 ++++++++------
.../src/profile/components/RecentActivity.tsx | 2 +
.../getChartRequiredFieldsMissingMessage.ts | 5 +-
.../src/views/CRUD/alert/AlertList.tsx | 2 +-
.../src/views/CRUD/alert/AlertReportModal.tsx | 2 +-
.../src/views/CRUD/alert/ExecutionLog.tsx | 12 ++++-
.../views/CRUD/annotation/AnnotationModal.tsx | 1 +
.../annotationlayers/AnnotationLayersList.tsx | 2 +-
.../CRUD/csstemplates/CssTemplatesList.tsx | 2 +-
.../DatabaseConnectionForm/EncryptedField.tsx | 4 +-
.../ValidatedInputField.tsx | 6 +--
.../database/DatabaseModal/SSHTunnelForm.tsx | 4 +-
.../data/database/DatabaseModal/index.tsx | 4 +-
.../src/views/CRUD/data/query/QueryList.tsx | 2 +-
.../CRUD/data/savedquery/SavedQueryList.tsx | 2 +-
superset-frontend/src/views/CRUD/hooks.ts | 6 ++-
.../src/views/CRUD/welcome/EmptyState.tsx | 13 +++--
superset/charts/post_processing.py | 7 +--
superset/connectors/base/models.py | 5 +-
superset/databases/schemas.py | 2 +-
superset/initialization/__init__.py | 9 ++--
superset/models/sql_lab.py | 5 +-
superset/sql_lab.py | 12 ++++-
superset/sqllab/exceptions.py | 9 ++--
superset/utils/date_parser.py | 2 +-
superset/utils/encrypt.py | 9 +++-
superset/views/api.py | 3 +-
superset/views/dashboard/mixin.py | 2 +-
superset/views/database/views.py | 22 ++++----
superset/views/sql_lab/views.py | 2 +-
superset/viz.py | 2 +-
.../unit_tests/charts/test_post_processing.py | 53 ++++++++++---------
60 files changed, 260 insertions(+), 157 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/ColumnConfigControl/constants.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/ColumnConfigControl/constants.tsx
index b940375aa9eb7..ecdee5be1f28a 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/ColumnConfigControl/constants.tsx
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/ColumnConfigControl/constants.tsx
@@ -81,7 +81,7 @@ const columnWidth: ControlFormItemSpec<'InputNumber'> = {
"Default minimal column width in pixels, actual width may still be larger than this if other columns don't need much space",
),
width: 120,
- placeholder: 'auto',
+ placeholder: t('auto'),
debounceDelay: 400,
validators: [validateNumber],
};
diff --git a/superset-frontend/plugins/legacy-plugin-chart-calendar/src/Calendar.js b/superset-frontend/plugins/legacy-plugin-chart-calendar/src/Calendar.js
index 0417ea3e8b5af..d97557a77b506 100644
--- a/superset-frontend/plugins/legacy-plugin-chart-calendar/src/Calendar.js
+++ b/superset-frontend/plugins/legacy-plugin-chart-calendar/src/Calendar.js
@@ -19,7 +19,7 @@
import PropTypes from 'prop-types';
import { extent as d3Extent, range as d3Range } from 'd3-array';
import { select as d3Select } from 'd3-selection';
-import { getSequentialSchemeRegistry } from '@superset-ui/core';
+import { getSequentialSchemeRegistry, t } from '@superset-ui/core';
import CalHeatMap from './vendor/cal-heatmap';
const propTypes = {
@@ -85,10 +85,12 @@ function Calendar(element, props) {
const metricsData = data.data;
+ const METRIC_TEXT = t('Metric');
+
Object.keys(metricsData).forEach(metric => {
const calContainer = div.append('div');
if (showMetricName) {
- calContainer.text(`Metric: ${verboseMap[metric] || metric}`);
+ calContainer.text(`${METRIC_TEXT}: ${verboseMap[metric] || metric}`);
}
const timestamps = metricsData[metric];
const extents = d3Extent(Object.keys(timestamps), key => timestamps[key]);
diff --git a/superset-frontend/plugins/legacy-plugin-chart-calendar/src/vendor/cal-heatmap.js b/superset-frontend/plugins/legacy-plugin-chart-calendar/src/vendor/cal-heatmap.js
index 3320693f5cc63..760bf0ce2b0c4 100644
--- a/superset-frontend/plugins/legacy-plugin-chart-calendar/src/vendor/cal-heatmap.js
+++ b/superset-frontend/plugins/legacy-plugin-chart-calendar/src/vendor/cal-heatmap.js
@@ -9,7 +9,7 @@
/* eslint-disable */
import d3tip from 'd3-tip';
-import { getContrastingColor } from '@superset-ui/core';
+import { getContrastingColor, t } from '@superset-ui/core';
var d3 = typeof require === 'function' ? require('d3') : window.d3;
@@ -256,9 +256,9 @@ var CalHeatMap = function () {
// Formatting of the title displayed when hovering a legend cell
legendTitleFormat: {
- lower: 'less than {min} {name}',
- inner: 'between {down} and {up} {name}',
- upper: 'more than {max} {name}',
+ lower: t('less than {min} {name}'),
+ inner: t('between {down} and {up} {name}'),
+ upper: t('more than {max} {name}'),
},
// Animation duration, in ms
diff --git a/superset-frontend/plugins/legacy-plugin-chart-histogram/src/Histogram.jsx b/superset-frontend/plugins/legacy-plugin-chart-histogram/src/Histogram.jsx
index 2c07267748614..67d5f30f9022d 100644
--- a/superset-frontend/plugins/legacy-plugin-chart-histogram/src/Histogram.jsx
+++ b/superset-frontend/plugins/legacy-plugin-chart-histogram/src/Histogram.jsx
@@ -111,7 +111,7 @@ class CustomHistogram extends React.PureComponent {
renderTooltip={({ datum, color }) => (
- {datum.bin0} to {datum.bin1}
+ {datum.bin0} {t('to')} {datum.bin1}
{t('count')}
diff --git a/superset-frontend/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js b/superset-frontend/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js
index f967c985fcfd4..dd70afad3b36c 100644
--- a/superset-frontend/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js
+++ b/superset-frontend/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js
@@ -24,6 +24,7 @@ import {
NumberFormats,
CategoricalColorNamespace,
getSequentialSchemeRegistry,
+ t,
} from '@superset-ui/core';
import wrapSvgText from './utils/wrapSvgText';
@@ -381,7 +382,10 @@ function Sunburst(element, props) {
.append('text')
.attr('class', 'path-abs-percent')
.attr('y', yOffsets[offsetIndex])
- .text(`${absolutePercString} of total`);
+ // eslint-disable-next-line prefer-template
+ .text(absolutePercString + ' ' + t('of total'));
+
+ const OF_PARENT_TEXT = t('of parent');
if (conditionalPercString) {
offsetIndex += 1;
@@ -389,7 +393,7 @@ function Sunburst(element, props) {
.append('text')
.attr('class', 'path-cond-percent')
.attr('y', yOffsets[offsetIndex])
- .text(`${conditionalPercString} of parent`);
+ .text(`${conditionalPercString} ${OF_PARENT_TEXT}`);
}
offsetIndex += 1;
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Radar/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Radar/controlPanel.tsx
index 3c320b05c4a04..68b9a17345ccf 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Radar/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Radar/controlPanel.tsx
@@ -50,7 +50,7 @@ const radarMetricMaxValue: { name: string; config: ControlFormItemSpec } = {
'The maximum value of metrics. It is an optional configuration',
),
width: 120,
- placeholder: 'auto',
+ placeholder: t('auto'),
debounceDelay: 400,
validators: [validateNumber],
},
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx
index 3e1bb68f49d0f..ae0dd2409c1fb 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx
@@ -52,7 +52,7 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] {
const isXAxis = axis === 'x';
const isVertical = (controls: ControlStateMapping) =>
Boolean(controls?.orientation.value === OrientationType.vertical);
- const isHorizental = (controls: ControlStateMapping) =>
+ const isHorizontal = (controls: ControlStateMapping) =>
Boolean(controls?.orientation.value === OrientationType.horizontal);
return [
[
@@ -65,7 +65,7 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] {
default: '',
description: t('Changing this control takes effect instantly'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
- isXAxis ? isVertical(controls) : isHorizental(controls),
+ isXAxis ? isVertical(controls) : isHorizontal(controls),
},
},
],
@@ -82,7 +82,7 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] {
choices: formatSelectOptions(sections.TITLE_MARGIN_OPTIONS),
description: t('Changing this control takes effect instantly'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
- isXAxis ? isVertical(controls) : isHorizental(controls),
+ isXAxis ? isVertical(controls) : isHorizontal(controls),
},
},
],
@@ -96,7 +96,7 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] {
default: '',
description: t('Changing this control takes effect instantly'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
- isXAxis ? isHorizental(controls) : isVertical(controls),
+ isXAxis ? isHorizontal(controls) : isVertical(controls),
},
},
],
@@ -113,7 +113,7 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] {
choices: formatSelectOptions(sections.TITLE_MARGIN_OPTIONS),
description: t('Changing this control takes effect instantly'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
- isXAxis ? isHorizental(controls) : isVertical(controls),
+ isXAxis ? isHorizontal(controls) : isVertical(controls),
},
},
],
@@ -130,7 +130,7 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] {
choices: sections.TITLE_POSITION_OPTIONS,
description: t('Changing this control takes effect instantly'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
- isXAxis ? isHorizental(controls) : isVertical(controls),
+ isXAxis ? isHorizontal(controls) : isVertical(controls),
},
},
],
@@ -141,7 +141,7 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
const isXAxis = axis === 'x';
const isVertical = (controls: ControlStateMapping) =>
Boolean(controls?.orientation.value === OrientationType.vertical);
- const isHorizental = (controls: ControlStateMapping) =>
+ const isHorizontal = (controls: ControlStateMapping) =>
Boolean(controls?.orientation.value === OrientationType.horizontal);
return [
[
@@ -154,7 +154,7 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
'When using other than adaptive formatting, labels may overlap.',
)}`,
visibility: ({ controls }: ControlPanelsContainerProps) =>
- isXAxis ? isVertical(controls) : isHorizental(controls),
+ isXAxis ? isVertical(controls) : isHorizontal(controls),
},
},
],
@@ -176,7 +176,7 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
'Input field supports custom rotation. e.g. 30 for 30°',
),
visibility: ({ controls }: ControlPanelsContainerProps) =>
- isXAxis ? isVertical(controls) : isHorizental(controls),
+ isXAxis ? isVertical(controls) : isHorizontal(controls),
},
},
],
@@ -187,7 +187,7 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
...sharedControls.y_axis_format,
label: t('Axis Format'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
- isXAxis ? isHorizental(controls) : isVertical(controls),
+ isXAxis ? isHorizontal(controls) : isVertical(controls),
},
},
],
@@ -201,7 +201,7 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
default: logAxis,
description: t('Logarithmic axis'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
- isXAxis ? isHorizental(controls) : isVertical(controls),
+ isXAxis ? isHorizontal(controls) : isVertical(controls),
},
},
],
@@ -215,7 +215,7 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
default: minorSplitLine,
description: t('Draw split lines for minor axis ticks'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
- isXAxis ? isHorizental(controls) : isVertical(controls),
+ isXAxis ? isHorizontal(controls) : isVertical(controls),
},
},
],
@@ -229,7 +229,7 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
renderTrigger: true,
description: t('It’s not recommended to truncate axis in Bar chart.'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
- isXAxis ? isHorizental(controls) : isVertical(controls),
+ isXAxis ? isHorizontal(controls) : isVertical(controls),
},
},
],
@@ -249,7 +249,7 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
),
visibility: ({ controls }: ControlPanelsContainerProps) =>
Boolean(controls?.truncateYAxis?.value) &&
- (isXAxis ? isHorizental(controls) : isVertical(controls)),
+ (isXAxis ? isHorizontal(controls) : isVertical(controls)),
},
},
],
diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx
index a5feed70f21bb..d9653686e11d6 100644
--- a/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx
+++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx
@@ -29,6 +29,7 @@ import {
useTheme,
isAdhocColumn,
BinaryQueryObjectFilterClause,
+ t,
} from '@superset-ui/core';
import { PivotTable, sortAs, aggregatorTemplates } from './react-pivottable';
import {
@@ -55,7 +56,7 @@ const PivotTableWrapper = styled.div`
overflow: auto;
`;
-const METRIC_KEY = 'metric';
+const METRIC_KEY = t('metric');
const vals = ['value'];
const StyledPlusSquareOutlined = styled(PlusSquareOutlined)`
diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx
index ebfc4a2536640..576325a21ddec 100644
--- a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx
+++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx
@@ -487,7 +487,9 @@ export class TableRenderer extends React.Component {
true,
)}
>
- {`Total (${this.props.aggregatorName})`}
+ {t('Total (%(aggregatorName)s)', {
+ aggregatorName: t(this.props.aggregatorName),
+ })}
) : null;
@@ -550,7 +552,9 @@ export class TableRenderer extends React.Component {
)}
>
{colAttrs.length === 0
- ? `Total (${this.props.aggregatorName})`
+ ? t('Total (%(aggregatorName)s)', {
+ aggregatorName: t(this.props.aggregatorName),
+ })
: null}
@@ -764,10 +768,9 @@ export class TableRenderer extends React.Component {
true,
)}
>
- {
- // eslint-disable-next-line prefer-template
- t('Total') + ` (${this.props.aggregatorName})`
- }
+ {t('Total (%(aggregatorName)s)', {
+ aggregatorName: t(this.props.aggregatorName),
+ })}
);
diff --git a/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SelectPageSize.tsx b/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SelectPageSize.tsx
index 989b121a3352a..48d4b9a66874e 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SelectPageSize.tsx
+++ b/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SelectPageSize.tsx
@@ -17,6 +17,7 @@
* under the License.
*/
import React from 'react';
+import { t } from '@superset-ui/core';
import { formatSelectOptions } from '@superset-ui/chart-controls';
export type SizeOption = [number, string];
@@ -34,7 +35,7 @@ function DefaultSelectRenderer({
}: SelectPageSizeRendererProps) {
return (
- Show{' '}
+ {t('Show')}{' '}
);
}
diff --git a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
index 3c4c74af9e10b..465f7bdbff135 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
+++ b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
@@ -198,7 +198,7 @@ function SelectPageSize({
}
const getNoResultsMessage = (filter: string) =>
- t(filter ? 'No matching records found' : 'No records found');
+ filter ? t('No matching records found') : t('No records found');
export default function TableChart(
props: TableChartTransformedProps & {
diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js
index a331e462d7a65..cd63a464b1402 100644
--- a/superset-frontend/src/SqlLab/actions/sqlLab.js
+++ b/superset-frontend/src/SqlLab/actions/sqlLab.js
@@ -1412,7 +1412,7 @@ export function popQuery(queryId) {
dbId: queryData.database.id,
schema: queryData.schema,
sql: queryData.sql,
- name: `Copy of ${queryData.tab_name}`,
+ name: t('Copy of %s', queryData.tab_name),
autorun: false,
};
return dispatch(addQueryEditor(queryEditorProps));
@@ -1422,6 +1422,7 @@ export function popQuery(queryId) {
}
export function popDatasourceQuery(datasourceKey, sql) {
return function (dispatch) {
+ const QUERY_TEXT = t('Query');
const datasetId = datasourceKey.split('__')[0];
return SupersetClient.get({
endpoint: `/api/v1/dataset/${datasetId}?q=(keys:!(none))`,
@@ -1429,7 +1430,7 @@ export function popDatasourceQuery(datasourceKey, sql) {
.then(({ json }) =>
dispatch(
addQueryEditor({
- name: `Query ${json.result.name}`,
+ name: `${QUERY_TEXT} ${json.result.name}`,
dbId: json.result.database.id,
schema: json.result.schema,
autorun: sql !== undefined,
diff --git a/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx b/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx
index 4a8c581a82b1a..0ae092ef5efe3 100644
--- a/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx
+++ b/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx
@@ -18,7 +18,7 @@
*/
import React from 'react';
import Label from 'src/components/Label';
-import { STATE_TYPE_MAP } from 'src/SqlLab/constants';
+import { STATE_TYPE_MAP, STATE_TYPE_MAP_LOCALIZED } from 'src/SqlLab/constants';
import { styled, Query } from '@superset-ui/core';
interface QueryStateLabelProps {
@@ -31,6 +31,8 @@ const StyledLabel = styled(Label)`
export default function QueryStateLabel({ query }: QueryStateLabelProps) {
return (
- {query.state}
+
+ {STATE_TYPE_MAP_LOCALIZED[query.state]}
+
);
}
diff --git a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx
index 81a4e47a11368..62912d66a274d 100644
--- a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx
+++ b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx
@@ -360,8 +360,8 @@ const ResultSet = ({
message={t('%(rows)d rows returned', { rows })}
onClose={() => setAlertIsOpen(false)}
description={t(
- 'The number of rows displayed is limited to %s by the dropdown.',
- rows,
+ 'The number of rows displayed is limited to %(rows)d by the dropdown.',
+ { rows },
)}
/>
diff --git a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx
index d8b2d5a0cfba8..0b389dfb39838 100644
--- a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx
@@ -35,6 +35,7 @@ import {
STATUS_OPTIONS,
STATE_TYPE_MAP,
LOCALSTORAGE_MAX_QUERY_AGE_MS,
+ STATUS_OPTIONS_LOCALIZED,
} from '../../constants';
const TAB_HEIGHT = 140;
@@ -145,7 +146,7 @@ const SouthPane = ({
};
const renderOfflineStatus = () => (
);
diff --git a/superset-frontend/src/SqlLab/constants.ts b/superset-frontend/src/SqlLab/constants.ts
index 29b0f6cf6be0b..108ce895618a0 100644
--- a/superset-frontend/src/SqlLab/constants.ts
+++ b/superset-frontend/src/SqlLab/constants.ts
@@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
+import { t } from '@superset-ui/core';
+
export const STATE_TYPE_MAP = {
offline: 'danger',
failed: 'danger',
@@ -26,6 +28,16 @@ export const STATE_TYPE_MAP = {
success: 'success',
};
+export const STATE_TYPE_MAP_LOCALIZED = {
+ offline: t('offline'),
+ failed: t('failed'),
+ pending: t('pending'),
+ fetching: t('fetching'),
+ running: t('running'),
+ stopped: t('stopped'),
+ success: t('success'),
+};
+
export const STATUS_OPTIONS = {
success: 'success',
failed: 'failed',
@@ -34,6 +46,14 @@ export const STATUS_OPTIONS = {
pending: 'pending',
};
+export const STATUS_OPTIONS_LOCALIZED = {
+ success: t('success'),
+ failed: t('failed'),
+ running: t('running'),
+ offline: t('offline'),
+ pending: t('pending'),
+};
+
export const TIME_OPTIONS = [
'now',
'1 hour ago',
diff --git a/superset-frontend/src/components/DatabaseSelector/index.tsx b/superset-frontend/src/components/DatabaseSelector/index.tsx
index 3b10e70f20901..e14bad09a89b3 100644
--- a/superset-frontend/src/components/DatabaseSelector/index.tsx
+++ b/superset-frontend/src/components/DatabaseSelector/index.tsx
@@ -248,7 +248,7 @@ export default function DatabaseSelector({
setSchemaOptions(options);
setLoadingSchemas(false);
if (options.length === 1) changeSchema(options[0]);
- if (refresh > 0) addSuccessToast('List refreshed');
+ if (refresh > 0) addSuccessToast(t('List refreshed'));
})
.catch(err => {
setLoadingSchemas(false);
@@ -321,6 +321,7 @@ export default function DatabaseSelector({
labelInValue
loading={loadingSchemas}
name="select-schema"
+ notFoundContent={t('No compatible schema found')}
placeholder={t('Select schema or type schema name')}
onChange={item => changeSchema(item as SchemaValue)}
options={schemaOptions}
diff --git a/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx b/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx
index 9875a3c1f7c30..5ec5926808da8 100644
--- a/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx
+++ b/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx
@@ -190,7 +190,7 @@ const ChangeDatasourceModal: FunctionComponent
= ({
);
});
onHide();
- addSuccessToast('Successfully changed dataset!');
+ addSuccessToast(t('Successfully changed dataset!'));
};
const handlerCancelConfirm = () => {
diff --git a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
index 4a484f12569b6..6f0f8a84862b1 100644
--- a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
+++ b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
@@ -491,7 +491,7 @@ ColumnCollectionTable.defaultProps = {
allowAddItem: false,
allowEditDataType: false,
itemGenerator: () => ({
- column_name: '',
+ column_name: t(''),
filterable: true,
groupby: true,
}),
@@ -976,8 +976,8 @@ class DatasourceEditor extends React.PureComponent {
tableColumns={['name', 'config']}
onChange={this.onDatasourcePropChange.bind(this, 'spatials')}
itemGenerator={() => ({
- name: '',
- type: '',
+ name: t(''),
+ type: t(''),
config: null,
})}
collection={spatials}
@@ -1256,7 +1256,7 @@ class DatasourceEditor extends React.PureComponent {
allowAddItem
onChange={this.onDatasourcePropChange.bind(this, 'metrics')}
itemGenerator={() => ({
- metric_name: '',
+ metric_name: t(''),
verbose_name: '',
expression: '',
})}
@@ -1418,10 +1418,10 @@ class DatasourceEditor extends React.PureComponent {
allowAddItem
allowEditDataType
itemGenerator={() => ({
- column_name: '',
+ column_name: t(''),
filterable: true,
groupby: true,
- expression: '',
+ expression: t(''),
__expanded: true,
})}
/>
diff --git a/superset-frontend/src/components/Datasource/DatasourceModal.tsx b/superset-frontend/src/components/Datasource/DatasourceModal.tsx
index 726cfaf615605..b0a0bb9c42f5f 100644
--- a/superset-frontend/src/components/Datasource/DatasourceModal.tsx
+++ b/superset-frontend/src/components/Datasource/DatasourceModal.tsx
@@ -177,6 +177,8 @@ const DatasourceModal: FunctionComponent = ({
content: renderSaveDialog(),
onOk: onConfirmSave,
icon: null,
+ okText: t('OK'),
+ cancelText: t('Cancel'),
});
};
diff --git a/superset-frontend/src/components/ListView/Filters/DateRange.tsx b/superset-frontend/src/components/ListView/Filters/DateRange.tsx
index 4dfaf11f79fdf..121131248f2d9 100644
--- a/superset-frontend/src/components/ListView/Filters/DateRange.tsx
+++ b/superset-frontend/src/components/ListView/Filters/DateRange.tsx
@@ -23,7 +23,7 @@ import React, {
useImperativeHandle,
} from 'react';
import moment, { Moment } from 'moment';
-import { styled } from '@superset-ui/core';
+import { styled, t } from '@superset-ui/core';
import { RangePicker } from 'src/components/DatePicker';
import { FormLabel } from 'src/components/Form';
import { BaseFilter, FilterHandler } from './Base';
@@ -64,6 +64,7 @@ function DateRangeFilter(
{Header}
{
diff --git a/superset-frontend/src/constants.ts b/superset-frontend/src/constants.ts
index dcef70da7e8a5..66f2f70aa795a 100644
--- a/superset-frontend/src/constants.ts
+++ b/superset-frontend/src/constants.ts
@@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
+import { t } from '@superset-ui/core';
+
import { BootstrapData, CommonBootstrapData } from './types/bootstrapTypes';
export const DATETIME_WITH_TIME_ZONE = 'YYYY-MM-DD HH:mm:ssZ';
@@ -142,7 +144,7 @@ export const SLOW_DEBOUNCE = 500;
/**
* Display null as `N/A`
*/
-export const NULL_DISPLAY = 'N/A';
+export const NULL_DISPLAY = t('N/A');
export const DEFAULT_COMMON_BOOTSTRAP_DATA: CommonBootstrapData = {
flash_messages: [],
diff --git a/superset-frontend/src/dashboard/actions/dashboardState.js b/superset-frontend/src/dashboard/actions/dashboardState.js
index 9f45b986fcdba..8db1a500eee32 100644
--- a/superset-frontend/src/dashboard/actions/dashboardState.js
+++ b/superset-frontend/src/dashboard/actions/dashboardState.js
@@ -652,7 +652,10 @@ export function maxUndoHistoryToast() {
return dispatch(
addWarningToast(
- `You have used all ${historyLength} undo slots and will not be able to fully undo subsequent actions. You may save your current state to reset the history.`,
+ t(
+ 'You have used all %(historyLength)s undo slots and will not be able to fully undo subsequent actions. You may save your current state to reset the history.',
+ { historyLength },
+ ),
),
);
};
diff --git a/superset-frontend/src/dashboard/components/SaveModal.tsx b/superset-frontend/src/dashboard/components/SaveModal.tsx
index 3cbaa40ba3532..dbdcb7b55200e 100644
--- a/superset-frontend/src/dashboard/components/SaveModal.tsx
+++ b/superset-frontend/src/dashboard/components/SaveModal.tsx
@@ -81,7 +81,7 @@ class SaveModal extends React.PureComponent {
super(props);
this.state = {
saveType: props.saveType,
- newDashName: `${props.dashboardTitle} [copy]`,
+ newDashName: props.dashboardTitle + t('[copy]'),
duplicateSlices: false,
};
diff --git a/superset-frontend/src/dashboard/components/menu/BackgroundStyleDropdown.tsx b/superset-frontend/src/dashboard/components/menu/BackgroundStyleDropdown.tsx
index cf9bdc1a58ab2..5498b72169da4 100644
--- a/superset-frontend/src/dashboard/components/menu/BackgroundStyleDropdown.tsx
+++ b/superset-frontend/src/dashboard/components/menu/BackgroundStyleDropdown.tsx
@@ -18,7 +18,7 @@
*/
import React from 'react';
import cx from 'classnames';
-import { css, styled } from '@superset-ui/core';
+import { css, styled, t } from '@superset-ui/core';
import backgroundStyleOptions from 'src/dashboard/util/backgroundStyleOptions';
import PopoverDropdown, {
@@ -73,11 +73,12 @@ const BackgroundStyleOption = styled.div`
`;
function renderButton(option: OptionProps) {
+ const BACKGROUND_TEXT = t('background');
return (
- {`${option.label} background`}
+ {`${option.label} ${BACKGROUND_TEXT}`}
);
}
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx
index ed69c6734f1f6..fa0b4fbea09b2 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx
@@ -90,6 +90,7 @@ const DatasetSelect = ({ onChange, value }: DatasetSelectProps) => {
value={value}
options={loadDatasetOptions}
onChange={onChange}
+ notFoundContent={t('No compatible datasets found')}
/>
);
};
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
index fcfde1f33a067..0b6a33f06932d 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
@@ -944,7 +944,9 @@ const FiltersConfigForm = (
{t('Time range')}}
- initialValue={filterToEdit?.time_range || 'No filter'}
+ initialValue={
+ filterToEdit?.time_range || t('No filter')
+ }
required={!hasAdhoc}
rules={[
{
diff --git a/superset-frontend/src/dashboard/util/newComponentFactory.js b/superset-frontend/src/dashboard/util/newComponentFactory.js
index 8fddfda83c385..bec990b4e6600 100644
--- a/superset-frontend/src/dashboard/util/newComponentFactory.js
+++ b/superset-frontend/src/dashboard/util/newComponentFactory.js
@@ -46,7 +46,7 @@ const typeToDefaultMetaData = {
},
[DIVIDER_TYPE]: null,
[HEADER_TYPE]: {
- text: 'New header',
+ text: t('New header'),
headerSize: MEDIUM_HEADER,
background: BACKGROUND_TRANSPARENT,
},
diff --git a/superset-frontend/src/explore/constants.ts b/superset-frontend/src/explore/constants.ts
index f45dbf2043594..cd038dac20ca3 100644
--- a/superset-frontend/src/explore/constants.ts
+++ b/superset-frontend/src/explore/constants.ts
@@ -56,33 +56,39 @@ export interface OperatorType {
export const OPERATOR_ENUM_TO_OPERATOR_TYPE: {
[key in Operators]: OperatorType;
} = {
- [Operators.EQUALS]: { display: 'Equal to (=)', operation: '==' },
- [Operators.NOT_EQUALS]: { display: 'Not equal to (≠)', operation: '!=' },
- [Operators.LESS_THAN]: { display: 'Less than (<)', operation: '<' },
+ [Operators.EQUALS]: { display: t('Equal to (=)'), operation: '==' },
+ [Operators.NOT_EQUALS]: { display: t('Not equal to (≠)'), operation: '!=' },
+ [Operators.LESS_THAN]: { display: t('Less than (<)'), operation: '<' },
[Operators.LESS_THAN_OR_EQUAL]: {
- display: 'Less or equal (<=)',
+ display: t('Less or equal (<=)'),
operation: '<=',
},
- [Operators.GREATER_THAN]: { display: 'Greater than (>)', operation: '>' },
+ [Operators.GREATER_THAN]: { display: t('Greater than (>)'), operation: '>' },
[Operators.GREATER_THAN_OR_EQUAL]: {
- display: 'Greater or equal (>=)',
+ display: t('Greater or equal (>=)'),
operation: '>=',
},
- [Operators.IN]: { display: 'In', operation: 'IN' },
- [Operators.NOT_IN]: { display: 'Not in', operation: 'NOT IN' },
- [Operators.LIKE]: { display: 'Like', operation: 'LIKE' },
- [Operators.ILIKE]: { display: 'Like (case insensitive)', operation: 'ILIKE' },
- [Operators.REGEX]: { display: 'Regex', operation: 'REGEX' },
- [Operators.IS_NOT_NULL]: { display: 'Is not null', operation: 'IS NOT NULL' },
- [Operators.IS_NULL]: { display: 'Is null', operation: 'IS NULL' },
+ [Operators.IN]: { display: t('In'), operation: 'IN' },
+ [Operators.NOT_IN]: { display: t('Not in'), operation: 'NOT IN' },
+ [Operators.LIKE]: { display: t('Like'), operation: 'LIKE' },
+ [Operators.ILIKE]: {
+ display: t('Like (case insensitive)'),
+ operation: 'ILIKE',
+ },
+ [Operators.REGEX]: { display: t('Regex'), operation: 'REGEX' },
+ [Operators.IS_NOT_NULL]: {
+ display: t('Is not null'),
+ operation: 'IS NOT NULL',
+ },
+ [Operators.IS_NULL]: { display: t('Is null'), operation: 'IS NULL' },
[Operators.LATEST_PARTITION]: {
- display: 'use latest_partition template',
+ display: t('use latest_partition template'),
operation: 'LATEST PARTITION',
},
- [Operators.IS_TRUE]: { display: 'Is true', operation: '==' },
- [Operators.IS_FALSE]: { display: 'Is false', operation: '==' },
+ [Operators.IS_TRUE]: { display: t('Is true'), operation: '==' },
+ [Operators.IS_FALSE]: { display: t('Is false'), operation: '==' },
[Operators.TEMPORAL_RANGE]: {
- display: 'TEMPORAL_RANGE',
+ display: t('TEMPORAL_RANGE'),
operation: 'TEMPORAL_RANGE',
},
};
diff --git a/superset-frontend/src/profile/components/RecentActivity.tsx b/superset-frontend/src/profile/components/RecentActivity.tsx
index 39d7b7d11c045..975d8cb3ddf3d 100644
--- a/superset-frontend/src/profile/components/RecentActivity.tsx
+++ b/superset-frontend/src/profile/components/RecentActivity.tsx
@@ -18,6 +18,7 @@
*/
import React from 'react';
import moment from 'moment';
+import { t } from '@superset-ui/core';
import rison from 'rison';
import TableLoader from '../../components/TableLoader';
@@ -48,6 +49,7 @@ export default function RecentActivity({ user }: RecentActivityProps) {
mutator={mutator}
sortable
dataEndpoint={`/api/v1/log/recent_activity/${user?.userId}/?q=${params}`}
+ noDataText={t('No Data')}
/>
);
diff --git a/superset-frontend/src/utils/getChartRequiredFieldsMissingMessage.ts b/superset-frontend/src/utils/getChartRequiredFieldsMissingMessage.ts
index ac11e8503dc2f..865452ade8251 100644
--- a/superset-frontend/src/utils/getChartRequiredFieldsMissingMessage.ts
+++ b/superset-frontend/src/utils/getChartRequiredFieldsMissingMessage.ts
@@ -19,8 +19,11 @@
import { t } from '@superset-ui/core';
+const CREATE_CHART_TEXT = t('Create chart');
+const UPDATE_CHART_TEXT = t('Update chart');
+
export const getChartRequiredFieldsMissingMessage = (isCreating: boolean) =>
t(
'Select values in highlighted field(s) in the control panel. Then run the query by clicking on the %s button.',
- isCreating ? '"Create chart"' : '"Update chart"',
+ `"${isCreating ? CREATE_CHART_TEXT : UPDATE_CHART_TEXT}"`,
);
diff --git a/superset-frontend/src/views/CRUD/alert/AlertList.tsx b/superset-frontend/src/views/CRUD/alert/AlertList.tsx
index 826b5519f4a1a..1c34167652460 100644
--- a/superset-frontend/src/views/CRUD/alert/AlertList.tsx
+++ b/superset-frontend/src/views/CRUD/alert/AlertList.tsx
@@ -455,7 +455,7 @@ function AlertList({
id: 'owners',
input: 'select',
operator: FilterOperator.relationManyMany,
- unfilteredLabel: 'All',
+ unfilteredLabel: t('All'),
fetchSelects: createFetchRelated(
'report',
'owners',
diff --git a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx
index 79a2d945fe858..d7f7a4c7364c3 100644
--- a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx
+++ b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx
@@ -571,7 +571,7 @@ const AlertReportModal: FunctionComponent