Skip to content

Commit

Permalink
add warning when default locale is used
Browse files Browse the repository at this point in the history
  • Loading branch information
billyvg committed Jun 23, 2021
1 parent a1626aa commit 7bafdaa
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion static/app/locale.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import * as Sentry from '@sentry/react';
import Jed from 'jed';
import isArray from 'lodash/isArray';
import isObject from 'lodash/isObject';
Expand Down Expand Up @@ -68,7 +69,16 @@ type FormatArg = ComponentMap | React.ReactNode;
* if it has otherwise not been initialized.
*/
function getClient() {
return i18n || setLocale(DEFAULT_LOCALE_DATA);
if (!i18n) {
// If this happens, it could mean that an import was added/changed where
// locale initialization does not happen soon enough.
const warning = new Error('Locale not set, defaulting to English');
console.error(warning); // eslint-disable-line no-console
Sentry.captureException(warning);
return setLocale(DEFAULT_LOCALE_DATA);
}

return i18n;
}

/**
Expand Down

0 comments on commit 7bafdaa

Please sign in to comment.