Skip to content

Commit

Permalink
Merge pull request #655 from ccutrer/lazy-loadable-duplicate-availabl…
Browse files Browse the repository at this point in the history
…e-locales

fix LazyLoadable#available_locales duplicating locales
  • Loading branch information
radar committed Apr 26, 2023
2 parents b9b79ab + 2acc3f4 commit 4ced6ee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/i18n/backend/lazy_loadable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def eager_load!
# Parse the load path and extract all locales.
def available_locales
if lazy_load?
I18n.load_path.map { |path| LocaleExtractor.locale_from_path(path) }
I18n.load_path.map { |path| LocaleExtractor.locale_from_path(path) }.uniq
else
super
end
Expand Down
2 changes: 1 addition & 1 deletion test/backend/lazy_loadable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def setup
@lazy_mode_backend = I18n::Backend::LazyLoadable.new(lazy_load: true)
@eager_mode_backend = I18n::Backend::LazyLoadable.new(lazy_load: false)

I18n.load_path = [File.join(locales_dir, '/en.yml'), File.join(locales_dir, '/fr.yml')]
I18n.load_path = [File.join(locales_dir, '/en.yml'), File.join(locales_dir, '/en.yaml'), File.join(locales_dir, '/fr.yml')]
end

test "lazy mode: only loads translations for current locale" do
Expand Down

0 comments on commit 4ced6ee

Please sign in to comment.