fix: Translations related to the date range filter (#26074)

This commit is contained in:
Bill Belanger 2024-02-21 18:29:03 -05:00 committed by GitHub
parent 2e4f6d3f38
commit cc2f6f1ed9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
41 changed files with 367755 additions and 367519 deletions

View File

@ -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();
});
});

View File

@ -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 = {
@ -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"

View File

@ -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),

View File

@ -60,8 +60,10 @@ class DeleteChartCommand(BaseCommand):
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:

View File

@ -60,8 +60,10 @@ class DeleteDashboardCommand(BaseCommand):
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:

View File

@ -59,8 +59,10 @@ class DeleteDatabaseCommand(BaseCommand):
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:

View File

@ -97,8 +97,10 @@ class ValidateSQLCommand(BaseCommand):
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,
),
@ -110,9 +112,10 @@ class ValidateSQLCommand(BaseCommand):
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,
),

View File

@ -96,9 +96,9 @@ class AlertCommand(BaseCommand):
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:
@ -106,9 +106,9 @@ class AlertCommand(BaseCommand):
# 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:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -105,9 +105,7 @@ class Api(BaseSupersetView):
}
return self.json_response({"result": result})
except (ValueError, TimeRangeParseFailError, TimeRangeAmbiguousError) as error:
error_msg = {
"message": _("Unexpected time range: %(error)s") % {"error": error}
}
error_msg = {"message": _("Unexpected time range: %(error)s", error=error)}
return self.json_response(error_msg, 400)
def get_query_context_factory(self) -> QueryContextFactory:

View File

@ -1899,8 +1899,7 @@ class BaseDeckGLViz(BaseViz):
return (point.latitude, point.longitude)
except Exception as ex:
raise SpatialException(
_("Invalid spatial point encountered: %(latlong)s")
% {"latlong": latlong}
_("Invalid spatial point encountered: %(latlong)s", latlong=latlong)
) from ex
@staticmethod