Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error when locale is missing a faker key #1286

Closed
mrcasals opened this issue Jun 14, 2018 · 3 comments
Closed

Error when locale is missing a faker key #1286

mrcasals opened this issue Jun 14, 2018 · 3 comments

Comments

@mrcasals
Copy link

We're using faker version 1.8.7, and when we set I18n.locale = :fr and run Faker::Job.position, the code fails with this error:

NoMethodError: undefined method `[]' for nil:NilClass
/Users/my_user/.gem/ruby/2.5.1/gems/faker-1.8.7/lib/faker.rb:182:in `method_missing'

We're using Ruby 2.5.1.

I found out that the French locale does not have the job key, so this line fails:

https://github.com/stympy/faker/blob/bc912ae08ec8c369ca2cee543656f70207d2a84a/lib/faker.rb#L182

Can someone point me to a direction to fix this bug? I can't find a way to get a failing test for this 😞

Thanks! 😄

@vbrazo
Copy link
Member

vbrazo commented Jun 15, 2018

Well, someone needs to go there and add the job french locales. I don't know French, but I always try to help with Brazilian Portuguese and Spanish. Are you @mrcasals up to this challenge? You'd basically need to:

  • go to lib/locales/fr.yml and add the job locales
  • write tests for these locales in this file

If you're a new contributor, you should read this file first.

@mrcasals
Copy link
Author

@vbrazo I'm afraid I can't, but I'll try to ask for help. Anyway, is there any way to make faker delegate to the English locale if no translation is found for the given language? This would solve our current issues

@deivid-rodriguez
Copy link
Contributor

@mrcasals I fixed this in #1292 😉

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

No branches or pull requests

3 participants