-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the JS so it supports NodeJS #179
Conversation
…etermine the module system. Add uglifyjs and build script to package json
I forgot to mention that everything should work as before, the code was just rearranged. |
@bensampaio it would be good for you to explain the problem you are having at your work as an example in the documentation. The PR seems OK. I'm going to merge it. |
_domains = []; | ||
this.locale = get_current_locale(); | ||
if (typeof document !== 'undefined') { | ||
return document.documentElement.lang.replace('-', '_'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should return en
as default locale (or use a different detection strategy). Putting it as null
is a bad idea.
/*! | ||
* William DURAND <william.durand1@gmail.com> | ||
* MIT Licensed | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update the build script so that it keeps the license header
@stof, sorry for the delay on an answer. Since this was already merged, how do you propose I make the changes? I no longer have the forked repo. |
@bensampaio create a new PR |
This breaks when using RequireJs. |
I came across this problem when trying to implement server rendering on a ReactJS application dependent on the bazinga-translator. Since the variables
window
anddocument
don't exist in NodeJS, the Translator initialization would always fail.To fix that, I improved the module system detection so that when required on NodeJS the code no longer fails because
document
andwindow
don't exist. Also removed the dependency on the variableundefined
.Besides that, I added
uglify-js
as a dependency and the build script so other contributors don't need to guess which uglification options should be used. To uglify the JS now you just need to runnpm run build
under theResources
directory.What do you think?