How to use the scratch-l10n/locales/editor-msgs.en function in scratch-l10n

To help you get started, we’ve selected a few scratch-l10n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LLK / scratch-gui / src / playground / intl.js View on Github external
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
};
github LLK / scratch-gui / src / reducers / locales.js View on Github external
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,

scratch-l10n

Localization for the Scratch 3.0 components

BSD-3-Clause
Latest version published 7 hours ago

Package Health Score

78 / 100
Full package analysis

Similar packages