Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Added translate functions #21816

Merged
merged 2 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ export const advancedAnalyticsControls: ControlPanelSectionConfig = {
label: t('Fill method'),
default: null,
choices: [
['asfreq', 'Null imputation'],
['zerofill', 'Zero imputation'],
['linear', 'Linear interpolation'],
['ffill', 'Forward values'],
['bfill', 'Backward values'],
['median', 'Median values'],
['mean', 'Mean values'],
['sum', 'Sum values'],
['asfreq', t('Null imputation')],
['zerofill', t('Zero imputation')],
['linear', t('Linear interpolation')],
['ffill', t('Forward values')],
['bfill', t('Backward values')],
['median', t('Median values')],
['mean', t('Mean values')],
['sum', t('Sum values')],
],
description: t('Pandas resample method'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export const echartsTimeSeriesQuery: ControlPanelSectionConfig = {
label: t('Contribution Mode'),
default: null,
choices: [
[null, 'None'],
[ContributionType.Row, 'Row'],
[ContributionType.Column, 'Series'],
[null, t('None')],
[ContributionType.Row, t('Row')],
[ContributionType.Column, t('Series')],
],
description: t('Calculate contribution per series or row'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export const forecastIntervalControls: ControlPanelSectionConfig = {
config: {
type: 'SelectControl',
freeForm: true,
label: 'Yearly seasonality',
label: t('Yearly seasonality'),
choices: [
[null, 'default'],
[true, 'Yes'],
[false, 'No'],
[null, t('default')],
[true, t('Yes')],
[false, t('No')],
],
default: FORECAST_DEFAULT_DATA.forecastSeasonalityYearly,
description: t(
Expand All @@ -101,11 +101,11 @@ export const forecastIntervalControls: ControlPanelSectionConfig = {
config: {
type: 'SelectControl',
freeForm: true,
label: 'Weekly seasonality',
label: t('Weekly seasonality'),
choices: [
[null, 'default'],
[true, 'Yes'],
[false, 'No'],
[null, t('default')],
[true, t('Yes')],
[false, t('No')],
],
default: FORECAST_DEFAULT_DATA.forecastSeasonalityWeekly,
description: t(
Expand All @@ -120,11 +120,11 @@ export const forecastIntervalControls: ControlPanelSectionConfig = {
config: {
type: 'SelectControl',
freeForm: true,
label: 'Daily seasonality',
label: t('Daily seasonality'),
choices: [
[null, 'default'],
[true, 'Yes'],
[false, 'No'],
[null, t('default')],
[true, t('Yes')],
[false, t('No')],
],
default: FORECAST_DEFAULT_DATA.forecastSeasonalityDaily,
description: t(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,10 @@ const config: ControlPanelConfig = {
label: t('Calculation type'),
default: 'values',
choices: [
['values', 'Actual Values'],
['absolute', 'Difference'],
['percentage', 'Percentage change'],
['ratio', 'Ratio'],
['values', t('Actual Values')],
['absolute', t('Difference')],
['percentage', t('Percentage change')],
['ratio', t('Ratio')],
],
description: t(
'How to display time shifts: as individual lines; as the ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,10 @@ export const timeSeriesSection: ControlPanelSectionConfig[] = [
label: t('Calculation type'),
default: 'values',
choices: [
['values', 'Actual Values'],
['absolute', 'Difference'],
['percentage', 'Percentage change'],
['ratio', 'Ratio'],
['values', t('Actual Values')],
['absolute', t('Difference')],
['percentage', t('Percentage change')],
['ratio', t('Ratio')],
],
description: t(
'How to display time shifts: as individual lines; as the ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t } from '@superset-ui/core';

function extractTypes(metadata) {
return Object.keys(metadata).reduce((prev, key) => {
const result = prev;
Expand All @@ -28,21 +30,21 @@ function extractTypes(metadata) {
export const ANNOTATION_TYPES_METADATA = {
FORMULA: {
value: 'FORMULA',
label: 'Formula',
label: t('Formula'),
},
EVENT: {
value: 'EVENT',
label: 'Event',
label: t('Event'),
supportNativeSource: true,
},
INTERVAL: {
value: 'INTERVAL',
label: 'Interval',
label: t('Interval'),
supportNativeSource: true,
},
TIME_SERIES: {
value: 'TIME_SERIES',
label: 'Time Series',
label: t('Time Series'),
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ const config: ControlPanelConfig = {
label: t('Fill method'),
default: null,
choices: [
['asfreq', 'Null imputation'],
['zerofill', 'Zero imputation'],
['linear', 'Linear interpolation'],
['ffill', 'Forward values'],
['bfill', 'Backward values'],
['median', 'Median values'],
['mean', 'Mean values'],
['sum', 'Sum values'],
['asfreq', t('Null imputation')],
['zerofill', t('Zero imputation')],
['linear', t('Linear interpolation')],
['ffill', t('Forward values')],
['bfill', t('Backward values')],
['median', t('Median values')],
['mean', t('Mean values')],
['sum', t('Sum values')],
],
description: t('Pandas resample method'),
},
Expand Down
16 changes: 8 additions & 8 deletions superset-frontend/plugins/plugin-chart-echarts/src/controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ const legendTypeControl: ControlSetItem = {
config: {
type: 'SelectControl',
freeForm: false,
label: 'Type',
label: t('Type'),
choices: [
['scroll', 'Scroll'],
['plain', 'Plain'],
['scroll', t('Scroll')],
['plain', t('Plain')],
],
default: legendType,
renderTrigger: true,
Expand All @@ -78,12 +78,12 @@ const legendOrientationControl: ControlSetItem = {
config: {
type: 'SelectControl',
freeForm: false,
label: 'Orientation',
label: t('Orientation'),
choices: [
['top', 'Top'],
['bottom', 'Bottom'],
['left', 'Left'],
['right', 'Right'],
['top', t('Top')],
['bottom', t('Bottom')],
['left', t('Left')],
['right', t('Right')],
],
default: legendOrientation,
renderTrigger: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class HandlebarsChartPlugin extends ChartPlugin {
*/
constructor() {
const metadata = new ChartMetadata({
description: 'Write a handlebars template to render the data',
description: t('Write a handlebars template to render the data'),
name: t('Handlebars'),
thumbnail,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
setIsSaving(false);
getClientErrorObject(response).then(({ error }) => {
modal.error({
title: 'Error',
title: t('Error'),
content: error || t('An error has occurred'),
okButtonProps: { danger: true, className: 'btn-danger' },
});
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/TableSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
onSuccess: (data: { options: Table[] }) => {
onTablesLoad?.(data.options);
if (isFetched) {
addSuccessToast('List updated');
addSuccessToast(t('List updated'));
}
},
onError: () => handleError(t('There was an error loading the tables')),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const PropertiesModal = ({
}

Modal.error({
title: 'Error',
title: t('Error'),
content: errorText,
okButtonProps: { danger: true, className: 'btn-danger' },
});
Expand Down Expand Up @@ -275,7 +275,7 @@ const PropertiesModal = ({
// only fire if the color_scheme is present and invalid
if (colorScheme && !colorChoices.includes(colorScheme)) {
Modal.error({
title: 'Error',
title: t('Error'),
content: t('A valid color scheme is required'),
okButtonProps: { danger: true, className: 'btn-danger' },
});
Expand Down
8 changes: 4 additions & 4 deletions superset-frontend/src/dashboard/components/SliceAdder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ const defaultProps = {

const KEYS_TO_FILTERS = ['slice_name', 'viz_type', 'datasource_name'];
const KEYS_TO_SORT = {
slice_name: 'name',
viz_type: 'viz type',
datasource_name: 'dataset',
changed_on: 'recent',
slice_name: t('name'),
viz_type: t('viz type'),
datasource_name: t('dataset'),
changed_on: t('recent'),
};

const DEFAULT_SORT_KEY = 'changed_on';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => {
{hasErrors && (
<Tooltip
id={`${kebabCase('validation-errors')}-tooltip`}
title="This section contains validation errors"
title={t('This section contains validation errors')}
>
<Icons.InfoCircleOutlined
css={css`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function PropertiesModal({
errorText = t('You do not have permission to edit this chart');
}
Modal.error({
title: 'Error',
title: t('Error'),
content: errorText,
okButtonProps: { danger: true, className: 'btn-danger' },
});
Expand Down Expand Up @@ -186,7 +186,7 @@ function PropertiesModal({
<Modal
show={show}
onHide={onHide}
title="Edit Chart Properties"
title={t('Edit Chart Properties')}
footer={
<>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ class AnnotationLayer extends React.PureComponent {
let description = '';
if (requiresQuery(sourceType)) {
if (sourceType === ANNOTATION_SOURCE_TYPES.NATIVE) {
label = 'Annotation layer';
description = 'Select the Annotation Layer you would like to use.';
label = t('Annotation layer');
description = t('Select the Annotation Layer you would like to use.');
} else {
label = t('Chart');
description = t(
Expand All @@ -426,10 +426,10 @@ class AnnotationLayer extends React.PureComponent {
);
}
} else if (annotationType === ANNOTATION_TYPES.FORMULA) {
label = 'Formula';
description = `Expects a formula with depending time parameter 'x'
label = t('Formula');
description = t(`Expects a formula with depending time parameter 'x'
in milliseconds since epoch. mathjs is used to evaluate the formulas.
Example: '2x+5'`;
Example: '2x+5'`);
}
if (requiresQuery(sourceType)) {
return (
Expand Down Expand Up @@ -464,7 +464,7 @@ class AnnotationLayer extends React.PureComponent {
onChange={this.handleValue}
validationErrors={
!this.isValidFormulaAnnotation(value, annotationType)
? ['Bad formula.']
? [t('Bad formula.')]
: []
}
/>
Expand Down Expand Up @@ -656,10 +656,10 @@ class AnnotationLayer extends React.PureComponent {
label={t('Style')}
// see '../../../visualizations/nvd3_vis.css'
options={[
{ value: 'solid', label: 'Solid' },
{ value: 'dashed', label: 'Dashed' },
{ value: 'longDashed', label: 'Long dashed' },
{ value: 'dotted', label: 'Dotted' },
{ value: 'solid', label: t('Solid') },
{ value: 'dashed', label: t('Dashed') },
{ value: 'longDashed', label: t('Long dashed') },
{ value: 'dotted', label: t('Dotted') },
]}
value={style}
clearable={false}
Expand All @@ -671,7 +671,7 @@ class AnnotationLayer extends React.PureComponent {
label={t('Opacity')}
// see '../../../visualizations/nvd3_vis.css'
options={[
{ value: '', label: 'Solid' },
{ value: '', label: t('Solid') },
{ value: 'opacityLow', label: '0.2' },
{ value: 'opacityMedium', label: '0.5' },
{ value: 'opacityHigh', label: '0.8' },
Expand All @@ -693,7 +693,7 @@ class AnnotationLayer extends React.PureComponent {
buttonSize="xsmall"
onClick={() => this.setState({ color: AUTOMATIC_COLOR })}
>
Automatic Color
{t('Automatic Color')}
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const colorSchemeOptions = (theme: SupersetTheme) => [
];

const operatorOptions = [
{ value: COMPARATOR.NONE, label: 'None' },
{ value: COMPARATOR.NONE, label: t('None') },
{ value: COMPARATOR.GREATER_THAN, label: '>' },
{ value: COMPARATOR.LESS_THAN, label: '<' },
{ value: COMPARATOR.GREATER_OR_EQUAL, label: '≥' },
Expand Down
Loading