Permalink
Browse files

Support multiple languages for seed data in extension and form genera…

…ted seeds file.
  • Loading branch information...
ugisozols committed May 25, 2012
1 parent 0179860 commit 33878c5bd2fe9598e6579309f307587e0c0c496c
@@ -1,23 +1,27 @@
-if defined?(::Refinery::User)
- ::Refinery::User.all.each do |user|
- if user.plugins.where(:name => 'refinerycms-<%= namespacing.underscore %>').blank?
- user.plugins.create(:name => 'refinerycms-<%= namespacing.underscore %>',
- :position => (user.plugins.maximum(:position) || -1) +1)
+Refinery::I18n.frontend_locales.each do |lang|
+ I18n.locale = lang
+
+ if defined?(Refinery::User)
+ Refinery::User.all.each do |user|
+ if user.plugins.where(:name => 'refinerycms-<%= namespacing.underscore %>').blank?
+ user.plugins.create(:name => 'refinerycms-<%= namespacing.underscore %>',
+ :position => (user.plugins.maximum(:position) || -1) +1)
+ end
end
end
-end
<% unless skip_frontend? -%>
-url = "/<%= [(namespacing.underscore if namespacing.underscore != plural_name), plural_name].compact.join('/') %>"
-if defined?(::Refinery::Page) && ::Refinery::Page.where(:link_url => url).empty?
- page = ::Refinery::Page.create(
- :title => '<%= class_name.pluralize.underscore.titleize %>',
- :link_url => url,
- :deletable => false,
- :menu_match => "^#{url}(\/|\/.+?|)$"
- )
- Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
- page.parts.create(:title => default_page_part, :body => nil, :position => index)
+ url = "/<%= [(namespacing.underscore if namespacing.underscore != plural_name), plural_name].compact.join('/') %>"
+ if defined?(Refinery::Page) && Refinery::Page.where(:link_url => url).empty?
+ page = Refinery::Page.create(
+ :title => '<%= class_name.pluralize.underscore.titleize %>',
+ :link_url => url,
+ :deletable => false,
+ :menu_match => "^#{url}(\/|\/.+?|)$"
+ )
+ Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
+ page.parts.create(:title => default_page_part, :body => nil, :position => index)
+ end
end
-end
<% end -%>
+end
@@ -1,27 +1,31 @@
-if defined?(::Refinery::User)
- ::Refinery::User.all.each do |user|
- if user.plugins.find_by_name('<%= plural_name %>').nil?
- user.plugins.create(:name => "<%= plural_name %>",
- :position => (user.plugins.maximum(:position) || -1) +1)
+Refinery::I18n.frontend_locales.each do |lang|
+ I18n.locale = lang
+
+ if defined?(Refinery::User)
+ Refinery::User.all.each do |user|
+ if user.plugins.find_by_name('<%= plural_name %>').nil?
+ user.plugins.create(:name => "<%= plural_name %>",
+ :position => (user.plugins.maximum(:position) || -1) +1)
+ end
end
end
-end
-if defined?(::Refinery::Page)
- page = ::Refinery::Page.create(
- :title => "<%= class_name.pluralize.underscore.titleize %>",
- :link_url => "/<%= plural_name %>/new",
- :deletable => false,
- :menu_match => "^/<%= plural_name %>(\/|\/.+?|)$"
- )
- thank_you_page = page.children.create(
- :title => "Thank You",
- :link_url => "/<%= plural_name %>/thank_you",
- :deletable => false,
- :show_in_menu => false
- )
- Refinery::Pages.default_parts.each do |default_page_part|
- page.parts.create(:title => default_page_part, :body => nil)
- thank_you_page.parts.create(:title => default_page_part, :body => nil)
+ if defined?(Refinery::Page)
+ page = Refinery::Page.create(
+ :title => "<%= class_name.pluralize.underscore.titleize %>",
+ :link_url => "/<%= plural_name %>/new",
+ :deletable => false,
+ :menu_match => "^/<%= plural_name %>(\/|\/.+?|)$"
+ )
+ thank_you_page = page.children.create(
+ :title => "Thank You",
+ :link_url => "/<%= plural_name %>/thank_you",
+ :deletable => false,
+ :show_in_menu => false
+ )
+ Refinery::Pages.default_parts.each do |default_page_part|
+ page.parts.create(:title => default_page_part, :body => nil)
+ thank_you_page.parts.create(:title => default_page_part, :body => nil)
+ end
end
end

0 comments on commit 33878c5

Please sign in to comment.