Skip to content

Commit 3fcc13a

Browse files
committed
Integrate www-gui localization
* Initialize `locales` in redux using methods exported by GUI. * pass GUI method to set the `scratchlanguage` cookie NOTE: It does not reload the page, so switching back to the project page will not reflect language changes made in gui until the next page reload. Reloading the page will lose project state so we don’t want to do that.
1 parent ecd686f commit 3fcc13a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/views/preview/preview.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const render = require('../../lib/render.jsx');
1212
const storage = require('../../lib/storage.js').default;
1313
const log = require('../../lib/log');
1414
const EXTENSION_INFO = require('../../lib/extensions.js').default;
15+
const jar = require('../../lib/jar.js');
1516

1617
const PreviewPresentation = require('./presentation.jsx');
1718
const projectShape = require('./projectshape.jsx').projectShape;
@@ -332,6 +333,9 @@ class Preview extends React.Component {
332333
title: title
333334
});
334335
}
336+
handleSetLanguage (locale) {
337+
jar.set('scratchlanguage', locale);
338+
}
335339
handleUpdateProjectId (projectId, callback) {
336340
this.setState({projectId: projectId}, () => {
337341
const parts = window.location.pathname.toLowerCase()
@@ -444,6 +448,7 @@ class Preview extends React.Component {
444448
renderLogin={this.renderLogin}
445449
onLogOut={this.props.handleLogOut}
446450
onOpenRegistration={this.props.handleOpenRegistration}
451+
onSetLanguage={this.handleSetLanguage}
447452
onShare={this.handleShare}
448453
onToggleLoginOpen={this.props.handleToggleLoginOpen}
449454
onUpdateProjectId={this.handleUpdateProjectId}
@@ -707,6 +712,9 @@ render(
707712
preview: previewActions.previewReducer,
708713
...GUI.guiReducers
709714
},
710-
{scratchGui: initGuiState(GUI.guiInitialState)},
715+
{
716+
locales: GUI.initLocale(GUI.localesInitialState, window._locale),
717+
scratchGui: initGuiState(GUI.guiInitialState)
718+
},
711719
GUI.guiMiddleware
712720
);

0 commit comments

Comments
 (0)