diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-10-04 11:23:52 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-10-04 11:23:52 +0000 |
commit | 412571a4dfbf90d85df1393fa0075aacae27137d (patch) | |
tree | 7e6f349542472d2679fb5d8013f4c39eeb95960f /app/assets/javascripts/locale | |
parent | 086784411c73d61a296e923b2274f81344646a77 (diff) | |
download | gitlab-ce-412571a4dfbf90d85df1393fa0075aacae27137d.tar.gz |
Load only the currently needed JS locale file
Diffstat (limited to 'app/assets/javascripts/locale')
-rw-r--r-- | app/assets/javascripts/locale/index.js | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/app/assets/javascripts/locale/index.js b/app/assets/javascripts/locale/index.js index af718e894cf..ce05b3eabec 100644 --- a/app/assets/javascripts/locale/index.js +++ b/app/assets/javascripts/locale/index.js @@ -1,30 +1,12 @@ import Jed from 'jed'; - import sprintf from './sprintf'; -/** - This is required to require all the translation folders in the current directory - this saves us having to do this manually & keep up to date with new languages -**/ -function requireAll(requireContext) { return requireContext.keys().map(requireContext); } - -const allLocales = requireAll(require.context('./', true, /^(?!.*(?:index.js$)).*\.js$/)); -const locales = allLocales.reduce((d, obj) => { - const data = d; - const localeKey = Object.keys(obj)[0]; - - data[localeKey] = obj[localeKey]; - - return data; -}, {}); - const langAttribute = document.querySelector('html').getAttribute('lang'); const lang = (langAttribute || 'en').replace(/-/g, '_'); -const locale = new Jed(locales[lang]); +const locale = new Jed(window.translations || {}); /** Translates `text` - @param text The text to be translated @returns {String} The translated text **/ |