webpack: dont rely on translation files in development

Change-Id: I12bf4332bf9ec57a509d08bf71073033756b17bf
Reviewed-on: https://gerrit.instructure.com/72366
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
This commit is contained in:
Ethan Vizitei 2016-02-17 12:42:30 -07:00 committed by Jon Jensen
parent 74a9e2fae7
commit be337eeb01
1 changed files with 10 additions and 2 deletions

View File

@ -22,13 +22,21 @@ module.exports.pitch = function(remainingRequest, precedingRequest, data) {
if(scopeName.indexOf("ic_submission-download-dialog") > -1){
// TODO: I'm so, so sorry about this. Figure out how to scope
// correctly for this one exceptional case later
// correctly for this one exceptional case later
} else {
scopeName = scopeName.replace(/-/, '_');
}
// in development, we can save bandwidth and build time by not bothering
// to include translation artifacts during the build.
var shouldTranslate = process.env.RAILS_LOAD_ALL_LOCALES || process.env.RAILS_ENV == 'production' || process.env.NODE_ENV == 'production';
var translationDependency = "";
if(shouldTranslate){
translationDependency = " 'translations/" + scopeName + "', 'translations/_core',";
}
var scopedJavascript = "" +
"define(['i18nObj', 'translations/"+ scopeName +"', 'translations/_core', 'translations/_core_en'], function(I18n) {" +
"define(['i18nObj'," + translationDependency + " 'translations/_core_en'], function(I18n) {" +
" return I18n.scoped('" + scopeName + "');" +
"});";