diff --git a/extensions/ohif-i18n/src/index.js b/extensions/ohif-i18n/src/index.js index 8214b013f..f11da3c37 100755 --- a/extensions/ohif-i18n/src/index.js +++ b/extensions/ohif-i18n/src/index.js @@ -31,6 +31,12 @@ function getKeyForNameSpaces(key) { } function getLocales() { + const isWebpackEnv = typeof require.context === 'function'; + // require.context is exclusive from webpack, it's needed to escape inside jest + if (!isWebpackEnv) { + return {}; + } + const context = require.context(`./locales`, true, /\.json$/); const locales = {}; @@ -85,10 +91,6 @@ customDebug(`version ${pkg.version} loaded.`, 'info'); initI18n(); -export { - translate as t, - addLocales, - initI18n -}; +export { translate as t, addLocales, initI18n }; export default i18n;