diff --git a/superset-frontend/src/SqlLab/components/App/index.jsx b/superset-frontend/src/SqlLab/components/App/index.jsx index 406ad740bd5c..bce43f477800 100644 --- a/superset-frontend/src/SqlLab/components/App/index.jsx +++ b/superset-frontend/src/SqlLab/components/App/index.jsx @@ -83,12 +83,14 @@ class App extends React.PureComponent { this.props.actions.addDangerToast( t( "SQL Lab uses your browser's local storage to store queries and results." + - `\n Currently, you are using ${currentUsage.toFixed( - 2, - )} KB out of ${LOCALSTORAGE_MAX_USAGE_KB} KB. storage space.` + - '\n To keep SQL Lab from crashing, please delete some query tabs.' + - '\n You can re-access these queries by using the Save feature before you delete the tab. ' + - 'Note that you will need to close other SQL Lab windows before you do this.', + '\nCurrently, you are using %(currentUsage)s KB out of %(maxStorage)d KB storage space.' + + '\nTo keep SQL Lab from crashing, please delete some query tabs.' + + '\nYou can re-access these queries by using the Save feature before you delete the tab.' + + '\nNote that you will need to close other SQL Lab windows before you do this.', + { + currentUsage: currentUsage.toFixed(2), + maxStorage: LOCALSTORAGE_MAX_USAGE_KB, + }, ), ); } diff --git a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx index 987d87ea3007..2d15efc09be2 100644 --- a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx +++ b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx @@ -581,22 +581,22 @@ export default class ResultSet extends React.PureComponent< const isAdmin = !!this.props.user?.roles?.Admin; const displayMaxRowsReachedMessage = { withAdmin: t( - `The number of results displayed is limited to %(rows)d by the configuration DISPLAY_MAX_ROWS. `, + 'The number of results displayed is limited to %(rows)d by the configuration DISPLAY_MAX_ROWS. ', { rows }, ).concat( t( - `Please add additional limits/filters or download to csv to see more rows up to `, + 'Please add additional limits/filters or download to csv to see more rows up to ', ), - t(`the %(limit)d limit.`, { limit }), + t('the %(limit)d limit.', { limit }), ), withoutAdmin: t( - `The number of results displayed is limited to %(rows)d. `, + 'The number of results displayed is limited to %(rows)d. ', { rows }, ).concat( t( - `Please add additional limits/filters, download to csv, or contact an admin `, + 'Please add additional limits/filters, download to csv, or contact an admin ', ), - t(`to see more rows up to the %(limit)d limit.`, { + t('to see more rows up to the %(limit)d limit.', { limit, }), ), @@ -609,7 +609,7 @@ export default class ResultSet extends React.PureComponent< limitMessage = ( {t( - `The number of rows displayed is limited to %(rows)d by the query`, + 'The number of rows displayed is limited to %(rows)d by the query', { rows }, )} @@ -621,7 +621,7 @@ export default class ResultSet extends React.PureComponent< limitMessage = ( {t( - `The number of rows displayed is limited to %(rows)d by the limit dropdown.`, + 'The number of rows displayed is limited to %(rows)d by the limit dropdown.', { rows }, )} @@ -630,7 +630,7 @@ export default class ResultSet extends React.PureComponent< limitMessage = ( {t( - `The number of rows displayed is limited to %(rows)d by the query and limit dropdown.`, + 'The number of rows displayed is limited to %(rows)d by the query and limit dropdown.', { rows }, )} @@ -640,17 +640,17 @@ export default class ResultSet extends React.PureComponent< {!limitReached && !shouldUseDefaultDropdownAlert && ( - {t(`%(rows)d rows returned`, { rows })} {limitMessage} + {t('%(rows)d rows returned', { rows })} {limitMessage} )} {!limitReached && shouldUseDefaultDropdownAlert && (
@@ -661,7 +661,7 @@ export default class ResultSet extends React.PureComponent< { - const nowPublished = isPublished ? 'published' : 'hidden'; - dispatch(addSuccessToast(t(`This dashboard is now ${nowPublished}`))); + dispatch( + addSuccessToast( + isPublished + ? t('This dashboard is now published') + : t('This dashboard is now hidden'), + ), + ); dispatch(togglePublished(isPublished)); }) .catch(() => { diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx index 703f47ec7aff..9a8a9fde605b 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx @@ -320,7 +320,9 @@ const FilterBar: React.FC = ({ activeKey={editFilterSetId ? TabIds.AllFilters : undefined} > @@ -340,7 +342,9 @@ const FilterBar: React.FC = ({ diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx index 65ac4fbca259..ce8978abaa1c 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx @@ -106,7 +106,7 @@ export default function getControlItemsMap({ initialValue={initColumn} label={ - {t(`${mainControlItem.config?.label}`) || t('Column')} + {mainControlItem.config?.label || t('Column')} } rules={[ diff --git a/superset-frontend/src/views/CRUD/alert/AlertList.tsx b/superset-frontend/src/views/CRUD/alert/AlertList.tsx index c9d8d6346193..706878765065 100644 --- a/superset-frontend/src/views/CRUD/alert/AlertList.tsx +++ b/superset-frontend/src/views/CRUD/alert/AlertList.tsx @@ -50,6 +50,14 @@ import { AlertObject, AlertState } from './types'; const PAGE_SIZE = 25; +const AlertStateLabel: Record = { + [AlertState.Success]: t('Success'), + [AlertState.Working]: t('Working'), + [AlertState.Error]: t('Error'), + [AlertState.Noop]: t('Not triggered'), + [AlertState.Grace]: t('On Grace'), +}; + interface AlertListProps { addDangerToast: (msg: string) => void; addSuccessToast: (msg: string) => void; @@ -394,11 +402,17 @@ function AlertList({ operator: FilterOperator.equals, unfilteredLabel: 'Any', selects: [ - { label: t(`${AlertState.success}`), value: AlertState.success }, - { label: t(`${AlertState.working}`), value: AlertState.working }, - { label: t(`${AlertState.error}`), value: AlertState.error }, - { label: t(`${AlertState.noop}`), value: AlertState.noop }, - { label: t(`${AlertState.grace}`), value: AlertState.grace }, + { + label: AlertStateLabel[AlertState.Success], + value: AlertState.Success, + }, + { + label: AlertStateLabel[AlertState.Working], + value: AlertState.Working, + }, + { label: AlertStateLabel[AlertState.Error], value: AlertState.Error }, + { label: AlertStateLabel[AlertState.Noop], value: AlertState.Noop }, + { label: AlertStateLabel[AlertState.Grace], value: AlertState.Grace }, ], }, { diff --git a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx index 775423ad76d5..201780289605 100644 --- a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx +++ b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx @@ -1047,9 +1047,13 @@ const AlertReportModal: FunctionComponent = ({ ) : ( )} - {isEditMode - ? t(`Edit ${isReport ? 'Report' : 'Alert'}`) - : t(`Add ${isReport ? 'Report' : 'Alert'}`)} + {isEditMode && isReport + ? t('Edit Report') + : isEditMode + ? t('Edit Alert') + : isReport + ? 'Add Report' + : 'Add Alert'} } > diff --git a/superset-frontend/src/views/CRUD/alert/ExecutionLog.tsx b/superset-frontend/src/views/CRUD/alert/ExecutionLog.tsx index e9c7baff21d5..64e665aeb4c1 100644 --- a/superset-frontend/src/views/CRUD/alert/ExecutionLog.tsx +++ b/superset-frontend/src/views/CRUD/alert/ExecutionLog.tsx @@ -153,7 +153,7 @@ function ExecutionLog({ addDangerToast, isReportEnabled }: ExecutionLogProps) { name={ - {t(`${alertResource?.type}`)} {alertResource?.name} + {alertResource?.type} {alertResource?.name} Back to all diff --git a/superset-frontend/src/views/CRUD/alert/components/AlertStatusIcon.tsx b/superset-frontend/src/views/CRUD/alert/components/AlertStatusIcon.tsx index 586afc68e91e..048a12f35e5e 100644 --- a/superset-frontend/src/views/CRUD/alert/components/AlertStatusIcon.tsx +++ b/superset-frontend/src/views/CRUD/alert/components/AlertStatusIcon.tsx @@ -28,17 +28,17 @@ function getStatusColor( theme: typeof supersetTheme, ) { switch (status) { - case AlertState.working: + case AlertState.Working: return theme.colors.primary.base; - case AlertState.error: + case AlertState.Error: return theme.colors.error.base; - case AlertState.success: + case AlertState.Success: return isReportEnabled ? theme.colors.success.base : theme.colors.alert.base; - case AlertState.noop: + case AlertState.Noop: return theme.colors.success.base; - case AlertState.grace: + case AlertState.Grace: return theme.colors.alert.base; default: return theme.colors.grayscale.base; @@ -59,43 +59,43 @@ export default function AlertStatusIcon({ status: '', }; switch (state) { - case AlertState.success: + case AlertState.Success: lastStateConfig.icon = isReportEnabled ? Icons.Check : Icons.AlertSolidSmall; lastStateConfig.label = isReportEnabled ? t('Report sent') : t('Alert triggered, notification sent'); - lastStateConfig.status = AlertState.success; + lastStateConfig.status = AlertState.Success; break; - case AlertState.working: + case AlertState.Working: lastStateConfig.icon = Icons.Running; lastStateConfig.label = isReportEnabled ? t('Report sending') : t('Alert running'); - lastStateConfig.status = AlertState.working; + lastStateConfig.status = AlertState.Working; break; - case AlertState.error: + case AlertState.Error: lastStateConfig.icon = Icons.XSmall; lastStateConfig.label = isReportEnabled ? t('Report failed') : t('Alert failed'); - lastStateConfig.status = AlertState.error; + lastStateConfig.status = AlertState.Error; break; - case AlertState.noop: + case AlertState.Noop: lastStateConfig.icon = Icons.Check; lastStateConfig.label = t('Nothing triggered'); - lastStateConfig.status = AlertState.noop; + lastStateConfig.status = AlertState.Noop; break; - case AlertState.grace: + case AlertState.Grace: lastStateConfig.icon = Icons.AlertSolidSmall; lastStateConfig.label = t('Alert Triggered, In Grace Period'); - lastStateConfig.status = AlertState.grace; + lastStateConfig.status = AlertState.Grace; break; default: lastStateConfig.icon = Icons.Check; lastStateConfig.label = t('Nothing triggered'); - lastStateConfig.status = AlertState.noop; + lastStateConfig.status = AlertState.Noop; } const Icon = lastStateConfig.icon; return ( diff --git a/superset-frontend/src/views/CRUD/alert/components/RecipientIcon.tsx b/superset-frontend/src/views/CRUD/alert/components/RecipientIcon.tsx index b2e8652c537e..96ca65ccb10c 100644 --- a/superset-frontend/src/views/CRUD/alert/components/RecipientIcon.tsx +++ b/superset-frontend/src/views/CRUD/alert/components/RecipientIcon.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { t, SupersetTheme, css } from '@superset-ui/core'; +import { SupersetTheme, css } from '@superset-ui/core'; import React, { ReactElement } from 'react'; import { Tooltip } from 'src/components/Tooltip'; import Icons from 'src/components/Icons'; @@ -33,13 +33,13 @@ export default function RecipientIcon({ type }: { type: string }) { label: '', }; switch (type) { - case RecipientIconName.email: + case RecipientIconName.Email: recipientIconConfig.icon = ; - recipientIconConfig.label = t(`${RecipientIconName.email}`); + recipientIconConfig.label = RecipientIconName.Email; break; - case RecipientIconName.slack: + case RecipientIconName.Slack: recipientIconConfig.icon = ; - recipientIconConfig.label = t(`${RecipientIconName.slack}`); + recipientIconConfig.label = RecipientIconName.Slack; break; default: recipientIconConfig.icon = null; diff --git a/superset-frontend/src/views/CRUD/alert/types.ts b/superset-frontend/src/views/CRUD/alert/types.ts index 3f939a03bcfa..1c40cdb1f9ef 100644 --- a/superset-frontend/src/views/CRUD/alert/types.ts +++ b/superset-frontend/src/views/CRUD/alert/types.ts @@ -100,14 +100,14 @@ export type LogObject = { }; export enum AlertState { - success = 'Success', - working = 'Working', - error = 'Error', - noop = 'Not triggered', - grace = 'On Grace', + Success = 'Success', + Working = 'Working', + Error = 'Error', + Noop = 'Not triggered', + Grace = 'On Grace', } export enum RecipientIconName { - email = 'Email', - slack = 'Slack', + Email = 'Email', + Slack = 'Slack', } diff --git a/superset-frontend/src/views/CRUD/hooks.ts b/superset-frontend/src/views/CRUD/hooks.ts index 057e4799aea4..f9b7a1ed98cc 100644 --- a/superset-frontend/src/views/CRUD/hooks.ts +++ b/superset-frontend/src/views/CRUD/hooks.ts @@ -623,7 +623,7 @@ export const testDatabaseConnection = ( addSuccessToast(t('Connection looks good!')); }, createErrorHandler((errMsg: Record | string) => { - handleErrorMsg(t(`${t('ERROR: ')}${parsedErrorMessage(errMsg)}`)); + handleErrorMsg(t('ERROR: %s', parsedErrorMessage(errMsg))); }), ); }; diff --git a/superset-frontend/src/views/CRUD/welcome/EmptyState.tsx b/superset-frontend/src/views/CRUD/welcome/EmptyState.tsx index b55ac8a4a1f1..c89d6bc56867 100644 --- a/superset-frontend/src/views/CRUD/welcome/EmptyState.tsx +++ b/superset-frontend/src/views/CRUD/welcome/EmptyState.tsx @@ -57,11 +57,11 @@ export default function EmptyState({ tableName, tab }: EmptyStateProps) { SAVED_QUERIES: 'empty-queries.svg', }; const mine = ( - {`No ${ - tableName === 'SAVED_QUERIES' - ? t('saved queries') - : t(`${tableName.toLowerCase()}`) - } yet`} + + {tableName === 'SAVED_QUERIES' + ? t('No saved queries yet') + : t('No %(tableName)s yet', { tableName: tableName.toLowerCase() })} + ); const recent = ( @@ -77,7 +77,9 @@ export default function EmptyState({ tableName, tab }: EmptyStateProps) { ); } if (tab === 'Examples') { - return t(`Example ${tableName.toLowerCase()} will appear here`); + return t('Example %(tableName)s will appear here', { + tableName: tableName.toLowerCase(), + }); } if (tab === 'Edited') { return t( diff --git a/superset/databases/commands/exceptions.py b/superset/databases/commands/exceptions.py index 9cd8b3306f62..9ba58373e197 100644 --- a/superset/databases/commands/exceptions.py +++ b/superset/databases/commands/exceptions.py @@ -60,7 +60,7 @@ def __init__(self, json_error: str = "") -> None: super().__init__( [ _( - "Field cannot be decoded by JSON. %{json_error}s", + "Field cannot be decoded by JSON. %(json_error)s", json_error=json_error, ) ],