language stuff fixed

This commit is contained in:
Harry Bomrah 2015-05-01 16:48:49 +08:00
parent 9460619846
commit dd8574b8c3
3 changed files with 15 additions and 11 deletions

View File

@ -19,15 +19,19 @@ class ArchivesController < ApplicationController
"status-class" => "status-#{status['classname']}" "status-class" => "status-#{status['classname']}"
} }
end end
files = archive.archive_file_multiples.order_by(:sort_number=>'asc').collect do |file| files = []
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue "" archive.archive_file_multiples.order_by(:sort_number=>'asc').each do |file|
extension = file.file.file.extension.downcase rescue "" if file.choose_lang.include?(I18n.locale.to_s)
# url = file.file.url rescue "" title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
{ extension = file.file.file.extension.downcase rescue ""
"file-name" => title, # url = file.file.url rescue ""
"file-type" => extension, files << {
"file-url" => "/xhr/archive/download?file=#{file.id}" "file-name" => title,
} "file-type" => extension,
"file-url" => "/xhr/archive/download?file=#{file.id}"
}
end
end end
{ {

View File

@ -8,7 +8,7 @@ class ArchiveFileMultiple
field :file_title, localize: true field :file_title, localize: true
# field :description # field :description
field :download_count, type: Integer, default: 0 field :download_count, type: Integer, default: 0
field :choose_lang, :type => Array, :default => nil field :choose_lang, :type => Array, :default => ["en","zh_tw"]
field :should_destroy, :type => Boolean field :should_destroy, :type => Boolean
field :sort_number, :type => Integer field :sort_number, :type => Integer

View File

@ -41,7 +41,7 @@
<% @site_in_use_locales.each do |locale| %> <% @site_in_use_locales.each do |locale| %>
<li> <li>
<label class="checkbox"> <label class="checkbox">
<%= check_box_tag "archive_file[archive_file_multiples_attributes][#{( form_file.new_record? ? 'new_archive_file_multiples' : "#{i}" )}][choose_lang][]", locale, (form_file.choose_lang.nil? ? true : form_file.choose_lang.include?(locale)) %> <%= check_box_tag "archive_file[archive_file_multiples_attributes][#{( form_file.new_record? ? 'new_archive_file_multiples' : "#{i}" )}][choose_lang][]", locale, form_file.choose_lang.include?(locale.to_s) %>
<%= t(locale.to_s) %> <%= t(locale.to_s) %>
</label> </label>
</li> </li>