Skip to content

Commit

Permalink
Merge pull request #883 from tf/public-i18n-fallack-fix
Browse files Browse the repository at this point in the history
Fix order of public i18n fallback
  • Loading branch information
tf authored Oct 10, 2017
2 parents 9aae68e + b561e43 commit b2c5e53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/helpers/pageflow/public_i18n_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def public_i18n_javascript_tag(entry)
def public_i18n_translations(entry)
{
pageflow: {
public: I18n.t('pageflow.public', locale: entry.locale)
public: I18n.t('pageflow.public', locale: I18n.default_locale)
.dup
.deep_merge(I18n.t('pageflow.public', locale: I18n.default_locale))
.deep_merge(I18n.t('pageflow.public', locale: entry.locale))
}
}
end
Expand Down
5 changes: 3 additions & 2 deletions spec/helpers/pageflow/public_i18n_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ module Pageflow
end

it 'falls back to default locale for missing keys' do
translation(:es, 'pageflow.public.some', 'text')
translation(I18n.default_locale, 'pageflow.public.some', 'text')
translation(:es, 'pageflow.public.some', 'es_text')
translation(I18n.default_locale, 'pageflow.public.some', 'default_text')
translation(I18n.default_locale, 'pageflow.public.some_new', 'new')

entry = PublishedEntry.new(create(:entry,
Expand All @@ -51,6 +51,7 @@ module Pageflow

result = helper.public_i18n_translations(entry)

expect(result[:pageflow][:public][:some]).to eq('es_text')
expect(result[:pageflow][:public][:some_new]).to eq('new')
end
end
Expand Down

0 comments on commit b2c5e53

Please sign in to comment.