Skip to content

Commit aeb69be

Browse files
feat: [IPR-1063] Add locale to editor state props
1 parent 38044f4 commit aeb69be

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

packages/scratch-gui/src/exported-reducers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {ScratchPaintReducer} from 'scratch-paint';
2-
import LocalesReducer, {localesInitialState, initLocale} from './reducers/locales.js';
2+
import LocalesReducer, {localesInitialState, initLocale, selectLocale} from './reducers/locales.js';
33
import GuiReducer, {buildInitialState, guiMiddleware, initEmbedded, initFullScreen, initPlayer} from './reducers/gui';
44
import {setFullScreen, setPlayer, setEmbedded} from './reducers/mode.js';
55
import {activateDeck} from './reducers/cards.js';
@@ -49,5 +49,6 @@ export {
4949
setFullScreen,
5050
setPlayer,
5151
setEmbedded,
52-
activateDeck
52+
activateDeck,
53+
selectLocale
5354
};

packages/scratch-gui/src/lib/app-state-provider-hoc.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import PropTypes from 'prop-types';
44

55
import {EditorState} from './editor-state';
66
import {setPlayer, setFullScreen, setEmbedded} from '../reducers/mode.js';
7-
import ConnectedIntlProvider from './connected-intl-provider.jsx';
87

98
/**
109
* Wraps the editor into the redux state contained within an EditorState instance.
@@ -39,11 +38,9 @@ export const AppStateProviderHOC = function (WrappedComponent) {
3938
} = this.props;
4039
return (
4140
<Provider store={appState.store}>
42-
<ConnectedIntlProvider>
43-
<WrappedComponent
44-
{...componentProps}
45-
/>
46-
</ConnectedIntlProvider>
41+
<WrappedComponent
42+
{...componentProps}
43+
/>
4744
</Provider>
4845
);
4946
}

packages/scratch-gui/src/lib/editor-state.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface EditorStateParams {
2121
isPlayerOnly?: boolean;
2222
showTelemetryModal?: boolean;
2323
isEmbedded?: boolean;
24+
locale?: string;
2425
}
2526

2627
/**
@@ -40,10 +41,18 @@ export class EditorState {
4041
let enhancer;
4142

4243
let initializedLocales = localesInitialState;
43-
const locale = detectLocale(Object.keys(locales));
44+
45+
let locale = 'en';
46+
if (params.locale && Object.keys(locales).includes(params.locale)) {
47+
locale = params.locale;
48+
} else {
49+
locale = detectLocale(Object.keys(locales));
50+
}
51+
4452
if (locale !== 'en') {
4553
initializedLocales = initLocale(initializedLocales, locale);
4654
}
55+
4756
if (params.localesOnly) {
4857
// Used for instantiating minimal state for the unsupported
4958
// browser modal

0 commit comments

Comments
 (0)