feat: added i18n statements to sqllab (#7194)

Closes #7193
This commit is contained in:
Enrico Berti 2019-04-01 22:43:22 +02:00 committed by Krist Wongsuphasawat
parent 2af9a84d09
commit 37d7b2c040
5 changed files with 20 additions and 18 deletions

View File

@ -76,8 +76,8 @@ export default class LimitControl extends React.PureComponent {
renderPopover() {
const textValue = this.state.textValue;
const isValid = this.isValidLimit(textValue);
const errorMsg = 'Row limit must be positive integer' +
(this.props.maxRow ? ` and not greater than ${this.props.maxRow}` : '');
const errorMsg = t('Row limit must be positive integer') +
(this.props.maxRow ? t(' and not greater than %s', this.props.maxRow) : '');
return (
<Popover id="sqllab-limit-results">
<div style={{ width: '100px' }}>

View File

@ -220,7 +220,7 @@ export default class ResultSet extends React.PureComponent {
</React.Fragment>
);
} else if (data && data.length === 0) {
return <Alert bsStyle="warning">The query returned no data</Alert>;
return <Alert bsStyle="warning">{t('The query returned no data')}</Alert>;
}
}
if (query.cached) {

View File

@ -42,7 +42,7 @@ class ShareSqlLabQuery extends React.Component {
constructor(props) {
super(props);
this.state = {
shortUrl: 'Loading ...',
shortUrl: t('Loading ...'),
showOverlay: false,
};
this.getCopyUrl = this.getCopyUrl.bind(this);
@ -69,7 +69,7 @@ class ShareSqlLabQuery extends React.Component {
return (
<Popover id="sqllab-shareurl-popover">
<CopyToClipboard
text={this.state.shortUrl || 'Loading ...'}
text={this.state.shortUrl || t('Loading ...')}
copyNode={<i className="fa fa-clipboard" title={t('Copy to clipboard')} />}
/>
</Popover>

View File

@ -144,19 +144,19 @@ class SqlEditor extends React.PureComponent {
{
name: 'runQuery1',
key: 'ctrl+r',
descr: 'Run query',
descr: t('Run query'),
func: this.runQuery,
},
{
name: 'runQuery2',
key: 'ctrl+enter',
descr: 'Run query',
descr: t('Run query'),
func: this.runQuery,
},
{
name: 'newTab',
key: 'ctrl+t',
descr: 'New tab',
descr: t('New tab'),
func: () => {
this.props.actions.addQueryEditor({
...this.props.queryEditor,
@ -168,7 +168,7 @@ class SqlEditor extends React.PureComponent {
{
name: 'stopQuery',
key: 'ctrl+x',
descr: 'Stop query',
descr: t('Stop query'),
func: this.stopQuery,
},
];
@ -287,9 +287,9 @@ class SqlEditor extends React.PureComponent {
if (this.props.latestQuery && this.props.latestQuery.limit_reached) {
const tooltip = (
<Tooltip id="tooltip">
It appears that the number of rows in the query results displayed
was limited on the server side to
the {this.props.latestQuery.rows} limit.
{t(`It appears that the number of rows in the query results displayed
was limited on the server side to
the %s limit.`, this.props.latestQuery.rows)}
</Tooltip>
);
limitWarning = (
@ -341,7 +341,7 @@ class SqlEditor extends React.PureComponent {
</span>
<span className="m-l-5">
<Hotkeys
header="Keyboard shortcuts"
header={t('Keyboard shortcuts')}
hotkeys={hotkeys}
/>
</span>

View File

@ -79,11 +79,13 @@ export default class TemplateParamsEditor extends React.Component {
renderDoc() {
return (
<p>
Assign a set of parameters as <code>JSON</code> below
(example: <code>{'{"my_table": "foo"}'}</code>),
and they become available
in your SQL (example: <code>SELECT * FROM {'{{ my_table }}'} </code>)
by using&nbsp;
{t('Assign a set of parameters as')}
<code>JSON</code>
{t('below (example:')}
<code>{'{"my_table": "foo"}'}</code>
{t('), and they become available in your SQL (example:')}
<code>SELECT * FROM {'{{ my_table }}'} </code>
{t(') by using')}&nbsp;
<a
href="https://superset.apache.org/sqllab.html#templating-with-jinja"
target="_blank"