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

Set :en as fallback locale for grape errors when translations are missin... #444

Merged
merged 2 commits into from Jul 22, 2013

Conversation

aew
Copy link
Contributor

@aew aew commented Jul 20, 2013

...g for the default locale

There is currently no mention of I18n in the Grape readme.

I found myself in the following situation:

  • Embedded Grape API inside of Rails
  • Rails app has a default locale of :pt-BR
  • Did not add anything to locale file for Grape as I didn't think of it
  • Did not have config.i18n.fallbacks = [:en] set in application.rb

As a result, for all validation errors, the error messages were simply blank.

We could just tell people to set a fallback locale or include translations, but I don't think the blank messages are user friendly - at least I found this very difficult to debug for such a simple issue. This pull request reflects my opinion that Grape should fallback to the English messages (provided in the en.yml that ships with Grape) in situations where the messages would otherwise be blank.

Of course if people explicitly want blank error messages...this pull request will be problematic for them. This situation seems unlikely to me. At the very least, documentation will help.

### I18n

Grape supports I18n for parameter-related error messages, but will fallback to English if
translations for the default locale have not been provided. See [en.yml](https://github.com/intridea/grape/blob/master/lib/grape/locale/en.yml) for message keys.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this link relative, without the whole https://... thing, it will just work.

@dblock
Copy link
Member

dblock commented Jul 21, 2013

Feel free to ignore my comments, except for the README. Please also update CHANGELOG. Happy to merge then, thanks for your PR!

@dblock
Copy link
Member

dblock commented Jul 22, 2013

Thank you, merging.

dblock added a commit that referenced this pull request Jul 22, 2013
Set :en as fallback locale for grape errors when translations are missin...
@dblock dblock merged commit d814e93 into ruby-grape:master Jul 22, 2013
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

2 participants