Teach Webpack to bundle translations plugin locales

Bug # 14679

Signed-off-by: Alex Coles <alex@alexbcoles.com>
pull/2193/head
Alex Coles 10 years ago
parent 1acafcaa26
commit 53c900fa3c
  1. 11
      app/assets/javascripts/angular/openproject-app.js
  2. 14
      webpack.config.js

@ -27,8 +27,17 @@
//++
var I18n = require('./vendor/i18n');
I18n.translations.de = require("locales/js-de.yml").de;
// standard locales
I18n.translations.en = require("locales/js-en.yml").en;
I18n.translations.de = require("locales/js-de.yml").de;
// extra locales, automatically loaded
var requireExtraLocale = require.context('extra-locales', false, /js-[\w|-]{2,5}\.yml$/);
requireExtraLocale.keys().forEach(function(localeFile) {
var locale = localeFile.match(/js-([\w|-]{2,5})\.yml/)[1];
I18n.translations[locale] = requireExtraLocale(localeFile)[locale];
});
var angular = require('angular');
require('angular-animate');

@ -1,5 +1,6 @@
var webpack = require('webpack'),
path = require('path');
var webpack = require('webpack'),
path = require('path'),
pathConfig = require('./config/rails-plugins.conf');
module.exports = {
context: __dirname + '/app/assets/javascripts/angular',
@ -15,7 +16,7 @@ module.exports = {
loaders: [
{ test: /[\/]angular\.js$/, loader: "exports?angular" },
{ test: /[\/]vendor[\/]i18n\.js$/, loader: "expose?I18n" },
{ test: /js-\w{2}\.yml$/, loader: 'json!yaml' },
{ test: /js-[\w|-]{2,5}\.yml$/, loader: 'json!yaml' }
]
},
@ -28,7 +29,8 @@ module.exports = {
],
alias: {
'locales': 'config/locales',
'locales': 'config/locales',
'extra-locales': path.join(pathConfig.translationsPluginPath, 'config', 'locales'),
'angular-ui-date': 'angular-ui-date/src/date',
'angular-truncate': 'angular-truncate/src/truncate',
@ -40,6 +42,10 @@ module.exports = {
}
},
resolveLoader: {
root: __dirname + '/node_modules'
},
externals: { jquery: "jQuery" },
plugins: [

Loading…
Cancel
Save