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

Internationalization of Js pages #3161

Closed
wants to merge 22 commits into from
Closed
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
52 changes: 52 additions & 0 deletions babel/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -916,3 +916,55 @@ msgstr ""
msgid "Saved Queries"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:73
msgid "Please enter a slice name"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:88
msgid "Please select a dashboard"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:96
msgid "Please enter a dashboard name"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:134
msgid "Save A Slice"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:155
msgid "Overwrite slice"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:164
msgid "Save as"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:168
msgid "[slice name]"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:181
msgid "Do not add to a dashboard"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:189
msgid "Add slice to existing dashboard"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:203
msgid "Add to new dashboard"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:208
msgid "[dashboard name]"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:220
msgid "Save"
msgstr ""

#: superset/assets/javascripts/explore/components/SaveModal.jsx:229
msgid "Save & go to dashboard"
msgstr ""

Binary file added superset/.config.py.swp
Binary file not shown.
28 changes: 15 additions & 13 deletions superset/assets/javascripts/explore/components/SaveModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import $ from 'jquery';
import { Modal, Alert, Button, Radio } from 'react-bootstrap';
import Select from 'react-select';
import { connect } from 'react-redux';
import { t } from '../../locale';

const propTypes = {
can_overwrite: PropTypes.bool,
Expand Down Expand Up @@ -69,7 +70,7 @@ class SaveModal extends React.Component {
if (sliceParams.action === 'saveas') {
sliceName = this.state.newSliceName;
if (sliceName === '') {
this.setState({ alert: 'Please enter a slice name' });
this.setState({ alert: t('Please enter a slice name') });
return;
}
sliceParams.slice_name = sliceName;
Expand All @@ -84,15 +85,15 @@ class SaveModal extends React.Component {
case ('existing'):
dashboard = this.state.saveToDashboardId;
if (!dashboard) {
this.setState({ alert: 'Please select a dashboard' });
this.setState({ alert: t('Please select a dashboard') });
return;
}
sliceParams.save_to_dashboard_id = dashboard;
break;
case ('new'):
dashboard = this.state.newDashboardName;
if (dashboard === '') {
this.setState({ alert: 'Please enter a dashboard name' });
this.setState({ alert: t('Please enter a dashboard name') });
return;
}
sliceParams.new_dashboard_name = dashboard;
Expand Down Expand Up @@ -130,7 +131,7 @@ class SaveModal extends React.Component {
>
<Modal.Header closeButton>
<Modal.Title>
Save A Slice
{t('Save A Slice')}
</Modal.Title>
</Modal.Header>
<Modal.Body>
Expand All @@ -151,7 +152,7 @@ class SaveModal extends React.Component {
checked={this.state.action === 'overwrite'}
onChange={this.changeAction.bind(this, 'overwrite')}
>
{`Overwrite slice ${this.props.slice.slice_name}`}
{`${t('Overwrite slice')} ${this.props.slice.slice_name}`}
</Radio>
}

Expand All @@ -160,11 +161,11 @@ class SaveModal extends React.Component {
inline
checked={this.state.action === 'saveas'}
onChange={this.changeAction.bind(this, 'saveas')}
> Save as &nbsp;
> {t('Save as')} &nbsp;
</Radio>
<input
name="new_slice_name"
placeholder="[slice name]"
placeholder={t('[slice name]')}
onChange={this.onChange.bind(this, 'newSliceName')}
onFocus={this.changeAction.bind(this, 'saveas')}
/>
Expand All @@ -177,15 +178,15 @@ class SaveModal extends React.Component {
checked={this.state.addToDash === 'noSave'}
onChange={this.changeDash.bind(this, 'noSave')}
>
Do not add to a dashboard
{t('Do not add to a dashboard')}
</Radio>

<Radio
inline
checked={this.state.addToDash === 'existing'}
onChange={this.changeDash.bind(this, 'existing')}
>
Add slice to existing dashboard
{t('Add slice to existing dashboard')}
</Radio>
<Select
options={this.props.dashboards}
Expand All @@ -199,13 +200,14 @@ class SaveModal extends React.Component {
checked={this.state.addToDash === 'new'}
onChange={this.changeDash.bind(this, 'new')}
>
Add to new dashboard &nbsp;
{t('Add to new dashboard')} &nbsp;
</Radio>
<input
onChange={this.onChange.bind(this, 'newDashboardName')}
onFocus={this.changeDash.bind(this, 'new')}
placeholder="[dashboard name]"
placeholder={t('[dashboard name]')}
/>

</Modal.Body>

<Modal.Footer>
Expand All @@ -215,7 +217,7 @@ class SaveModal extends React.Component {
className="btn pull-left"
onClick={this.saveOrOverwrite.bind(this, false)}
>
Save
{t('Save')}
</Button>
<Button
type="button"
Expand All @@ -224,7 +226,7 @@ class SaveModal extends React.Component {
disabled={this.state.addToDash === 'noSave'}
onClick={this.saveOrOverwrite.bind(this, true)}
>
Save & go to dashboard
{t('Save & go to dashboard')}
</Button>
</Modal.Footer>
</Modal>
Expand Down
34 changes: 34 additions & 0 deletions superset/assets/javascripts/explore/stores/language.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

const $ = window.$ = require('jquery');

export function getLanguage() {
function getLocale() {
const locale = $.ajax({
url: '/superset/rest/api/getLocale',
async: false,
});
return locale.responseText;
}
switch (getLocale()) {
case 'en':
return 'es';
case 'fr':
return 'fr';
case 'it':
return 'it';
case 'zh':
return 'zh';
default:
return 'es';
}
}

export function getTranslate() {
const translate = $.ajax({
url: '/superset/rest/api/getTranslate',
async: false,
});
console.log(translate);
console.log(translate.responseText);
return translate.responseText;
}
Loading