Skip to content

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.

README.md Outdated
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.

2 participants