mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 07:38:07 -05:00
b65332c5d4
Now that Raven is bundled with webpack, it's not available in the global context, so require it and configure it within the init module. I struggled to figure out how to expose the raven-js module as a global, as all the combinations of `externals` and `ProvidePlugin` only applied to webpacked modules, not the global window. The correct way to do it seems to be exports-loader but that looked rather hacky and hard to understand.
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
var jar = require('./lib/jar');
|
|
var Raven = require('raven-js');
|
|
|
|
/**
|
|
* -----------------------------------------------------------------------------
|
|
* Error handling
|
|
* -----------------------------------------------------------------------------
|
|
*/
|
|
(function () {
|
|
if (process.env.SENTRY_DSN !== '') {
|
|
Raven.config(process.env.SENTRY_DSN).install();
|
|
}
|
|
})();
|
|
|
|
/**
|
|
* -----------------------------------------------------------------------------
|
|
* L10N
|
|
* -----------------------------------------------------------------------------
|
|
*/
|
|
(function () {
|
|
/**
|
|
* Bind locale code from cookie if available. Uses navigator language API as a fallback.
|
|
*
|
|
* @return {string}
|
|
*/
|
|
function updateLocale () {
|
|
var obj = jar.get('scratchlanguage');
|
|
if (typeof obj === 'undefined') {
|
|
obj = window.navigator.userLanguage || window.navigator.language;
|
|
if (['pt','pt-pt','PT','PT-PT'].indexOf(obj) !== -1) {
|
|
obj = 'pt-br'; // default Portuguese users to Brazilian Portuguese due to our user base. Added in 2.2.5.
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
window._locale = updateLocale();
|
|
})();
|