make some text localizable, mainly in explore, query (#5735)

This commit is contained in:
hitdemo 2018-08-27 02:02:56 +08:00 committed by Maxime Beauchemin
parent cae070467b
commit 9a6595d0e9
3 changed files with 24 additions and 18 deletions

View File

@ -272,20 +272,20 @@ export default 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 = 'Slice';
description = `Use a pre defined Superset Slice as a source for annotations and overlays.
label = t('Chart');
description = `Use a pre defined Superset Chart as a source for annotations and overlays.
'your chart must be one of these visualization types:
'[${getSupportedSourceTypes(annotationType)
.map(x => vizTypes[x].label).join(', ')}]'`;
}
} else if (annotationType === AnnotationTypes.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 (
@ -300,7 +300,7 @@ export default class AnnotationLayer extends React.PureComponent {
isLoading={isLoadingOptions}
value={value}
onChange={this.handleValue}
validationErrors={!value ? ['Mandatory'] : []}
validationErrors={!value ? [t('Mandatory')] : []}
/>
);
} if (annotationType === AnnotationTypes.FORMULA) {
@ -314,7 +314,7 @@ export default class AnnotationLayer extends React.PureComponent {
placeholder=""
value={value}
onChange={this.handleValue}
validationErrors={this.isValidFormula(value, annotationType) ? ['Bad formula.'] : []}
validationErrors={this.isValidFormula(value, annotationType) ? [t('Bad formula.')] : []}
/>
);
}
@ -530,7 +530,7 @@ export default class AnnotationLayer extends React.PureComponent {
bsSize="xsmall"
onClick={() => this.setState({ color: AUTOMATIC_COLOR })}
>
Automatic Color
{t('Automatic Color')}
</Button>
</div>
</div>
@ -545,8 +545,8 @@ export default class AnnotationLayer extends React.PureComponent {
<CheckboxControl
hovered
name="annotation-layer-show-markers"
label="Show Markers"
description={'Shows or hides markers for the time series'}
label={t('Show Markers')}
description={t('Shows or hides markers for the time series')}
value={showMarkers}
onChange={v => this.setState({ showMarkers: v })}
/>
@ -555,8 +555,8 @@ export default class AnnotationLayer extends React.PureComponent {
<CheckboxControl
hovered
name="annotation-layer-hide-line"
label="Hide Line"
description={'Hides the Line for the time series'}
label={t('Hide Line')}
description={t('Hides the Line for the time series')}
value={hideLine}
onChange={v => this.setState({ hideLine: v })}
/>
@ -612,8 +612,8 @@ export default class AnnotationLayer extends React.PureComponent {
{!!getSupportedSourceTypes(annotationType).length &&
<SelectControl
hovered
description="Choose the source of your annotations"
label="Annotation Source"
description={t('Choose the source of your annotations')}
label={t('Annotation Source')}
name="annotation-source-type"
options={getSupportedSourceTypes(annotationType).map(
x => ({ value: x, label: getAnnotationSourceTypeLabels(x) }))}

View File

@ -1431,7 +1431,7 @@ class Superset(BaseSupersetView):
def save_slice(self, slc):
session = db.session()
msg = 'Slice [{}] has been saved'.format(slc.slice_name)
msg = _('Chart [{}] has been saved').format(slc.slice_name)
session.add(slc)
session.commit()
flash(msg, 'info')
@ -1440,7 +1440,7 @@ class Superset(BaseSupersetView):
session = db.session()
session.merge(slc)
session.commit()
msg = 'Slice [{}] has been overwritten'.format(slc.slice_name)
msg = _('Chart [{}] has been overwritten').format(slc.slice_name)
flash(msg, 'info')
@api

View File

@ -18,6 +18,12 @@ from .base import BaseSupersetView, DeleteMixin, SupersetModelView
class QueryView(SupersetModelView):
datamodel = SQLAInterface(Query)
list_title = _('List Query')
show_title = _('Show Query')
add_title = _('Add Query')
edit_title = _('Edit Query')
list_columns = ['user', 'database', 'status', 'start_time', 'end_time']
label_columns = {
'user': _('User'),