Skip to content

Commit 3e99c7d

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 f3b9826 commit 3e99c7d

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;
@@ -318,6 +319,9 @@ class Preview extends React.Component {
318319
title: title
319320
});
320321
}
322+
handleSetLanguage (locale) {
323+
jar.set('scratchlanguage', locale);
324+
}
321325
initCounts (favorites, loves) {
322326
this.setState({
323327
favoriteCount: favorites,
@@ -412,6 +416,7 @@ class Preview extends React.Component {
412416
renderLogin={this.renderLogin}
413417
onLogOut={this.props.handleLogOut}
414418
onOpenRegistration={this.props.handleOpenRegistration}
419+
onSetLanguage={this.handleSetLanguage}
415420
onShare={this.handleShare}
416421
onToggleLoginOpen={this.props.handleToggleLoginOpen}
417422
onUpdateProjectTitle={this.handleUpdateProjectTitle}
@@ -702,6 +707,9 @@ render(
702707
preview: previewActions.previewReducer,
703708
...GUI.guiReducers
704709
},
705-
{scratchGui: initGuiState(GUI.guiInitialState)},
710+
{
711+
locales: GUI.initLocale(GUI.localesInitialState, window._locale),
712+
scratchGui: initGuiState(GUI.guiInitialState)
713+
},
706714
GUI.guiMiddleware
707715
);

0 commit comments

Comments
 (0)