How to use scratch-l10n - 6 common examples

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-paint / src / playground / reducers / intl.js View on Github external
import {updateIntl as superUpdateIntl} from 'react-intl-redux';
import {IntlProvider, intlReducer} from 'react-intl-redux';

import localeData from 'scratch-l10n';
import paintMessages from 'scratch-l10n/locales/paint-editor-msgs';

Object.keys(localeData).forEach(locale => {
    // TODO: will need to handle locales not in the default intl - see www/custom-locales
    addLocaleData(localeData[locale].localeData);
});

const intlInitialState = {
    intl: {
        defaultLocale: 'en',
        locale: 'en',
        messages: paintMessages.en.messages
    }
};

const updateIntl = locale => superUpdateIntl({
    locale: locale,
    messages: paintMessages[locale].messages || paintMessages.en.messages
});

export {
    intlReducer as default,
    IntlProvider,
    intlInitialState,
    updateIntl
};
github LLK / scratch-www / src / lib / intl.jsx View on Github external
const ReactIntl = require('react-intl');

// Add locale data to react intl for all supported languages
const localeData = require('scratch-l10n').localeData;
ReactIntl.addLocaleData(localeData);

module.exports = ReactIntl;
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,
github LLK / scratch-paint / src / playground / reducers / intl.js View on Github external
const updateIntl = locale => superUpdateIntl({
    locale: locale,
    messages: paintMessages[locale].messages || paintMessages.en.messages
});
github LLK / scratch-www / bin / configure-fastly.js View on Github external
'} else {\n' +
            '    if (!req.http.Fastly-FF) {\n' +
            '        if (req.http.X-Forwarded-For) {\n' +
            '            set req.http.Fastly-Temp-XFF = req.http.X-Forwarded-For ", " client.ip;\n' +
            '        } else {\n' +
            '            set req.http.Fastly-Temp-XFF = client.ip;\n' +
            '        }\n' +
            '    } else {\n' +
            '        set req.http.Fastly-Temp-XFF = req.http.X-Forwarded-For;\n' +
            '    }\n' +
            '    set req.grace = 60s;\n' +
            '    if (req.http.Cookie:scratchlanguage) {\n' +
            '        set req.http.Accept-Language = req.http.Cookie:scratchlanguage;\n' +
            '    } else {\n' +
            '        set req.http.Accept-Language = accept.language_lookup("' +
                         Object.keys(languages).join(':') + '", ' +
                         '"en", ' +
                         'std.tolower(req.http.Accept-Language)' +
                     ');\n' +
            '    }\n' +
            '    if (req.url ~ "^(/projects/|/fragment/account-nav.json|/session/)" && ' +
            '!req.http.Cookie:scratchsessionsid) {\n' +
            '        set req.http.Cookie = "scratchlanguage=" req.http.Cookie:scratchlanguage;\n' +
            '    } else {\n' +
            '        return(pass);\n' +
            '    }\n' +
            '}\n';


        fastly.setCustomVCL(
            results.version,
            'recv-condition',

scratch-l10n

Localization for the Scratch 3.0 components

BSD-3-Clause
Latest version published 1 day ago

Package Health Score

78 / 100
Full package analysis

Similar packages