Skip to content
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

Option to disable i18n translation #58

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

snnrk
Copy link

@snnrk snnrk commented Mar 29, 2018

Hi,

My app needs to include the threshold into the message on validation error.
(eg. "Name should be within 15 characters.")
In the case of the message above, the code can be written like this:

req.__('Name should be within %s characters.', User.attributes.name.maxLength);

But sails-hook-validation translate the message inside when the current or default locale is set.
This behavior disturbs to replace the specifier in the message with the value.
The reason is:

  • Due to that behavior, I don't know what model (and field) the message is for.
  • I can't get the threshold because the name of the model (and the field) is not known.

So I added the option to disable i18n translation in the hook.
Using this option, I can receive the raw customMessage (formated as "model.field.rule').

Please pull them if acceptable.

The option is boolean, named sails.config.i18n.hookValidation.
sails.config.i18n.hookValidation will be set true if not defined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant