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
I18n translate possible by override the validate.translate
method
#10
Conversation
if (typeof validate.translate === 'function') { | ||
return validate.translate.apply(this, args); | ||
} else { | ||
return util.format.apply(this, args); |
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.
这里的 this 是指向谁呢?
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.
t 呀?这么写有问题吗?还是我把 apply 理解错了?看起来能跑的呀。
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.
没问题,这里应该传 util util.format.apply(util, args)
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.
好了
function t() { | ||
var args = Array.prototype.slice.call(arguments); | ||
if (typeof validate.translate === 'function') { | ||
return validate.translate.apply(this, args); |
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.
这里也应该换成 validate 吧?validate.translate.apply(validate, args);
+1 |
I18n translate possible by override the `validate.translate` method
parameter@1.1.0 |
I'm agree #9, but I don't like #10 . My opinion:
But this MR use the third way, Localization in the app AND parameter module, I don't like it. |
with #9
When the users want custom the validate messages, they can through override the
validate.translate
to done that.