You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently incorporating the i18n-js gem into my project. We currently export translations and use the requirejs-rails gem to load the i18n.js file from the server. We then will use the r.js optimization tool to assemble all of our dependencies into one JS file.
Although the contents of the i18n.js file are included in this r.js optimized version, it does not correctly detect the define method and appends a "shim" define at the end. Unfortunately this causes the I18n JS object to be inaccessible. I have tracked the problem down to the global closure inside the define call.
Steps to reproduce (current version of r.js included in the latest requirejs-rails gem on ubuntu server with packages nodejs npm):
wget 'https://raw.githubusercontent.com/jwhitley/requirejs-rails/0.9.5/bin/r.js'
# master copy as of 3/11/2015
wget 'https://raw.githubusercontent.com/fnando/i18n-js/f67fa51427dd004b43f20c46c4016a71012d6699/app/assets/javascripts/i18n.js'
# Optimized version
nodejs r.js -o baseUrl=. name=i18n out=i18n-optim.js
# Non-optimized version
nodejs r.js -o baseUrl=. name=i18n out=i18n-nooptim.js optimize=none
If you view the i18n-nooptim.js file, the last line is:
define("i18n.js", function(){});
Unfortunately this causes all require statements to return undefined for the 'i18n' dependency:
var global=this;
define('i18n', function(){ return factory(global);});
I believe that these are functionally identical, but I'm not sure about the original intention for this define statement statement, so I'm not sure if it will violate any edge cases. It's even fewer bytes :)
I'll create a pull request as an example fix.
The text was updated successfully, but these errors were encountered:
thegillis
added a commit
to MediaFactual/i18n-js
that referenced
this issue
Mar 11, 2015
I'm currently incorporating the i18n-js gem into my project. We currently export translations and use the requirejs-rails gem to load the i18n.js file from the server. We then will use the r.js optimization tool to assemble all of our dependencies into one JS file.
Although the contents of the i18n.js file are included in this r.js optimized version, it does not correctly detect the define method and appends a "shim" define at the end. Unfortunately this causes the I18n JS object to be inaccessible. I have tracked the problem down to the global closure inside the define call.
Steps to reproduce (current version of r.js included in the latest requirejs-rails gem on ubuntu server with packages nodejs npm):
If you view the i18n-nooptim.js file, the last line is:
Unfortunately this causes all require statements to return undefined for the 'i18n' dependency:
This is also identical to the most recent development copy of the r.js tool:
You will notice that the i18n-16-nooptim.js and i18n-16-optim.js files suffer from the same problem.
The fix is to replace the line:
With:
I believe that these are functionally identical, but I'm not sure about the original intention for this define statement statement, so I'm not sure if it will violate any edge cases. It's even fewer bytes :)
I'll create a pull request as an example fix.
The text was updated successfully, but these errors were encountered: