Skip to content
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

seeds multiple language localization fix #314

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 21 additions & 17 deletions db/seeds.rb
@@ -1,19 +1,23 @@
Refinery::User.all.each do |user|
if user.plugins.where(:name => 'refinerycms_blog').blank?
user.plugins.create(:name => "refinerycms_blog",
:position => (user.plugins.maximum(:position) || -1) +1)
end
end if defined?(Refinery::User)

if defined?(Refinery::Page) and !Refinery::Page.exists?(:link_url => '/blog')
page = Refinery::Page.create(
:title => "Blog",
:link_url => "/blog",
:deletable => false,
:menu_match => "^/blogs?(\/|\/.+?|)$"
)

Refinery::Pages.default_parts.each do |default_page_part|
page.parts.create(:title => default_page_part, :body => nil)
(Refinery.i18n_enabled? ? Refinery::I18n.frontend_locales : [:en]).each do |lang|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 2.1.x Refinery::I18n is a dependency of core so you don't need to check if i18n_enabled? anymore. You can simplify that line to:

Refinery::I18n.frontend_locales.each do |lang|

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails CI because Refinery doesn't know about i18n_enabled? anymore so the fix proposed by @ugisozols seems best.

I18n.locale = lang

Refinery::User.all.each do |user|
if user.plugins.where(:name => 'refinerycms_blog').blank?
user.plugins.create(:name => "refinerycms_blog",
:position => (user.plugins.maximum(:position) || -1) +1)
end
end if defined?(Refinery::User)

if defined?(Refinery::Page) and !Refinery::Page.exists?(:link_url => '/blog')
page = Refinery::Page.create(
:title => "Blog",
:link_url => "/blog",
:deletable => false,
:menu_match => "^/blogs?(\/|\/.+?|)$"
)

Refinery::Pages.default_parts.each do |default_page_part|
page.parts.create(:title => default_page_part, :body => nil)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here should come:
I18n.locale = I18n.default_locale
because we want clean up after us, don't we? :)

end
end