chore: Localization of superset pt. 3 (#22938)

Co-authored-by: Evan Rusackas <evan@preset.io>
This commit is contained in:
Artem Shumeiko 2023-02-07 19:21:23 +03:00 committed by GitHub
parent a1b7eb3870
commit 773d2a54a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 100 additions and 67 deletions

View File

@ -23,6 +23,13 @@ export const D3_FORMAT_DOCS = t(
'D3 format syntax: https://github.com/d3/d3-format',
);
export const D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT = t(
'Only applies when "Label Type" is set to show values.',
);
export const D3_NUMBER_FORMAT_DESCRIPTION_PERCENTAGE_TEXT = t(
'Only applies when "Label Type" is not set to a percentage.',
);
// input choices & options
export const D3_FORMAT_OPTIONS: [string, string][] = [
[NumberFormats.SMART_NUMBER, t('Adaptive formatting')],

View File

@ -19,7 +19,9 @@
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS,
D3_NUMBER_FORMAT_DESCRIPTION_PERCENTAGE_TEXT,
} from '@superset-ui/chart-controls';
import { showLegend } from '../NVD3Controls';
@ -67,11 +69,7 @@ const config: ControlPanelConfig = {
renderTrigger: true,
default: 'SMART_NUMBER',
choices: D3_FORMAT_OPTIONS,
description: `${t(
'D3 format syntax: https://github.com/d3/d3-format',
)} ${t(
'Only applies when the "Label Type" is not set to a percentage.',
)}`,
description: `${D3_FORMAT_DOCS} ${D3_NUMBER_FORMAT_DESCRIPTION_PERCENTAGE_TEXT}`,
},
},
],

View File

@ -25,6 +25,7 @@ import {
} from '@superset-ui/core';
import {
D3_FORMAT_DOCS,
D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
sections,
@ -137,9 +138,7 @@ const config: ControlPanelConfig = {
renderTrigger: true,
default: 'SMART_NUMBER',
choices: D3_FORMAT_OPTIONS,
description: `${t(
'D3 format syntax: https://github.com/d3/d3-format',
)} ${t('Only applies when "Label Type" is set to show values.')}`,
description: `${D3_FORMAT_DOCS} ${D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT}`,
},
},
],

View File

@ -21,10 +21,12 @@ import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
D3_FORMAT_OPTIONS,
D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT,
sections,
sharedControls,
ControlStateMapping,
getStandardizedControls,
D3_FORMAT_DOCS,
} from '@superset-ui/chart-controls';
import { DEFAULT_FORM_DATA, EchartsFunnelLabelTypeType } from './types';
import { legendSection } from '../controls';
@ -112,9 +114,7 @@ const config: ControlPanelConfig = {
renderTrigger: true,
default: numberFormat,
choices: D3_FORMAT_OPTIONS,
description: `${t(
'D3 format syntax: https://github.com/d3/d3-format',
)} ${t('Only applies when "Label Type" is set to show values.')}`,
description: `${D3_FORMAT_DOCS} ${D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT}`,
},
},
],

View File

@ -22,6 +22,7 @@ import {
ControlPanelConfig,
ControlPanelsContainerProps,
D3_FORMAT_DOCS,
D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
sections,
@ -120,9 +121,7 @@ const config: ControlPanelConfig = {
renderTrigger: true,
default: numberFormat,
choices: D3_FORMAT_OPTIONS,
description: `${t(
'D3 format syntax: https://github.com/d3/d3-format',
)} ${t('Only applies when "Label Type" is set to show values.')}`,
description: `${D3_FORMAT_DOCS} ${D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT}`,
tokenSeparators: ['\n', '\t', ';'],
},
},

View File

@ -27,6 +27,7 @@ import {
import {
ControlPanelConfig,
D3_FORMAT_DOCS,
D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
sections,
@ -137,9 +138,7 @@ const config: ControlPanelConfig = {
renderTrigger: true,
default: numberFormat,
choices: D3_FORMAT_OPTIONS,
description: `${t(
'D3 format syntax: https://github.com/d3/d3-format. ',
)} ${t('Only applies when "Label Type" is set to show values.')}`,
description: `${D3_FORMAT_DOCS} ${D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT}`,
},
},
],

View File

@ -22,6 +22,7 @@ import {
ControlPanelConfig,
ControlPanelsContainerProps,
D3_FORMAT_DOCS,
D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
getStandardizedControls,
@ -130,9 +131,7 @@ const config: ControlPanelConfig = {
renderTrigger: true,
default: numberFormat,
choices: D3_FORMAT_OPTIONS,
description: `${t(
'D3 format syntax: https://github.com/d3/d3-format',
)} ${t('Only applies when "Label Type" is set to show values.')}`,
description: `${D3_FORMAT_DOCS} ${D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT}`,
},
},
],

View File

@ -28,7 +28,7 @@ import {
} from '@superset-ui/chart-controls';
import { EchartsTimeseriesSeriesType } from '../types';
import { DEFAULT_FORM_DATA } from '../constants';
import { DEFAULT_FORM_DATA, TIME_SERIES_DESCRIPTION_TEXT } from '../constants';
import {
legendSection,
onlyTotalControl,
@ -182,9 +182,7 @@ const config: ControlPanelConfig = {
config: {
...sharedControls.x_axis_time_format,
default: 'smart_date',
description: `${D3_TIME_FORMAT_DOCS}. ${t(
'When using other than adaptive formatting, labels may overlap.',
)}`,
description: `${D3_TIME_FORMAT_DOCS}. ${TIME_SERIES_DESCRIPTION_TEXT}`,
},
},
],

View File

@ -31,7 +31,10 @@ import {
} from '@superset-ui/chart-controls';
import { OrientationType } from '../../types';
import { DEFAULT_FORM_DATA } from '../../constants';
import {
DEFAULT_FORM_DATA,
TIME_SERIES_DESCRIPTION_TEXT,
} from '../../constants';
import {
legendSection,
richTooltipSection,
@ -150,9 +153,7 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
config: {
...sharedControls.x_axis_time_format,
default: 'smart_date',
description: `${D3_TIME_FORMAT_DOCS}. ${t(
'When using other than adaptive formatting, labels may overlap.',
)}`,
description: `${D3_TIME_FORMAT_DOCS}. ${TIME_SERIES_DESCRIPTION_TEXT}`,
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isVertical(controls) : isHorizontal(controls),
},

View File

@ -28,7 +28,10 @@ import {
} from '@superset-ui/chart-controls';
import { EchartsTimeseriesSeriesType } from '../../types';
import { DEFAULT_FORM_DATA } from '../../constants';
import {
DEFAULT_FORM_DATA,
TIME_SERIES_DESCRIPTION_TEXT,
} from '../../constants';
import {
legendSection,
richTooltipSection,
@ -169,9 +172,7 @@ const config: ControlPanelConfig = {
config: {
...sharedControls.x_axis_time_format,
default: 'smart_date',
description: `${D3_TIME_FORMAT_DOCS}. ${t(
'When using other than adaptive formatting, labels may overlap.',
)}`,
description: `${D3_TIME_FORMAT_DOCS}. ${TIME_SERIES_DESCRIPTION_TEXT}`,
},
},
],

View File

@ -27,7 +27,10 @@ import {
sharedControls,
} from '@superset-ui/chart-controls';
import { DEFAULT_FORM_DATA } from '../../constants';
import {
DEFAULT_FORM_DATA,
TIME_SERIES_DESCRIPTION_TEXT,
} from '../../constants';
import {
legendSection,
richTooltipSection,
@ -112,9 +115,7 @@ const config: ControlPanelConfig = {
config: {
...sharedControls.x_axis_time_format,
default: 'smart_date',
description: `${D3_TIME_FORMAT_DOCS}. ${t(
'When using other than adaptive formatting, labels may overlap.',
)}`,
description: `${D3_TIME_FORMAT_DOCS}. ${TIME_SERIES_DESCRIPTION_TEXT}`,
},
},
],

View File

@ -27,7 +27,10 @@ import {
sharedControls,
} from '@superset-ui/chart-controls';
import { DEFAULT_FORM_DATA } from '../../constants';
import {
DEFAULT_FORM_DATA,
TIME_SERIES_DESCRIPTION_TEXT,
} from '../../constants';
import {
legendSection,
richTooltipSection,
@ -111,9 +114,7 @@ const config: ControlPanelConfig = {
config: {
...sharedControls.x_axis_time_format,
default: 'smart_date',
description: `${D3_TIME_FORMAT_DOCS}. ${t(
'When using other than adaptive formatting, labels may overlap.',
)}`,
description: `${D3_TIME_FORMAT_DOCS}. ${TIME_SERIES_DESCRIPTION_TEXT}`,
},
},
],

View File

@ -28,7 +28,7 @@ import {
} from '@superset-ui/chart-controls';
import { EchartsTimeseriesSeriesType } from '../../types';
import { DEFAULT_FORM_DATA } from '../constants';
import { DEFAULT_FORM_DATA, TIME_SERIES_DESCRIPTION_TEXT } from '../constants';
import {
legendSection,
richTooltipSection,
@ -166,9 +166,7 @@ const config: ControlPanelConfig = {
config: {
...sharedControls.x_axis_time_format,
default: 'smart_date',
description: `${D3_TIME_FORMAT_DOCS}. ${t(
'When using other than adaptive formatting, labels may overlap.',
)}`,
description: `${D3_TIME_FORMAT_DOCS}. ${TIME_SERIES_DESCRIPTION_TEXT}`,
},
},
],

View File

@ -17,6 +17,7 @@
* under the License.
*/
import { sections } from '@superset-ui/chart-controls';
import { t } from '@superset-ui/core';
import {
OrientationType,
EchartsTimeseriesSeriesType,
@ -63,3 +64,7 @@ export const DEFAULT_FORM_DATA: EchartsTimeseriesFormData = {
percentageThreshold: 0,
orientation: OrientationType.vertical,
};
export const TIME_SERIES_DESCRIPTION_TEXT: string = t(
'When using other than adaptive formatting, labels may overlap',
);

View File

@ -21,6 +21,7 @@ import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
D3_FORMAT_DOCS,
D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
sections,
@ -113,9 +114,7 @@ const config: ControlPanelConfig = {
renderTrigger: true,
default: numberFormat,
choices: D3_FORMAT_OPTIONS,
description: `${t(
'D3 format syntax: https://github.com/d3/d3-format. ',
)} ${t('Only applies when "Label Type" is set to show values.')}`,
description: `${D3_FORMAT_DOCS} ${D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT}`,
},
},
],

View File

@ -76,17 +76,30 @@ const QueryTable = ({
const theme = useTheme();
const dispatch = useDispatch();
const QUERY_HISTORY_TABLE_HEADERS_LOCALIZED = {
state: t('State'),
started: t('Started'),
duration: t('Duration'),
progress: t('Progress'),
rows: t('Rows'),
sql: t('SQL'),
results: t('Results'),
actions: t('Actions'),
};
const setHeaders = (column: string) => {
if (column === 'sql') {
return column.toUpperCase();
}
return column.charAt(0).toUpperCase().concat(column.slice(1));
};
const columnsOfTable = useMemo(
() =>
columns.map(column => ({
accessor: column,
Header: () => setHeaders(column),
Header:
QUERY_HISTORY_TABLE_HEADERS_LOCALIZED[column] || setHeaders(column),
disableSortBy: true,
})),
[columns],

View File

@ -182,10 +182,11 @@ const TableElement = ({ table, ...props }: TableElementProps) => {
const renderControls = () => {
let keyLink;
const KEYS_FOR_TABLE_TEXT = t('Keys for table');
if (table?.indexes?.length) {
keyLink = (
<ModalTrigger
modalTitle={`${t('Keys for table')} ${table.name}`}
modalTitle={`${KEYS_FOR_TABLE_TEXT} ${table.name}`}
modalBody={table.indexes.map((ix, i) => (
<pre key={i}>{JSON.stringify(ix, null, ' ')}</pre>
))}

View File

@ -37,6 +37,7 @@ import DrillDetailModal from './DrillDetailModal';
import { getMenuAdjustedY, MENU_ITEM_HEIGHT } from '../utils';
const MENU_PADDING = 4;
const DRILL_TO_DETAIL_TEXT = t('Drill to detail by');
const DisabledMenuItemTooltip = ({ title }: { title: ReactNode }) => (
<Tooltip title={title} placement="top">
@ -163,7 +164,7 @@ const DrillDetailMenuItems = ({
if (!handlesDimensionContextMenu) {
drillToDetailByMenuItem = (
<DisabledMenuItem {...props} key="drill-detail-by-chart-not-supported">
{t('Drill to detail by')}
{DRILL_TO_DETAIL_TEXT}
<DisabledMenuItemTooltip
title={t(
'Drill to detail by value is not yet supported for this chart type.',
@ -176,7 +177,7 @@ const DrillDetailMenuItems = ({
if (handlesDimensionContextMenu && noAggregations) {
drillToDetailByMenuItem = (
<DisabledMenuItem {...props} key="drill-detail-by-no-aggregations">
{t('Drill to detail by')}
{DRILL_TO_DETAIL_TEXT}
</DisabledMenuItem>
);
}
@ -195,7 +196,7 @@ const DrillDetailMenuItems = ({
<Menu.SubMenu
{...props}
popupOffset={[0, submenuYOffset]}
title={t('Drill to detail by')}
title={DRILL_TO_DETAIL_TEXT}
>
<div data-test="drill-to-detail-by-submenu">
{filters.map((filter, i) => (
@ -204,7 +205,7 @@ const DrillDetailMenuItems = ({
key={`drill-detail-filter-${i}`}
onClick={openModal.bind(null, [filter])}
>
{`${t('Drill to detail by')} `}
{`${DRILL_TO_DETAIL_TEXT} `}
<Filter>{filter.formattedVal}</Filter>
</Menu.Item>
))}
@ -214,7 +215,7 @@ const DrillDetailMenuItems = ({
key="drill-detail-filter-all"
onClick={openModal.bind(null, filters)}
>
{`${t('Drill to detail by')} `}
{`${DRILL_TO_DETAIL_TEXT} `}
<Filter>{t('all')}</Filter>
</Menu.Item>
)}
@ -226,7 +227,7 @@ const DrillDetailMenuItems = ({
if (handlesDimensionContextMenu && !noAggregations && !filters?.length) {
drillToDetailByMenuItem = (
<DisabledMenuItem {...props} key="drill-detail-by-select-aggregation">
{t('Drill to detail by')}
{DRILL_TO_DETAIL_TEXT}
<DisabledMenuItemTooltip
title={t(
'Right-click on a dimension value to drill to detail by that value.',

View File

@ -372,6 +372,7 @@ const Select = forwardRef(
const selectAllLabel = useMemo(
() => () =>
// TODO: localize
`${SELECT_ALL_VALUE} (${formatNumber(
NumberFormats.INTEGER,
fullSelectOptions.length,

View File

@ -73,6 +73,7 @@ const propTypes = {
const defaultProps = {};
// TODO: localize
const MARKDOWN_PLACE_HOLDER = `# ✨Header 1
## Header 2
### Header 3

View File

@ -33,7 +33,7 @@ export const getSliceHeaderTooltip = (sliceName: string | undefined) => {
: t('Click to edit chart.');
const secondLine = t(
'Use %s to open in a new tab.',
isMac ? '⌘ + click' : 'ctrl + click',
isMac ? t('⌘ + click') : t('ctrl + click'),
);
return (
<>

View File

@ -105,7 +105,7 @@ const ControlHeader: FC<ControlHeaderProps> = ({
{description && (
<span>
<Tooltip
id={`${t('description')}-tooltip`}
id="description-tooltip"
title={description}
placement="top"
>

View File

@ -335,19 +335,20 @@ export class ChartCreation extends React.PureComponent<
render() {
const isButtonDisabled = this.isBtnDisabled();
const VIEW_INSTRUCTIONS_TEXT = t('view instructions');
const datasetHelpText = this.state.canCreateDataset ? (
<span data-test="dataset-write">
<Link to="/dataset/add/" data-test="add-chart-new-dataset">
{t('Add a dataset')}
{t('Add a dataset')}{' '}
</Link>
{` ${t('or')} `}
{t('or')}{' '}
<a
href="https://superset.apache.org/docs/creating-charts-dashboards/creating-your-first-dashboard/#registering-a-new-table"
rel="noopener noreferrer"
target="_blank"
data-test="add-chart-new-dataset-instructions"
>
{`${t('view instructions')} `}
{`${VIEW_INSTRUCTIONS_TEXT} `}
<i className="fa fa-external-link" />
</a>
.
@ -359,7 +360,7 @@ export class ChartCreation extends React.PureComponent<
rel="noopener noreferrer"
target="_blank"
>
{`${t('View instructions')} `}
{`${VIEW_INSTRUCTIONS_TEXT} `}
<i className="fa fa-external-link" />
</a>
.

View File

@ -218,7 +218,7 @@ const ExtraOptions = ({
<div>
<h4>{t('Performance')}</h4>
<p className="helper">
Adjust performance settings of this database.
{t('Adjust performance settings of this database.')}
</p>
</div>
}

View File

@ -332,7 +332,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
row: {
original: { kind },
},
}: any) => kind[0]?.toUpperCase() + kind.slice(1),
}: any) => (kind === 'physical' ? t('Physical') : t('Virtual')),
Header: t('Type'),
accessor: 'kind',
disableSortBy: true,

View File

@ -37,6 +37,18 @@ const welcomeTableEmpty: Record<WelcomeTable, string> = {
[WelcomeTable.SavedQueries]: t('No saved queries yet'),
};
const welcomeTableWillAppear: Record<WelcomeTable, (other: string) => string> =
{
[WelcomeTable.Charts]: (other: string) =>
t('%(other)s charts will appear here', { other }),
[WelcomeTable.Dashboards]: (other: string) =>
t('%(other)s dashboards will appear here', { other }),
[WelcomeTable.Recents]: (other: string) =>
t('%(other)s recents will appear here', { other }),
[WelcomeTable.SavedQueries]: (other: string) =>
t('%(other)s saved queries will appear here', { other }),
};
export interface EmptyStateProps {
tableName: WelcomeTable;
tab?: string;
@ -97,10 +109,8 @@ export default function EmptyState({
);
}
if (tab === TableTab.Other) {
return t('%(other)s %(tableName)s will appear here', {
other: otherTabTitle || t('Other'),
tableName: tableName.toLowerCase(),
});
const other = otherTabTitle || t('Other');
return welcomeTableWillAppear[tableName](other);
}
if (tab === TableTab.Edited) {
return t(