diff options
Diffstat (limited to 'app/assets/javascripts/locale/index.js')
-rw-r--r-- | app/assets/javascripts/locale/index.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/app/assets/javascripts/locale/index.js b/app/assets/javascripts/locale/index.js index c1afabf1e35..600654794a5 100644 --- a/app/assets/javascripts/locale/index.js +++ b/app/assets/javascripts/locale/index.js @@ -6,8 +6,17 @@ const GITLAB_FALLBACK_LANGUAGE = 'en'; const languageCode = () => document.querySelector('html').getAttribute('lang') || GITLAB_FALLBACK_LANGUAGE; -const locale = new Jed(window.translations || {}); -delete window.translations; + +/** + * This file might be imported into a web worker indirectly, the `window` object + * won't be defined in the web worker context so we need to check if it is defined + * before we access the `translations` property. + */ +const hasTranslations = typeof window !== 'undefined' && window.translations; +const locale = new Jed(hasTranslations ? window.translations : {}); +if (hasTranslations) { + delete window.translations; +} /** Translates `text` |