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

Adds i18n support to error messages #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gabrielresende
Copy link

This PR adds support to i18n of error messages.

In some cases, the exception message may be good enough to be dispatched to the final user (after handling the exception properly, of course). It is better to add i18n support to the gem than parsing each message and translating them to the user’s language.

The changes introduced by this PR should not affect the current behavior of the gem. It presents the translation if the respective files are included in the load path (e.g., config/locales), otherwise it falls back to the default message in English.

The file locales/en.yml was added only for testing purposes and to be used as a model for other languages, and it is not used outside the gem.

This behaviour was inspired by the gem jsonapi-resources.

@iMacTia
Copy link
Collaborator

iMacTia commented May 29, 2018

@gabrielres I like the idea but we're planning a refactoring of validations based on ActiveModel so I'll come back to this after we're done with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants