Skip to content

Commit be337ee

Browse files
eviziteijenseng
authored andcommitted
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>
1 parent 74a9e2f commit be337ee

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

frontend_build/i18n.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@ module.exports.pitch = function(remainingRequest, precedingRequest, data) {
2222

2323
if(scopeName.indexOf("ic_submission-download-dialog") > -1){
2424
// TODO: I'm so, so sorry about this. Figure out how to scope
25-
// correctly for this one exceptional case later
25+
// correctly for this one exceptional case later
2626
} else {
2727
scopeName = scopeName.replace(/-/, '_');
2828
}
2929

30+
// in development, we can save bandwidth and build time by not bothering
31+
// to include translation artifacts during the build.
32+
var shouldTranslate = process.env.RAILS_LOAD_ALL_LOCALES || process.env.RAILS_ENV == 'production' || process.env.NODE_ENV == 'production';
33+
var translationDependency = "";
34+
if(shouldTranslate){
35+
translationDependency = " 'translations/" + scopeName + "', 'translations/_core',";
36+
}
37+
3038
var scopedJavascript = "" +
31-
"define(['i18nObj', 'translations/"+ scopeName +"', 'translations/_core', 'translations/_core_en'], function(I18n) {" +
39+
"define(['i18nObj'," + translationDependency + " 'translations/_core_en'], function(I18n) {" +
3240
" return I18n.scoped('" + scopeName + "');" +
3341
"});";
3442

0 commit comments

Comments
 (0)