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 = ''; let description = '';
if (requiresQuery(sourceType)) { if (requiresQuery(sourceType)) {
if (sourceType === ANNOTATION_SOURCE_TYPES.NATIVE) { if (sourceType === ANNOTATION_SOURCE_TYPES.NATIVE) {
label = 'Annotation Layer'; label = t('Annotation Layer');
description = 'Select the Annotation Layer you would like to use.'; description = t('Select the Annotation Layer you would like to use.');
} else { } else {
label = 'Slice'; label = t('Chart');
description = `Use a pre defined Superset Slice as a source for annotations and overlays. description = `Use a pre defined Superset Chart as a source for annotations and overlays.
'your chart must be one of these visualization types: 'your chart must be one of these visualization types:
'[${getSupportedSourceTypes(annotationType) '[${getSupportedSourceTypes(annotationType)
.map(x => vizTypes[x].label).join(', ')}]'`; .map(x => vizTypes[x].label).join(', ')}]'`;
} }
} else if (annotationType === AnnotationTypes.FORMULA) { } else if (annotationType === AnnotationTypes.FORMULA) {
label = 'Formula'; label = t('Formula');
description = `Expects a formula with depending time parameter 'x' description = t(`Expects a formula with depending time parameter 'x'
in milliseconds since epoch. mathjs is used to evaluate the formulas. in milliseconds since epoch. mathjs is used to evaluate the formulas.
Example: '2x+5'`; Example: '2x+5'`);
} }
if (requiresQuery(sourceType)) { if (requiresQuery(sourceType)) {
return ( return (
@ -300,7 +300,7 @@ export default class AnnotationLayer extends React.PureComponent {
isLoading={isLoadingOptions} isLoading={isLoadingOptions}
value={value} value={value}
onChange={this.handleValue} onChange={this.handleValue}
validationErrors={!value ? ['Mandatory'] : []} validationErrors={!value ? [t('Mandatory')] : []}
/> />
); );
} if (annotationType === AnnotationTypes.FORMULA) { } if (annotationType === AnnotationTypes.FORMULA) {
@ -314,7 +314,7 @@ export default class AnnotationLayer extends React.PureComponent {
placeholder="" placeholder=""
value={value} value={value}
onChange={this.handleValue} 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" bsSize="xsmall"
onClick={() => this.setState({ color: AUTOMATIC_COLOR })} onClick={() => this.setState({ color: AUTOMATIC_COLOR })}
> >
Automatic Color {t('Automatic Color')}
</Button> </Button>
</div> </div>
</div> </div>
@ -545,8 +545,8 @@ export default class AnnotationLayer extends React.PureComponent {
<CheckboxControl <CheckboxControl
hovered hovered
name="annotation-layer-show-markers" name="annotation-layer-show-markers"
label="Show Markers" label={t('Show Markers')}
description={'Shows or hides markers for the time series'} description={t('Shows or hides markers for the time series')}
value={showMarkers} value={showMarkers}
onChange={v => this.setState({ showMarkers: v })} onChange={v => this.setState({ showMarkers: v })}
/> />
@ -555,8 +555,8 @@ export default class AnnotationLayer extends React.PureComponent {
<CheckboxControl <CheckboxControl
hovered hovered
name="annotation-layer-hide-line" name="annotation-layer-hide-line"
label="Hide Line" label={t('Hide Line')}
description={'Hides the Line for the time series'} description={t('Hides the Line for the time series')}
value={hideLine} value={hideLine}
onChange={v => this.setState({ hideLine: v })} onChange={v => this.setState({ hideLine: v })}
/> />
@ -612,8 +612,8 @@ export default class AnnotationLayer extends React.PureComponent {
{!!getSupportedSourceTypes(annotationType).length && {!!getSupportedSourceTypes(annotationType).length &&
<SelectControl <SelectControl
hovered hovered
description="Choose the source of your annotations" description={t('Choose the source of your annotations')}
label="Annotation Source" label={t('Annotation Source')}
name="annotation-source-type" name="annotation-source-type"
options={getSupportedSourceTypes(annotationType).map( options={getSupportedSourceTypes(annotationType).map(
x => ({ value: x, label: getAnnotationSourceTypeLabels(x) }))} x => ({ value: x, label: getAnnotationSourceTypeLabels(x) }))}

View File

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

View File

@ -18,6 +18,12 @@ from .base import BaseSupersetView, DeleteMixin, SupersetModelView
class QueryView(SupersetModelView): class QueryView(SupersetModelView):
datamodel = SQLAInterface(Query) 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'] list_columns = ['user', 'database', 'status', 'start_time', 'end_time']
label_columns = { label_columns = {
'user': _('User'), 'user': _('User'),