Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function init() {
if ( window.Raven && isEnabled( 'sentry' ) ) {
window.Raven.config( 'https://02c1c1625528468ea40a86143860cdb7@sentry.io/96319' ).install();
// This is an experiment to send uncaught error in Promises to Sentry
// We might want to remove it if we receive too many errors
window.addEventListener( 'unhandledrejection', ( err ) => {
window.Raven.captureException( err.reason );
} );
}
window.switchLocale = switchLocale;
if ( window.localeData ) {
i18n.setLocale( window.localeData );
}
injectTapEventPlugin();
// pre-load checkout chunk
sections.checkout();
}
function switchLocale( localeSlug ) {
setLocaleCookie( localeSlug );
if ( localeSlug === config( 'i18n_default_locale_slug' ) ) {
// sets the locale back to the default
i18n.setLocale();
return;
}
request.get( languageFileUrl( localeSlug ) ).end( function( error, response ) {
if ( error ) {
debug( 'Encountered an error loading locale file for ' + localeSlug + '. Falling back to English.' );
return;
}
i18n.setLocale( response.body );
} );
}
export default function boot() {
// Initialize i18n mixin
//ReactClass.injection.injectMixin( i18n.mixin );
if ( ! window.i18nLocale ) {
return;
}
const i18nLocaleStringsObject = JSON.parse( window.i18nLocale.json );
if ( ! i18nLocaleStringsObject || ! i18nLocaleStringsObject[ '' ] ) {
return;
}
i18nLocaleStringsObject[ '' ].localeSlug = window.i18nLocale.localeSlug;
i18n.setLocale( i18nLocaleStringsObject );
}
export default function boot() {
let i18nLocaleStringsObject = null;
bootDebug( 'Starting Calypso Support' );
i18n.setLocale( window.i18nLocaleStrings );
ReactInjection.Class.injectMixin( i18n.mixin );
// Infer touch screen by checking if device supports touch events
if ( touchDetect.hasTouch() ) {
classes( document.documentElement ).add( 'touch' );
} else {
classes( document.documentElement ).add( 'notouch' );
}
// Initialize touch
injectTapEventPlugin();
}
body => {
if ( body ) {
// Handle race condition when we're requested to switch to a different
// locale while we're in the middle of request, we should abandon result
if ( targetLocaleSlug !== lastRequestedLocale ) {
return;
}
i18n.setLocale( body );
setLocaleInDOM( domLocaleSlug, !! language.rtl );
loadUserUndeployedTranslations( targetLocaleSlug );
}
},
// Failure.
Initial_State.locale[ '' ].localeSlug = Initial_State.localeSlug;
// Overloading the toLocaleString method to use the set locale
Number.prototype.realToLocaleString = Number.prototype.toLocaleString;
Number.prototype.toLocaleString = function( locale, options ) {
locale = locale || Initial_State.localeSlug;
options = options || {};
return this.realToLocaleString( locale, options );
};
} else {
Initial_State.locale = { '': { localeSlug: Initial_State.localeSlug } };
}
i18n.setLocale( Initial_State.locale );
const hashHistory = useRouterHistory( createHashHistory )();
const history = syncHistoryWithStore( hashHistory, store );
// Add dispatch and actionTypes to the window object so we can use it from the browser's console
if ( 'undefined' !== typeof window && process.env.NODE_ENV === 'development' ) {
assign( window, {
actionTypes: actionTypes,
dispatch: store.dispatch,
} );
}
render();
function render() {
export const setLocaleRawData = localeData => {
i18n.setLocale( localeData );
const { localeSlug, localeVariant = null } = localeData[ '' ];
return {
type: LOCALE_SET,
localeSlug,
localeVariant,
};
};
request.get( languageFileUrl( localeSlug ) ).end( function( error, response ) {
if ( error ) {
debug( 'Encountered an error loading locale file for ' + localeSlug + '. Falling back to English.' );
return;
}
i18n.setLocale( response.body );
} );
}