Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/faker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ def locale=(new_locale)

def locale
# Because I18n.locale defaults to :en, if we don't have :en in our available_locales, errors will happen
Thread.current[:faker_config_locale] || @default_locale || (I18n.available_locales.include?(I18n.locale) ? I18n.locale : I18n.available_locales.first)
# I18n.locale_available? is used here because it relies on a memoized
# set of locales, unlike I18n.available_locales which is recomputed
# on every call.
Thread.current[:faker_config_locale] || @default_locale || (I18n.locale_available?(I18n.locale) ? I18n.locale : I18n.available_locales.first)
end

def own_locale
Expand Down