Remove i18n_variable for controllers, helpers and models
This commit is contained in:
1 parent
327996a7b0
commit
49dd3a1770
16 files changed
+196
-103
No files matched your search
+172
-4
@@ -145,7 +145,7 @@ namespace :migrate do
|
||||
p '====================================================='
|
||||
|
||||
p 'Start PageContext'
|
||||
page_contexts = PageContext.admin_manager_all
|
||||
page_contexts = PageContext.all
|
||||
i = 1
|
||||
page_contexts.each do |page_context|
|
||||
p "#{i}/#{page_contexts.size} - #{page_context.id}"
|
||||
@@ -160,12 +160,13 @@ namespace :migrate do
|
||||
p '====================================================='
|
||||
|
||||
p 'Start WebLink'
|
||||
links = WebLink.admin_manager_all
|
||||
links = WebLink.all
|
||||
i = 1
|
||||
links.each do |link|
|
||||
p "#{i}/#{links.size} - #{link.id}"
|
||||
name = I18nVariable.first(:conditions => {:key => 'name', :language_value_id => link.id, :language_value_type => link.class})
|
||||
link.name_translations = {'en' => name['en'], 'zh_tw' => name['zh_tw']} if name
|
||||
# the original key was 'name'
|
||||
title = I18nVariable.first(:conditions => {:key => 'name', :language_value_id => link.id, :language_value_type => link.class})
|
||||
link.name_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
context = I18nVariable.first(:conditions => {:key => 'context', :language_value_id => link.id, :language_value_type => link.class})
|
||||
link.context_translations = {'en' => context['en'], 'zh_tw' => context['zh_tw']} if context
|
||||
link.save(:validate => false)
|
||||
@@ -187,6 +188,173 @@ namespace :migrate do
|
||||
end
|
||||
p 'End WebLinkCategory'
|
||||
|
||||
p '====================================================='
|
||||
p '====================================================='
|
||||
|
||||
p 'Start Meta'
|
||||
metas = Meta.all
|
||||
i = 1
|
||||
metas.each do |meta|
|
||||
p "#{i}/#{metas.size} - #{meta.id}"
|
||||
title = I18nVariable.first(:conditions => {:language_value_id => meta.id, :language_value_type => meta.class})
|
||||
meta.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
meta.save(:validate => false)
|
||||
i += 1
|
||||
end
|
||||
p 'End Meta'
|
||||
|
||||
p '====================================================='
|
||||
p '====================================================='
|
||||
|
||||
p 'Start Attribute'
|
||||
attributes = Attribute.all
|
||||
i = 1
|
||||
attributes.each do |attribute|
|
||||
p "#{i}/#{attributes.size} - #{attribute.id}"
|
||||
title = I18nVariable.first(:conditions => {:language_value_id => attribute.id, :language_value_type => attribute.class})
|
||||
attribute.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
attribute.save(:validate => false)
|
||||
i += 1
|
||||
end
|
||||
p 'End Attribute'
|
||||
|
||||
p '====================================================='
|
||||
|
||||
p 'Start AttributeField'
|
||||
attribute_fields = AttributeField.all
|
||||
i = 1
|
||||
attribute_fields.each do |attribute_field|
|
||||
p "#{i}/#{attribute_fields.size} - #{attribute_field.id}"
|
||||
title = I18nVariable.first(:conditions => {:language_value_id => attribute_field.id, :language_value_type => attribute_field.class})
|
||||
attribute_field.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
attribute_field.save(:validate => false)
|
||||
i += 1
|
||||
end
|
||||
p 'End AttributeField'
|
||||
|
||||
p '====================================================='
|
||||
|
||||
p 'Start Role'
|
||||
roles = Role.all
|
||||
i = 1
|
||||
roles.each do |role|
|
||||
p "#{i}/#{roles.size} - #{role.id}"
|
||||
title = I18nVariable.first(:conditions => {:language_value_id => role.id, :language_value_type => role.class})
|
||||
role.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
role.save(:validate => false)
|
||||
i += 1
|
||||
end
|
||||
p 'End Role'
|
||||
|
||||
p '====================================================='
|
||||
p '====================================================='
|
||||
|
||||
p 'Start AdImage'
|
||||
ad_images = AdImage.all
|
||||
i = 1
|
||||
ad_images.each do |image|
|
||||
p "#{i}/#{ad_images.size} - #{image.id}"
|
||||
# no key is set and title = context, this is due to original error in the code
|
||||
title = I18nVariable.first(:conditions => {:language_value_id => image.id, :language_value_type => image.class})
|
||||
image.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
image.context_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
image.save(:validate => false)
|
||||
i += 1
|
||||
end
|
||||
p 'End AdImage'
|
||||
|
||||
p '====================================================='
|
||||
p '====================================================='
|
||||
|
||||
p 'Start Asset'
|
||||
assets = Asset.all
|
||||
i = 1
|
||||
assets.each do |asset|
|
||||
p "#{i}/#{assets.size} - #{asset.id}"
|
||||
title = I18nVariable.first(:conditions => {:key => 'title', :language_value_id => asset.id, :language_value_type => asset.class})
|
||||
asset.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
description = I18nVariable.first(:conditions => {:key => 'description', :language_value_id => asset.id, :language_value_type => asset.class})
|
||||
asset.description_translations = {'en' => description['en'], 'zh_tw' => description['zh_tw']} if description
|
||||
asset.save(:validate => false)
|
||||
i += 1
|
||||
end
|
||||
p 'End Asset'
|
||||
|
||||
p '====================================================='
|
||||
|
||||
p 'Start AssetCategory'
|
||||
categories = AssetCategory.all
|
||||
i = 1
|
||||
categories.each do |category|
|
||||
p "#{i}/#{categories.size} - #{category.id}"
|
||||
title = I18nVariable.first(:conditions => {:language_value_id => category.id, :language_value_type => category.class})
|
||||
category.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
category.save(:validate => false)
|
||||
i += 1
|
||||
end
|
||||
p 'End AssetCategory'
|
||||
|
||||
p '====================================================='
|
||||
p '====================================================='
|
||||
|
||||
p 'Start Item'
|
||||
items = Item.all
|
||||
i = 1
|
||||
items.each do |item|
|
||||
p "#{i}/#{items.size} - #{item.id}"
|
||||
title = I18nVariable.first(:conditions => {:language_value_id => item.id, :language_value_type => item.class})
|
||||
item.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
item.save(:validate => false)
|
||||
i += 1
|
||||
end
|
||||
p 'End Item'
|
||||
|
||||
p '====================================================='
|
||||
|
||||
p 'Start Page'
|
||||
pages = Page.all
|
||||
i = 1
|
||||
pages.each do |item|
|
||||
p "#{i}/#{pages.size} - #{item.id}"
|
||||
# the key was originally 'title', changed to 'page_title' to avoit conflict with parent
|
||||
title = I18nVariable.first(:conditions => {:key => 'title', :language_value_id => item.id, :language_value_type => item.class})
|
||||
item.page_title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
item.save(:validate => false)
|
||||
i += 1
|
||||
end
|
||||
p 'End Page'
|
||||
|
||||
p '====================================================='
|
||||
|
||||
p 'Start PagePart'
|
||||
page_parts = PagePart.all
|
||||
i = 1
|
||||
page_parts.each do |part|
|
||||
p "#{i}/#{page_parts.size} - #{part.id}"
|
||||
title = I18nVariable.first(:conditions => {:key => 'title', :language_value_id => part.id, :language_value_type => part.class})
|
||||
part.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
content = I18nVariable.first(:conditions => {:key => 'i18n_variable', :language_value_id => part.id, :language_value_type => part.class})
|
||||
part.content_translations = {'en' => content['en'], 'zh_tw' => content['zh_tw']} if content
|
||||
part.save(:validate => false)
|
||||
i += 1
|
||||
end
|
||||
p 'End PagePart'
|
||||
|
||||
p '====================================================='
|
||||
p '====================================================='
|
||||
|
||||
p 'Start Site'
|
||||
site = Site.first
|
||||
title = I18nVariable.first(:conditions => {:key => 'title', :language_value_id => part.id, :language_value_type => part.class})
|
||||
site.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
|
||||
footer = I18nVariable.first(:conditions => {:key => 'footer', :language_value_id => site.id, :language_value_type => site.class})
|
||||
site.footer_translations = {'en' => footer['en'], 'zh_tw' => footer['zh_tw']} if footer
|
||||
sub_menu = I18nVariable.first(:conditions => {:key => 'sub_menu', :language_value_id => site.id, :language_value_type => site.class})
|
||||
site.sub_menu_translations = {'en' => sub_menu['en'], 'zh_tw' => sub_menu['zh_tw']} if sub_menu
|
||||
site.save(:validate => false)
|
||||
end
|
||||
p 'End Site'
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user