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

make some text localizable #5611

Merged
merged 1 commit into from
Aug 13, 2018
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
3 changes: 2 additions & 1 deletion superset/assets/src/dashboard/components/SliceAdder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Loading from '../../components/Loading';
import { CHART_TYPE, NEW_COMPONENT_SOURCE_TYPE } from '../util/componentTypes';
import { NEW_CHART_ID, NEW_COMPONENTS_SOURCE_ID } from '../util/constants';
import { slicePropShape } from '../util/propShapes';
import { t } from '../../locales';

const propTypes = {
fetchAllSlices: PropTypes.func.isRequired,
Expand Down Expand Up @@ -204,7 +205,7 @@ class SliceAdder extends React.Component {
<div className="slice-adder-container">
<div className="controls">
<SearchInput
placeholder="Filter your charts"
placeholder={t('Filter your charts')}
className="search-input"
onChange={this.searchUpdated}
onKeyPress={this.handleKeyPress}
Expand Down
6 changes: 3 additions & 3 deletions superset/assets/src/explore/components/DisplayQueryButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default class DisplayQueryButton extends React.PureComponent {
<ModalTrigger
isMenuItem
animation={this.props.animation}
triggerNode={<span>View query</span>}
triggerNode={<span>{t('View query')}</span>}
modalTitle={t('View query')}
bsSize="large"
beforeOpen={this.beforeOpen}
Expand All @@ -152,7 +152,7 @@ export default class DisplayQueryButton extends React.PureComponent {
<ModalTrigger
isMenuItem
animation={this.props.animation}
triggerNode={<span>View results</span>}
triggerNode={<span>{t('View results')}</span>}
modalTitle={t('View results')}
bsSize="large"
beforeOpen={this.beforeOpen}
Expand All @@ -163,7 +163,7 @@ export default class DisplayQueryButton extends React.PureComponent {
eventKey="3"
onClick={this.redirectSQLLab.bind(this)}
>
Run in SQL Lab
{t('Run in SQL Lab')}
</MenuItem>}
</DropdownButton>
);
Expand Down
34 changes: 18 additions & 16 deletions superset/assets/src/explore/components/controls/AnnotationLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import ControlHeader from '../ControlHeader';
import { nonEmpty } from '../../validators';
import vizTypes from '../../visTypes';

import { t } from '../../../locales';

const AUTOMATIC_COLOR = '';

const propTypes = {
Expand Down Expand Up @@ -485,12 +487,12 @@ export default class AnnotationLayer extends React.PureComponent {
<PopoverSection
isSelected
onSelect={() => {}}
title="Display configuration"
info="Configure your how you overlay is displayed here."
title={t('Display configuration')}
info={t('Configure your how you overlay is displayed here.')}
>
<SelectControl
name="annotation-layer-stroke"
label="Style"
label={t('Style')}
// see '../../../visualizations/nvd3_vis.css'
options={[
{ value: 'solid', label: 'Solid' },
Expand All @@ -503,7 +505,7 @@ export default class AnnotationLayer extends React.PureComponent {
/>
<SelectControl
name="annotation-layer-opacity"
label="Opacity"
label={t('Opacity')}
// see '../../../visualizations/nvd3_vis.css'
options={[
{ value: '', label: 'Solid' },
Expand All @@ -515,7 +517,7 @@ export default class AnnotationLayer extends React.PureComponent {
onChange={v => this.setState({ opacity: v })}
/>
<div>
<ControlHeader label="Color" />
<ControlHeader label={t('Color')} />
<div style={{ display: 'flex', flexDirection: 'column' }}>
<CompactPicker
color={color}
Expand All @@ -534,7 +536,7 @@ export default class AnnotationLayer extends React.PureComponent {
</div>
<TextControl
name="annotation-layer-stroke-width"
label="Line Width"
label={t('Line Width')}
isInt
value={width}
onChange={v => this.setState({ width: v })}
Expand Down Expand Up @@ -580,27 +582,27 @@ export default class AnnotationLayer extends React.PureComponent {
<PopoverSection
isSelected
onSelect={() => {}}
title="Layer Configuration"
info="Configure the basics of your Annotation Layer."
title={t('Layer Configuration')}
info={t('Configure the basics of your Annotation Layer.')}
>
<TextControl
name="annotation-layer-name"
label="Name"
label={t('Name')}
placeholder=""
value={name}
onChange={v => this.setState({ name: v })}
validationErrors={!name ? ['Mandatory'] : []}
validationErrors={!name ? [t('Mandatory')] : []}
/>
<CheckboxControl
name="annotation-layer-hide"
label="Hide Layer"
label={t('Hide Layer')}
value={!show}
onChange={v => this.setState({ show: !v })}
/>
<SelectControl
hovered
description="Choose the Annotation Layer Type"
label="Annotation Layer Type"
description={t('Choose the Annotation Layer Type')}
label={t('Annotation Layer Type')}
name="annotation-layer-type"
options={getSupportedAnnotationTypes(this.props.vizType).map(
x => ({ value: x, label: getAnnotationTypeLabel(x) }))}
Expand Down Expand Up @@ -630,23 +632,23 @@ export default class AnnotationLayer extends React.PureComponent {
bsSize="sm"
onClick={this.deleteAnnotation}
>
{ !isNew ? 'Remove' : 'Cancel' }
{ !isNew ? t('Remove') : t('Cancel') }
</Button>
<div>
<Button
bsSize="sm"
disabled={!isValid}
onClick={this.applyAnnotation}
>
Apply
{t('Apply')}
</Button>

<Button
bsSize="sm"
disabled={!isValid}
onClick={this.submitAnnotation}
>
OK
{t('OK')}
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class AnnotationLayerControl extends React.PureComponent {
return (
<Popover
style={{ maxWidth: 'none' }}
title={annotation ? 'Edit Annotation Layer' : 'Add Annotation Layer'}
title={annotation ? t('Edit Annotation Layer') : t('Add Annotation Layer')}
id={`annotation-pop-${id}`}
>
<AnnotationLayer
Expand Down
8 changes: 4 additions & 4 deletions superset/assets/src/explore/visTypes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ export const sections = {
'that allow for advanced analytical post processing ' +
'of query results'),
controlSetRows: [
[<h1 className="section-header">Moving Average</h1>],
[<h1 className="section-header">{t('Moving Average')}</h1>],
['rolling_type', 'rolling_periods', 'min_periods'],
[<h1 className="section-header">Time Comparison</h1>],
[<h1 className="section-header">{t('Time Comparison')}</h1>],
['time_compare', 'comparison_type'],
[<h1 className="section-header">Python Functions</h1>],
[<h1 className="section-header">{t('Python Functions')}</h1>],
[<h2 className="section-header">pandas.resample</h2>],
['resample_how', 'resample_rule', 'resample_fillmethod'],
],
Expand Down Expand Up @@ -1833,7 +1833,7 @@ export const visTypes = {
},

partition: {
label: 'Partition Diagram',
label: t('Partition Diagram'),
showOnExplore: true,
controlPanelSections: [
sections.NVD3TimeSeries[0],
Expand Down
10 changes: 10 additions & 0 deletions superset/connectors/druid/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class DruidColumnInlineView(CompactCRUDMixin, SupersetModelView): # noqa
'sum': _('Sum'),
'min': _('Min'),
'max': _('Max'),
'verbose_name': _('Verbose Name'),
'description': _('Description'),
}
description_columns = {
'filterable': _(
Expand Down Expand Up @@ -137,6 +139,7 @@ class DruidMetricInlineView(CompactCRUDMixin, SupersetModelView): # noqa
'json': _('JSON'),
'datasource': _('Druid Datasource'),
'warning_text': _('Warning Message'),
'is_restricted': _('Is Restricted'),
}

def post_add(self, metric):
Expand Down Expand Up @@ -175,6 +178,9 @@ class DruidClusterModelView(SupersetModelView, DeleteMixin, YamlExportMixin): #
'broker_host': _('Broker Host'),
'broker_port': _('Broker Port'),
'broker_endpoint': _('Broker Endpoint'),
'verbose_name': _('Verbose Name'),
'cache_timeout': _('Cache Timeout'),
'metadata_last_refreshed': _('Metadata Last Refreshed'),
}
description_columns = {
'cache_timeout': _(
Expand Down Expand Up @@ -272,6 +278,10 @@ class DruidDatasourceModelView(DatasourceModelView, DeleteMixin, YamlExportMixin
'default_endpoint': _('Default Endpoint'),
'offset': _('Time Offset'),
'cache_timeout': _('Cache Timeout'),
'datasource_name': _('Datasource Name'),
'fetch_values_from': _('Fetch Values From'),
'changed_by_': _('Changed By'),
'modified': _('Modified'),
}

def pre_add(self, datasource):
Expand Down
1 change: 1 addition & 0 deletions superset/connectors/sqla/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ class TableModelView(DatasourceModelView, DeleteMixin, YamlExportMixin): # noqa
'description': _('Description'),
'is_sqllab_view': _('SQL Lab View'),
'template_params': _('Template parameters'),
'modified': _('Modified'),
}

def pre_add(self, table):
Expand Down
26 changes: 26 additions & 0 deletions superset/views/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from flask_appbuilder.models.sqla.interface import SQLAInterface
from flask_babel import gettext as __
from flask_babel import lazy_gettext as _

from superset import appbuilder
from superset.models.annotations import Annotation, AnnotationLayer
Expand All @@ -15,11 +16,25 @@

class AnnotationModelView(SupersetModelView, DeleteMixin): # noqa
datamodel = SQLAInterface(Annotation)

list_title = _('List Annotation')
show_title = _('Show Annotation')
add_title = _('Add Annotation')
edit_title = _('Edit Annotation')

list_columns = ['layer', 'short_descr', 'start_dttm', 'end_dttm']
edit_columns = [
'layer', 'short_descr', 'long_descr', 'start_dttm', 'end_dttm']
add_columns = edit_columns

label_columns = {
'layer': _('Layer'),
'short_descr': _('Short Descr'),
'start_dttm': _('Start Dttm'),
'end_dttm': _('End Dttm'),
'long_descr': _('Long Descr'),
}

def pre_add(self, obj):
if not obj.layer:
raise Exception('Annotation layer is required.')
Expand All @@ -38,10 +53,21 @@ def pre_update(self, obj):

class AnnotationLayerModelView(SupersetModelView, DeleteMixin):
datamodel = SQLAInterface(AnnotationLayer)

list_title = _('List Annotation Layer')
show_title = _('Show Annotation Layer')
add_title = _('Add Annotation Layer')
edit_title = _('Edit Annotation Layer')

list_columns = ['id', 'name']
edit_columns = ['name', 'descr']
add_columns = edit_columns

label_columns = {
'name': _('Name'),
'descr': _('Description'),
}


appbuilder.add_view(
AnnotationLayerModelView,
Expand Down
16 changes: 16 additions & 0 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ class DatabaseView(SupersetModelView, DeleteMixin, YamlExportMixin): # noqa
'allow_run_sync': _('Allow Run Sync'),
'allow_run_async': _('Allow Run Async'),
'impersonate_user': _('Impersonate the logged on user'),
'allow_csv_upload': _('Allow Csv Upload'),
'modified': _('Modified'),
'allow_multi_schema_metadata_fetch': _('Allow Multi Schema Metadata Fetch'),
'backend': _('Backend'),
}

def pre_add(self, db):
Expand Down Expand Up @@ -624,6 +628,12 @@ class DashboardAddView(DashboardModelView): # noqa

class LogModelView(SupersetModelView):
datamodel = SQLAInterface(models.Log)

list_title = _('List Log')
show_title = _('Show Log')
add_title = _('Add Log')
edit_title = _('Edit Log')

list_columns = ('user', 'action', 'dttm')
edit_columns = ('user', 'action', 'dttm', 'json')
base_order = ('dttm', 'desc')
Expand Down Expand Up @@ -2725,6 +2735,12 @@ def slice_query(self, slice_id):

class CssTemplateModelView(SupersetModelView, DeleteMixin):
datamodel = SQLAInterface(models.CssTemplate)

list_title = _('List Css Template')
show_title = _('Show Css Template')
add_title = _('Add Css Template')
edit_title = _('Edit Css Template')

list_columns = ['template_name']
edit_columns = ['template_name', 'css']
add_columns = edit_columns
Expand Down