rake fixes for multilingual
This commit is contained in:
parent
e3cf299843
commit
2a5cc3e31c
|
@ -13,7 +13,7 @@ class AnnouncementLinkWidgetsController < ApplicationController
|
|||
"heading-links" => "Links"
|
||||
}
|
||||
}
|
||||
f = File.join(Rails.root, "public" , "announcement_link_widget.json")
|
||||
f = File.join(Rails.root, "public" , "announcement_link_widget_#{I18n.locale.to_s}.json")
|
||||
if File.exists?(f)
|
||||
contents = File.read(f)
|
||||
data = JSON.parse(contents)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
namespace :announcement_link_widget do
|
||||
desc "Combination of widgets"
|
||||
task :make_cache,[:url] => :environment do |task,args|
|
||||
announcement_app = ModuleApp.find_by_key("announcement")
|
||||
I18n.available_locales.each do |locale|
|
||||
OrbitHelper.set_site_locale locale
|
||||
announcement_app = ModuleApp.find_by_key("announcement")
|
||||
link_app = ModuleApp.find_by_key("web_resource")
|
||||
OrbitHelper.override_widget_module_app("announcement")
|
||||
link_app_tags = link_app.tags
|
||||
|
@ -20,7 +22,7 @@ namespace :announcement_link_widget do
|
|||
end
|
||||
common_tags_frontend = common_tags.collect do |ct|
|
||||
{
|
||||
"tag-name" => ct.name,
|
||||
"tag-name" => ct.name_translations[locale.to_s],
|
||||
"tag-id" => ct.name.downcase.gsub(" ", "_"),
|
||||
"announcements" => [],
|
||||
"links" => []
|
||||
|
@ -35,7 +37,7 @@ namespace :announcement_link_widget do
|
|||
name = t.name.downcase.gsub(" ", "_")
|
||||
index = common_tags_frontend.index{|t| t["tag-id"] == name}
|
||||
ctf = common_tags_frontend[index]
|
||||
ctf["announcements"] << {"title" => ann.title,"link"=>OrbitHelper.widget_item_url(ann.to_param)}
|
||||
ctf["announcements"] << {"title" => ann.title_translations[locale.to_s],"link"=>OrbitHelper.widget_item_url(ann.to_param)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -48,7 +50,7 @@ namespace :announcement_link_widget do
|
|||
name = t.name.downcase.gsub(" ", "_")
|
||||
index = common_tags_frontend.index{|t| t["tag-id"] == name}
|
||||
ctf = common_tags_frontend[index]
|
||||
ctf["links"] << {"title" => wl.title,"url" => wl.url}
|
||||
ctf["links"] << {"title" => wl.title_translations[locale.to_s],"url" => wl.url_translations[locale.to_s]}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -63,9 +65,10 @@ namespace :announcement_link_widget do
|
|||
"heading-links" => "Links"
|
||||
}
|
||||
}
|
||||
file = File.join(Rails.root, "public" , "announcement_link_widget.json")
|
||||
file = File.join(Rails.root, "public" , "announcement_link_widget_#{locale.to_s}.json")
|
||||
File.open(file,"w") do |f|
|
||||
f.write(@data.to_json)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue