2018-01-30 11:53:12 -05:00
|
|
|
const jar = require('./lib/jar');
|
|
|
|
const Raven = require('raven-js');
|
2015-10-16 11:04:34 -04:00
|
|
|
|
2016-05-17 15:57:23 -04:00
|
|
|
/**
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
* Error handling
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
*/
|
2018-01-30 11:53:12 -05:00
|
|
|
(() => {
|
2016-05-17 15:57:23 -04:00
|
|
|
if (process.env.SENTRY_DSN !== '') {
|
|
|
|
Raven.config(process.env.SENTRY_DSN).install();
|
|
|
|
}
|
|
|
|
})();
|
2015-10-15 23:05:57 -04:00
|
|
|
|
2015-10-21 20:49:31 -04:00
|
|
|
/**
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
* L10N
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
*/
|
2018-01-30 11:53:12 -05:00
|
|
|
(() => {
|
|
|
|
/*
|
2015-10-15 23:05:57 -04:00
|
|
|
* Bind locale code from cookie if available. Uses navigator language API as a fallback.
|
|
|
|
*
|
|
|
|
* @return {string}
|
|
|
|
*/
|
2018-01-30 11:53:12 -05:00
|
|
|
const updateLocale = () => {
|
|
|
|
let obj = jar.get('scratchlanguage');
|
2015-10-15 23:05:57 -04:00
|
|
|
if (typeof obj === 'undefined') {
|
|
|
|
obj = window.navigator.userLanguage || window.navigator.language;
|
2018-01-30 11:53:12 -05:00
|
|
|
if (['pt', 'pt-pt', 'PT', 'PT-PT'].indexOf(obj) !== -1) {
|
2016-01-04 14:18:47 -05:00
|
|
|
obj = 'pt-br'; // default Portuguese users to Brazilian Portuguese due to our user base. Added in 2.2.5.
|
|
|
|
}
|
2015-10-15 23:05:57 -04:00
|
|
|
}
|
|
|
|
return obj;
|
2018-01-30 11:53:12 -05:00
|
|
|
};
|
2015-10-15 23:05:57 -04:00
|
|
|
|
2016-01-06 14:09:32 -05:00
|
|
|
window._locale = updateLocale();
|
2015-10-15 23:05:57 -04:00
|
|
|
})();
|