Skip to content

Commit

Permalink
fix: Translations related to the date range filter (apache#26074)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralkion authored Feb 21, 2024
1 parent 2e4f6d3 commit cc2f6f1
Show file tree
Hide file tree
Showing 41 changed files with 293,830 additions and 293,594 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('Time range filter', () => {
.click()
.then(() => {
cy.get('.ant-radio-group').children().its('length').should('eq', 5);
cy.get('.ant-radio-checked + span').contains('last year');
cy.get('.ant-radio-checked + span').contains('Last year');
cy.get('[data-test=cancel-button]').click();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import React, { forwardRef, ReactNode, RefObject } from 'react';
import { css, styled, useTheme } from '@superset-ui/core';
import { css, styled, useTheme, t } from '@superset-ui/core';
import Icons from 'src/components/Icons';

export type DateLabelProps = {
Expand Down Expand Up @@ -88,7 +88,7 @@ export const DateLabel = forwardRef(
return (
<LabelContainer {...props} tabIndex={0}>
<span className="date-label-content" ref={ref}>
{props.label}
{typeof props.label === 'string' ? t(props.label) : props.label}
</span>
<Icons.CalendarOutlined
iconSize="s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export const FRAME_OPTIONS: SelectOptionType[] = [
];

export const COMMON_RANGE_OPTIONS: SelectOptionType[] = [
{ value: 'Last day', label: t('last day') },
{ value: 'Last week', label: t('last week') },
{ value: 'Last month', label: t('last month') },
{ value: 'Last quarter', label: t('last quarter') },
{ value: 'Last year', label: t('last year') },
{ value: 'Last day', label: t('Last day') },
{ value: 'Last week', label: t('Last week') },
{ value: 'Last month', label: t('Last month') },
{ value: 'Last quarter', label: t('Last quarter') },
{ value: 'Last year', label: t('Last year') },
];
export const COMMON_RANGE_VALUES_SET = new Set(
COMMON_RANGE_OPTIONS.map(({ value }) => value),
Expand Down
6 changes: 4 additions & 2 deletions superset/commands/chart/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def validate(self) -> None:
if reports := ReportScheduleDAO.find_by_chart_ids(self._model_ids):
report_names = [report.name for report in reports]
raise ChartDeleteFailedReportsExistError(
_("There are associated alerts or reports: %(report_names)s")
% {"report_names": ",".join(report_names)}
_(
"There are associated alerts or reports: %(report_names)s",
report_names=",".join(report_names),
)
)
# Check ownership
for model in self._models:
Expand Down
6 changes: 4 additions & 2 deletions superset/commands/dashboard/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def validate(self) -> None:
if reports := ReportScheduleDAO.find_by_dashboard_ids(self._model_ids):
report_names = [report.name for report in reports]
raise DashboardDeleteFailedReportsExistError(
_("There are associated alerts or reports: %(report_names)s")
% {"report_names": ",".join(report_names)}
_(
"There are associated alerts or reports: %(report_names)s",
report_names=",".join(report_names),
)
)
# Check ownership
for model in self._models:
Expand Down
6 changes: 4 additions & 2 deletions superset/commands/database/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def validate(self) -> None:
if reports := ReportScheduleDAO.find_by_database_id(self._model_id):
report_names = [report.name for report in reports]
raise DatabaseDeleteFailedReportsExistError(
_("There are associated alerts or reports: %(report_names)s")
% {"report_names": ",".join(report_names)}
_(
"There are associated alerts or reports: %(report_names)s",
report_names=",".join(report_names),
)
)
# Check if there are datasets for this database
if self._model.tables:
Expand Down
13 changes: 8 additions & 5 deletions superset/commands/database/validate_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ def validate(self) -> None:
if not validators_by_engine or spec.engine not in validators_by_engine:
raise NoValidatorConfigFoundError(
SupersetError(
message=__("no SQL validator is configured for %(engine)s")
% {"engine": spec.engine},
message=__(
"no SQL validator is configured for %(engine_spec)s",
engine_spec=spec.engine,
),
error_type=SupersetErrorType.GENERIC_DB_ENGINE_ERROR,
level=ErrorLevel.ERROR,
),
Expand All @@ -110,9 +112,10 @@ def validate(self) -> None:
SupersetError(
message=__(
"No validator named %(validator_name)s found "
"(configured for the %(engine)s engine)"
)
% {"validator_name": validator_name, "engine": spec.engine},
"(configured for the %(engine_spec)s engine)",
validator_name=validator_name,
engine_spec=spec.engine,
),
error_type=SupersetErrorType.GENERIC_DB_ENGINE_ERROR,
level=ErrorLevel.ERROR,
),
Expand Down
8 changes: 4 additions & 4 deletions superset/commands/report/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,19 @@ def _validate_result(rows: np.recarray[Any, Any]) -> None:
if len(rows) > 1:
raise AlertQueryMultipleRowsError(
message=_(
"Alert query returned more than one row. %(num_rows)s rows returned"
"Alert query returned more than one row. %(num_rows)s rows returned",
num_rows=len(rows),
)
% {"num_rows": len(rows)}
)
# check if query returned more than one column
if len(rows[0]) > 2:
raise AlertQueryMultipleColumnsError(
# len is subtracted by 1 to discard pandas index column
_(
"Alert query returned more than one column. "
"%(num_columns)s columns returned"
"%(num_cols)s columns returned",
num_cols=(len(rows[0]) - 1),
)
% {"num_columns": len(rows[0]) - 1}
)

def _validate_operator(self, rows: np.recarray[Any, Any]) -> None:
Expand Down
Loading

0 comments on commit cc2f6f1

Please sign in to comment.