feathersjs-ecosystem / authentication-local

[MOVED] Local authentication plugin for feathers-authentication
https://github.com/feathersjs/feathers
MIT License
26 stars 15 forks source link

i18n support #28

Closed andycaramba closed 7 years ago

andycaramba commented 7 years ago

How can I internationalise error messages like 'Invalid login' and so on?

daffl commented 7 years ago

You can modify the error with hook.error in an error hook:

app.service('myservice').hooks({
  error(hook) {
    const { error } = hook;

    if(error.name === 'NotAuthenticated' && hook.params.user.language === 'de') {
      error.message = "Bitte anmelden";
    }

    hook.error = error;
  }
})
andycaramba commented 7 years ago

@daffl thank you, it works