diff --git a/frontend/app/init-app.js b/frontend/app/init-app.js index 7a9af042f7..81ef1d28c3 100644 --- a/frontend/app/init-app.js +++ b/frontend/app/init-app.js @@ -39,6 +39,10 @@ require('jquery-ui/themes/base/datepicker.css'); require('jquery-ui/themes/base/dialog.css'); require('nouislider/distribute/nouislider.min.css'); +// load I18n, depending on the html element having a 'lang' attribute +var documentLang = (angular.element('html').attr('lang') || 'en').toLowerCase(); +require('angular-i18n/angular-locale_' + documentLang + '.js'); + var opApp = require('./angular-modules.ts').default; window.appBasePath = jQuery('meta[name=app_base_path]').attr('content') || ''; diff --git a/frontend/app/vendors.js b/frontend/app/vendors.js index a2c5fd0533..4f05c87b6f 100644 --- a/frontend/app/vendors.js +++ b/frontend/app/vendors.js @@ -55,10 +55,6 @@ require('angular-truncate/src/truncate.js'); require('angular-ui-router/release/angular-ui-router.min.js'); require('ng-file-upload/dist/ng-file-upload.min.js'); -// depends on the html element having a 'lang' attribute -var documentLang = (angular.element('html').attr('lang') || 'en').toLowerCase(); -require('angular-i18n/angular-locale_' + documentLang + '.js'); - // Jquery UI require('jquery-ui/ui/core.js'); require('jquery-ui/ui/position.js'); diff --git a/frontend/webpack-main-config.js b/frontend/webpack-main-config.js index e96ebaea81..7d0be08113 100644 --- a/frontend/webpack-main-config.js +++ b/frontend/webpack-main-config.js @@ -256,7 +256,10 @@ function getWebpackMainConfig() { new webpack.ContextReplacementPlugin( /(angular-i18n)/, new RegExp('angular-locale_(' + localeIds.join('|') + ')\.js$', 'i') - ) + ), + + // Restrict loaded moment locales to the ones we load from translations + new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, new RegExp('(' + localeIds.join('|') + ')\.js$', 'i')) ] }; diff --git a/frontend/webpack-vendors-config.js b/frontend/webpack-vendors-config.js index 12cfe63ac9..48520e313f 100644 --- a/frontend/webpack-vendors-config.js +++ b/frontend/webpack-vendors-config.js @@ -30,7 +30,6 @@ var webpack = require('webpack'); var fs = require('fs'); var path = require('path'); var _ = require('lodash'); -var pathConfig = require('./rails-plugins.conf'); var autoprefixer = require('autoprefixer'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); @@ -43,16 +42,6 @@ var node_root = path.resolve(__dirname, 'node_modules'); var output_root = path.resolve(__dirname, '..', 'app', 'assets', 'javascripts'); var bundle_output = path.resolve(output_root, 'bundles') -/** Extract available locales from openproject-translations plugin */ -var translations = path.resolve(pathConfig.allPluginNamesPaths['openproject-translations'], 'config', 'locales'); -var localeIds = ['en']; -fs.readdirSync(translations).forEach(function (file) { - var matches = file.match( /^js-(.+)\.yml$/); - if (matches && matches.length > 1) { - localeIds.push(matches[1]); - } -}); - function getWebpackVendorsConfig() { config = { entry: { @@ -84,16 +73,7 @@ function getWebpackVendorsConfig() { new CleanWebpackPlugin(['bundles'], { root: output_root, verbose: true - }), - - // Restrict loaded ngLocale locales to the ones we load from translations - new webpack.ContextReplacementPlugin( - /angular\-i18n/, - new RegExp('angular\-locale\_(' + localeIds.join('|') + ')\.js$', 'i') - ), - - // Restrict loaded moment locales to the ones we load from translations - new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, new RegExp('(' + localeIds.join('|') + ')\.js$', 'i')) + }) ] };