-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
I18n::MissingTranslationData: Translation missing: en.faker.company.buzzwords (I18n::MissingTranslationData) #2987
Comments
Thanks for reporting the issue, @rocket-turtle ! That's interesting. In your setup, I18n has For me, I18n's behavior makes sense, as faker is trying to force a locale that is not even available. So maybe this line here is not working as expected: Line 262 in 97cfd1a
Changing -- For now, if the We would also be open to accepting a PR that expands the |
I just added
If others have the same problem and #2719 is not moving to a different solution for loading the translations I can work on an PR but i think it would not be nice because |
I came to the same conclusion than @rocket-turtle I use Faker in a Rails app with FactoryBot in my RSpec code. So one way to circumvent this is to (in
But I'm not satisfied as the translation cache is no VERY polluted with every Faker translations from every languages... I currently use a fork of Faker that reloads I18n on missing translation (doing it once at the first missing translation, not every time). This way only :en translations are add and are polluting I18n. But still very basic and work is needed to reduce useless :en keys storage (when those keys are present in desired locale). |
My workaround is: in the Rails.application.configure do
config.i18n.enforce_available_locales = false
end and in I18n.load_path += Dir[File.join(`bundle show faker`.strip, 'lib', 'locales', '**/*.yml')]
Faker::Name.female_first_name # this line of code is to load the faker paths I hope we can find a better solution, because disabling |
Describe the bug
With my Setup I get this error when I call:
Faker::Company.catch_phrase
To Reproduce
Describe a way to reproduce your bug. To get the Faker version, run
Faker::VERSION
.Use the reproduction script below to reproduce the issue:
Additional context
Faker has a real simple translation missing fallback:
faker-3.4.2/lib/faker.rb
The
disable_enforce_available_locales
try to fix, ifenforce_available_locales
is set but:en
is not in thei18n.available_locales
.faker-3.4.2/lib/faker.rb:262
Problem
With this setup
I18n
does not store the:en
translation.i18n-1.14.5/lib/i18n/backend/simple.rb
Current workaround
Somewhere in my code I make:
I18n.reload! if I18n.backend.send(:translations).keys.exclude?(:en)
Solution?
I can not think about a good / easy solution without "polluting" the translations:
Before the reload!
I18n.backend.send(:translations).keys.count => 1
After the reload!
I18n.backend.send(:translations).keys.count => 66
Maybe the solution is in #2719
The text was updated successfully, but these errors were encountered: