Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {addLocaleData} from 'react-intl';
import localeData from 'scratch-l10n';
import editorMessages from 'scratch-l10n/locales/editor-msgs';
Object.keys(localeData).forEach(locale => {
addLocaleData(localeData[locale].localeData);
});
const intlDefault = {
defaultLocale: 'en',
locale: 'en',
messages: editorMessages.en
};
export {
intlDefault as default,
editorMessages
};
import {addLocaleData} from 'react-intl';
import {localeData} from 'scratch-l10n';
import editorMessages from 'scratch-l10n/locales/editor-msgs';
import RtlLocales from '../lib/rtl-locales';
addLocaleData(localeData);
const UPDATE_LOCALES = 'scratch-gui/locales/UPDATE_LOCALES';
const SELECT_LOCALE = 'scratch-gui/locales/SELECT_LOCALE';
const initialState = {
isRtl: false,
locale: 'en',
messagesByLocale: editorMessages,
messages: editorMessages.en
};
const reducer = function (state, action) {
if (typeof state === 'undefined') state = initialState;
switch (action.type) {
case SELECT_LOCALE:
return Object.assign({}, state, {
isRtl: RtlLocales.indexOf(action.locale) !== -1,
locale: action.locale,
messagesByLocale: state.messagesByLocale,
messages: state.messagesByLocale[action.locale]
});
case UPDATE_LOCALES:
return Object.assign({}, state, {
isRtl: state.isRtl,
locale: state.locale,