Skip to content

Commit

Permalink
I18n::Backend::Chain#translations merge from all backends
Browse files Browse the repository at this point in the history
https://github.com/fnando/i18n-js uses the `#translations` method to dump all translations to a javascript file during asset compilation.  The chain backend should deep_merge all these translations in order to dump the appropriate values.
  • Loading branch information
gburgett authored Feb 15, 2019
1 parent 80c4b78 commit 38a323e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/i18n/backend/chain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ def init_translations
end

def translations
backends.first.instance_eval do
init_translations unless initialized?
translations
backends.reverse.inject({}) do |h, b|
to_merge = b.instance_eval do
init_translations unless initialized?
translations
end

h.deep_merge(to_merge)
end
end

Expand Down

0 comments on commit 38a323e

Please sign in to comment.