Skip to content

Commit

Permalink
chore: Localization of superset pt. 3 (apache#22938)
Browse files Browse the repository at this point in the history
Co-authored-by: Evan Rusackas <evan@preset.io>
  • Loading branch information
2 people authored and PawankumarES committed Feb 13, 2023
1 parent 1aa135f commit 608c221
Show file tree
Hide file tree
Showing 26 changed files with 100 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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}`,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}`,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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}`,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ControlPanelConfig,
ControlPanelsContainerProps,
D3_FORMAT_DOCS,
D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
sections,
Expand Down Expand Up @@ -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', ';'],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
import {
ControlPanelConfig,
D3_FORMAT_DOCS,
D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
sections,
Expand Down Expand Up @@ -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}`,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ControlPanelConfig,
ControlPanelsContainerProps,
D3_FORMAT_DOCS,
D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
getStandardizedControls,
Expand Down Expand Up @@ -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}`,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}`,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}`,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}`,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}`,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}`,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import { sections } from '@superset-ui/chart-controls';
import { t } from '@superset-ui/core';
import {
OrientationType,
EchartsTimeseriesSeriesType,
Expand Down Expand Up @@ -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',
);
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}`,
},
},
],
Expand Down
15 changes: 14 additions & 1 deletion superset-frontend/src/SqlLab/components/QueryTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
))}
Expand Down
Loading

0 comments on commit 608c221

Please sign in to comment.