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

View File

@ -8,7 +8,7 @@ class ArchiveFileMultiple
field :file_title, localize: true
# field :description
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 :sort_number, :type => Integer

View File

@ -41,7 +41,7 @@
<% @site_in_use_locales.each do |locale| %>
<li>
<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) %>
</label>
</li>