Updated with some locale fixes in site preferences
This commit is contained in:
parent
7b1b1fa2d3
commit
14fea3638f
|
@ -140,21 +140,23 @@ class ApplicationController < ActionController::Base
|
|||
# update session if passed
|
||||
session[:locale] = params[:locale] if params[:locale]
|
||||
browser_locale = condition = nil
|
||||
default_locale = @site.default_locale if @site.default_locale.present?
|
||||
# check if locale is valid for non site pages
|
||||
default_locale = condition = nil
|
||||
|
||||
# check if locale is valid for non site pages
|
||||
if LIST[:forbidden_item_names].include?(env['PATH_INFO'].split('/')[1].to_s)
|
||||
condition = VALID_LOCALES.include?(session[:locale])
|
||||
elsif session[:locale]
|
||||
condition = @site.in_use_locales.include?(session[:locale])
|
||||
#check if the default locale is present or not
|
||||
elsif @site.default_locale.present?
|
||||
default_locale = @site.default_locale
|
||||
condition = @site.valid_locales.include?(default_locale)
|
||||
else
|
||||
condition = @site.in_use_locales.include?(default_locale)
|
||||
elsif !@site.enable_language_detection
|
||||
#check enable langauge detection
|
||||
browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first rescue nil
|
||||
condition = @site.in_use_locales.include?(browser_locale)
|
||||
elsif session[:locale]
|
||||
condition = @site.in_use_locales.include?(session[:locale])
|
||||
end
|
||||
session[:locale] = condition ? ( browser_locale || session[:locale] || default_locale) : I18n.default_locale.to_s
|
||||
session[:locale] = condition ? (default_locale || browser_locale || session[:locale]) : I18n.default_locale.to_s
|
||||
I18n.locale = session[:locale].to_sym
|
||||
@site_in_use_locales = site_locales_default_head(@site.in_use_locales)
|
||||
@site_valid_locales = site_locales_default_head(@site.valid_locales)
|
||||
|
|
|
@ -7,6 +7,7 @@ class Site
|
|||
|
||||
field :in_use_locales, :type => Array
|
||||
field :valid_locales, :type => Array
|
||||
field :enable_locales, :type => Array
|
||||
|
||||
field :roaming_id
|
||||
field :private_key, :type => Binary
|
||||
|
@ -17,6 +18,7 @@ class Site
|
|||
field :desktop_closed, :type => Boolean, :default => false
|
||||
field :sitemap_menu_in_header, :type => Boolean, :default => false
|
||||
field :enable_terms_of_use, :type => Boolean, :default => false
|
||||
field :enable_language_detection, :type => Boolean, :default => false
|
||||
|
||||
field :title_always_on, :type => Boolean, :default => false
|
||||
field :dashbroad_allow_visitor, :type => Boolean, :default => false
|
||||
|
@ -44,6 +46,21 @@ class Site
|
|||
|
||||
belongs_to :design
|
||||
has_many :site_metas, :autosave => true, :dependent => :destroy
|
||||
validate :in_use_locales, :minimum_enabled_locales
|
||||
|
||||
def minimum_enabled_locales
|
||||
size = self.in_use_locales.length
|
||||
if size < 1
|
||||
errors.add(:size, "Needs at least one language in use")
|
||||
end
|
||||
end
|
||||
|
||||
def maximum_enabled_locales
|
||||
size = self.in_use_locales.length
|
||||
if size >= 2
|
||||
errors.add(:size, "Max 2 ")
|
||||
end
|
||||
end
|
||||
|
||||
def generate_keys
|
||||
private_key = OpenSSL::PKey::RSA.generate(2048)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<%= Rails.logger.info"@@@@@@@@@@@@@@@@"+design.inspect%>
|
||||
<tr class="with_action">
|
||||
<td class="span1"><%= check_box_tag 'to_delete[]', design.id, false, :class => "checkbox_in_list" %></td>
|
||||
<td class="span2">
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
<fieldset>
|
||||
|
||||
|
||||
<!-- Input Area -->
|
||||
<div class="input-area">
|
||||
<div class="nav-name"><strong>Classification</strong></div>
|
||||
|
@ -127,7 +126,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted">Disable personal desktop</label>
|
||||
<label class="control-label muted"><%= I18n.t('site.enable_personal_desktop')%></label>
|
||||
<div class="controls">
|
||||
<%= f.check_box :desktop_closed , :class=>"toggle-check" %>
|
||||
</div>
|
||||
|
@ -143,23 +142,29 @@
|
|||
<input type="checkbox" class="toggle-check" data-disabled="true">
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- Terms of Use -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted">Default Language</label>
|
||||
<label class="control-label muted">Enable User Language Detection
|
||||
</label>
|
||||
<div class="controls">
|
||||
<%= @site_in_use_locales %>
|
||||
<%= f.check_box :enable_language_detection, :class => "toggle-check" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<%= check_box_tag :default_locale, locale, (@site.enabled_for.nil?), :class=>"toggle-check" %>
|
||||
<%= I18nVariable.from_locale(locale) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted">Enable Language</label>
|
||||
<div class="controls">
|
||||
<% @site_valid_locales.each do |valid_locale| %>
|
||||
<%= check_box_tag "site[in_use_locales][]", locale, @site.valid_locales.include?(locale), :class=>"toggle-check" %>
|
||||
<%= I18nVariable.from_locale(valid_locale) %>
|
||||
<%= check_box_tag "site[enable_locales][]", locale, @site.valid_locales.include?(locale), :class=>"toggle-check", :data => { :title => "#{I18nVariable.from_locale(locale)}" } %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label muted">Default Language</label>
|
||||
<div class="controls">
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<%= check_box_tag :default_locale, locale, (@site.default_locale.nil?), :class=>"toggle-check", :data => { :title => "#{I18nVariable.from_locale(locale)}" } %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -21,11 +21,13 @@
|
|||
</li>
|
||||
|
||||
<!-- Desktop -->
|
||||
<% if !@site.desktop_closed%>
|
||||
<li id="orbit-desktop">
|
||||
<a href="<%= desktop_path %>" role="button">
|
||||
<i class="icons-screen"></i> <span class="hide"><%= t(:desktop) %></span>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
<% if @site.default_image.present?%>
|
||||
|
|
|
@ -391,6 +391,7 @@ en:
|
|||
footer_help: Footer Guide
|
||||
frontend_closed: Frontend Closed
|
||||
frontend_open: Frontend Open
|
||||
enable_personal_desktop: Enable Personal Desktop
|
||||
header: Site header
|
||||
info: Site information
|
||||
keywords: Site keywords
|
||||
|
|
|
@ -385,8 +385,9 @@ zh_tw:
|
|||
thumbnail: 縮圖
|
||||
site:
|
||||
frontend_closed: 前台關閉?
|
||||
frontend_open: 前台關閉 ?
|
||||
frontend_open: 開啟前台
|
||||
backend_openness_on: 開啟開放式後台(訪客可遊覽)
|
||||
enable_personal_desktop: 開啟個人桌面
|
||||
default_image: 預設圖像
|
||||
description: 網站描述
|
||||
description_help: 網站描述說明
|
||||
|
|
Loading…
Reference in New Issue