-
-
Notifications
You must be signed in to change notification settings - Fork 280
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
Pick required language only. #220
Comments
A workaround for those in the same shoe: use webpack
|
Thankyou sir. I tried new webpack.ContextReplacementPlugin(/validatorjs[/\]lang$/, /en/) but that didn't work.... I may have missed the src dir |
@hongyuan1306 This works like a charm. I guess this issue can be closed now. What do you think? @skaterdav85 @garygreen |
Yeah there's various ways to exclude the lang from the bundle. By default it should only include english. Webpack may include all of them though because of the "wildcard" include so you can use
(that's webpack 3, not sure if that would work for v4) |
All these is a workaround not a solution. |
@mixtur We welcome any input or PRs to address this issue. In the meantime, there are a number of viable solutions supplied around using webpack. When preparing a solution, keep in mind that it needs to work against all the supported languages. Default to US only is not a viable solution as we have a large international user base and their preferred languages need to be taken into consideration |
While I can appreciate your statement, assuming English default is not the desired solution as we have a large international user base, and defaulting to English just won't work. As I have mentioned to others, I am open to ideas of how this can be handled. |
Will |
@mikeerickson I agree it's not ideal to assume everyone wants English as the primary language - though that's just how it was implemented by myself years ago as it was the logical decision to include it as the main language and then any additional languages can be included seperately as desired. Of course the ideal scenario is to support custom builds of some kind so developers can set their primary language, but it's not clear how to achieve this with our current build system using Grunt + Browserify. If we switched to a modern bundler it maybe easier with code splitting, etc. I think the ideal solution would be to have a new way validatorjs can be It's tricky to get this all working in the browser, node, bundlers etc so any PRs/suggestions are welcome. |
This sounds like what I'm thinking too. |
Thanks for the regex solution @hongyuan1306 Leaving it here for anyone that might need this in the future:
|
@pepijnolivier FTR, this is based on the official documentation --> https://webpack.js.org/plugins/ignore-plugin/#using-regular-expressions . Definitely not a hack or sth one could not figure out 😉 |
I was surprised that all the languages are inside my js bundle.
It would be great to have English by default and load additional language when
Validator.useLang(...)
triggered.The text was updated successfully, but these errors were encountered: