How to use the react-intl.addLocaleData function in react-intl

To help you get started, we’ve selected a few react-intl 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 benkeen / birdsearch.org / core / start.jsx View on Github external
import { Router, Route } from 'react-router';
import { Provider, connect } from 'react-redux';
import { createStore, combineReducers, applyMiddleware } from 'redux';

import * as components from '../components/index';
import * as i18n from './i18n/index';
import * as storage from './storage';
import * as reducers from './reducers';
import { C } from './core';

// locale information for react-intl
import en from 'react-intl/dist/locale-data/en';
import es from 'react-intl/dist/locale-data/es';
import fr from 'react-intl/dist/locale-data/fr';
import de from 'react-intl/dist/locale-data/de';
addLocaleData(en);
addLocaleData(es);
addLocaleData(fr);
addLocaleData(de);

const {
  Header,
  DOMHelper,
  MainPanel
} = components;

// initialize the store with the appropriate lang
const store = initStore({ locale: storage.get('locale') || C.DEFAULT_LOCALE });

// debugging
//console.log("initial store state: ", store.getState());
//store.subscribe(() => console.log("store just changed: ", store.getState()));
github meetup / meetup-web-platform / packages / mwp-i18n / src / loadLocaleData.js View on Github external
export default function loadLocaleData(localeCode: ?string) {
	if (!localeCode) {
		return;
	}
	const locale = localeMap[localeCode];
	if (!locale) {
		console.warn(`${localeCode} not supported`);
		return;
	}
	if (!locale.data) {
		// locale is supported but no special config will be loaded
		return;
	}
	addLocaleData(locale.data);
}
github airbus-cyber / graylog-plugin-alert-wizard / src / web / wizard / WizardPage.jsx View on Github external
import {Col, Row} from 'react-bootstrap';
import {IfPermitted, PageHeader, Spinner, DocumentTitle} from 'components/common';
import AlertRuleList from './AlertRuleList';
import ManageSettings from './ManageSettings';
import {addLocaleData, IntlProvider, FormattedMessage} from 'react-intl';
import messages_fr from '../translations/fr.json';
import WizardConfigurationsActions from '../config/WizardConfigurationsActions';
import WizardConfigurationStore from "../config/WizardConfigurationsStore";
import StoreProvider from 'injection/StoreProvider';
import ActionsProvider from 'injection/ActionsProvider';
const PluginsStore = StoreProvider.getStore('Plugins');
const NodesActions = ActionsProvider.getActions('Nodes');

let frLocaleData = require('react-intl/locale-data/fr');
const language = navigator.language.split(/[-_]/)[0];
addLocaleData(frLocaleData);

const messages = {
            'fr': messages_fr
        };

const WizardPage = createReactClass({
    displayName: 'WizardPage',

    mixins: [Reflux.connect(WizardConfigurationStore)],

    getInitialState() {
        return {
            configurations: null,
            version: '',
        };
    },
github wso2 / carbon-device-mgt / components / application-mgt / org.wso2.carbon.device.application.mgt.store.ui / src / main / resources / store / src / index.js View on Github external
}).catch(error => {
        addLocaleData(require('react-intl/locale-data/en'));
        let defaultLocale = Axios.create({
            baseURL: Configuration.hostConstants.baseURL + "/" + Configuration.hostConstants.appContext + "/locales/"
            + Constants.defaultLocale + ".json"
        }).get();
        defaultLocale.then(response => {
            const messages = defineMessages(response.data);
            ReactDOM.render(, document.getElementById('root'));
            registerServiceWorker();
        }).catch(error => {
        });
    });
}
github bodhiproject / bodhi-ui / src / languageProvider / index.js View on Github external
import { addLocaleData } from 'react-intl';
import Enlang from './entries/en-US';
import Zhlang from './entries/zh-Hans-CN';
import Krlang from './entries/ko-KR';

addLocaleData(Enlang.data);
addLocaleData(Zhlang.data);
addLocaleData(Krlang.data);

export default {
  [Enlang.locale]: Enlang,
  [Zhlang.locale]: Zhlang,
  [Krlang.locale]: Krlang,
};
github Nexusoft / NexusInterface / app / reducers / index.js View on Github external
import addressbook from './addressbook';
import terminal from './terminal';
import settings from './settings';

import intl from './intl';
import { addLocaleData } from 'react-intl';
import ru from 'react-intl/locale-data/ru';
import ja from 'react-intl/locale-data/ja';
import de from 'react-intl/locale-data/de';
import en from 'react-intl/locale-data/en';
import ko from 'react-intl/locale-data/ko';
import fr from 'react-intl/locale-data/fr';
import es from 'react-intl/locale-data/es';
import { FormattedMessage } from 'react-intl';

addLocaleData(ru);
addLocaleData(en);
addLocaleData(ja);
addLocaleData(de);
addLocaleData(ko);
addLocaleData(fr);
addLocaleData(es);

export default function createRootReducer(history: {}) {
  const routerReducer = connectRouter(history)(() => {});

  return connectRouter(history)(
    combineReducers({
      intl,
      overview,
      routerReducer,
      list,
github formatjs / react-intl / examples / nested / src / client / index.jsx View on Github external
import * as React from 'react';
import ReactDOM from 'react-dom';
import {addLocaleData, IntlProvider} from 'react-intl';
import enLocaleData from 'react-intl/locale-data/en';
import App from './components/app';

addLocaleData(enLocaleData);

const {locale, messages} = window.App;

ReactDOM.render(
  
     messages[namespace]} />
  ,
  document.getElementById('container')
);
github akameco / PixivDeck / app / i18n / index.js View on Github external
import jaLocaleData from 'react-intl/locale-data/ja'
import enLocaleData from 'react-intl/locale-data/en'
import zhLocaleData from 'react-intl/locale-data/zh'
import idLocaleData from 'react-intl/locale-data/id'
import zhtwLocaleData from './localedata-zhtw'

import enTranslationMessages from './en.yml'
import idTranslationMessages from './id.yml'
import jaTranslationMessages from './ja.yml'
import zhTranslationMessages from './zh.yml'
import zhtwTranslationMessages from './zh-TW.yml'

addLocaleData(enLocaleData)
addLocaleData(idLocaleData)
addLocaleData(jaLocaleData)
addLocaleData(zhLocaleData)
addLocaleData(zhtwLocaleData)

export const appLocales = ['en', 'id', 'ja', 'zh', 'zh-tw']

export const translationMessages = {
  en: enTranslationMessages,
  id: idTranslationMessages,
  ja: jaTranslationMessages,
  zh: zhTranslationMessages,
  'zh-tw': zhtwTranslationMessages,
}
github voluntarily / vly2 / pages / _app.js View on Github external
Object.keys(window.ReactIntlLocaleData).forEach(lang => {
    addLocaleData(window.ReactIntlLocaleData[lang])
  })
}