Default Locale
This commit is contained in:
parent
a3f1b8d54a
commit
fa857cfeea
|
@ -145,11 +145,14 @@ class ApplicationController < ActionController::Base
|
||||||
condition = VALID_LOCALES.include?(session[:locale])
|
condition = VALID_LOCALES.include?(session[:locale])
|
||||||
elsif session[:locale]
|
elsif session[:locale]
|
||||||
condition = @site.in_use_locales.include?(session[:locale])
|
condition = @site.in_use_locales.include?(session[:locale])
|
||||||
|
elsif @site.default_locale.present?
|
||||||
|
default_locale = @site.default_locale
|
||||||
|
condition = @site.valid_locales.include?(default_locale)
|
||||||
else
|
else
|
||||||
browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first rescue nil
|
browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first rescue nil
|
||||||
condition = @site.in_use_locales.include?(browser_locale)
|
condition = @site.in_use_locales.include?(browser_locale)
|
||||||
end
|
end
|
||||||
session[:locale] = condition ? (browser_locale || session[: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
|
I18n.locale = session[:locale].to_sym
|
||||||
@site_in_use_locales = site_locales_default_head(@site.in_use_locales)
|
@site_in_use_locales = site_locales_default_head(@site.in_use_locales)
|
||||||
@site_valid_locales = site_locales_default_head(@site.valid_locales)
|
@site_valid_locales = site_locales_default_head(@site.valid_locales)
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
class DesktopController< ApplicationController
|
class DesktopController< ApplicationController
|
||||||
layout 'desktop'
|
layout 'desktop'
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
before_filter :check_desktop_open, :only => [:index,:show]
|
||||||
|
|
||||||
#to load pages...
|
#to load pages...
|
||||||
|
|
||||||
|
# caches_page :index
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@desktop = current_user.desktop
|
@desktop = current_user.desktop
|
||||||
@currentusername = current_user.name
|
@currentusername = current_user.name
|
||||||
|
@ -336,6 +339,13 @@ class DesktopController< ApplicationController
|
||||||
render :json=>b.to_json
|
render :json=>b.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def check_desktop_open
|
||||||
|
if Me.desktop_closed && current_user.nil? #Need to be change
|
||||||
|
redirect_to '/admin/dashboards'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,12 +4,6 @@ class PagesController < ApplicationController
|
||||||
before_filter :check_frontend_open, :only => [:index,:show]
|
before_filter :check_frontend_open, :only => [:index,:show]
|
||||||
# caches_page :index
|
# caches_page :index
|
||||||
|
|
||||||
def check_frontend_open
|
|
||||||
if Me.frontend_closed and current_user.nil? #Need to be change
|
|
||||||
redirect_to '/admin/dashboards'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@item = Page.find_by_name('home')
|
@item = Page.find_by_name('home')
|
||||||
|
|
||||||
|
@ -118,6 +112,12 @@ class PagesController < ApplicationController
|
||||||
raise PageError,'Missing Frontend Page' if @item.nil?
|
raise PageError,'Missing Frontend Page' if @item.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_frontend_open
|
||||||
|
if Me.frontend_closed && current_user.nil? #Need to be change
|
||||||
|
redirect_to '/admin/dashboards'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def save_from_no_lang_for_page
|
def save_from_no_lang_for_page
|
||||||
if @item.nil? or !@item.enabled_for_lang(I18n.locale.to_s)
|
if @item.nil? or !@item.enabled_for_lang(I18n.locale.to_s)
|
||||||
flash[:error] = t('sys.module_page_lang_not_support')
|
flash[:error] = t('sys.module_page_lang_not_support')
|
||||||
|
|
|
@ -14,10 +14,12 @@ class Site
|
||||||
|
|
||||||
field :frontend_closed, :type => Boolean, :default => false
|
field :frontend_closed, :type => Boolean, :default => false
|
||||||
field :backend_openness_on, :type => Boolean, :default => false
|
field :backend_openness_on, :type => Boolean, :default => false
|
||||||
|
field :desktop_closed, :type => Boolean, :default => false
|
||||||
|
|
||||||
field :title_always_on, :type => Boolean, :default => false
|
field :title_always_on, :type => Boolean, :default => false
|
||||||
field :dashbroad_allow_visitor, :type => Boolean, :default => false
|
field :dashbroad_allow_visitor, :type => Boolean, :default => false
|
||||||
field :mail_settings, :type => Hash
|
field :mail_settings, :type => Hash
|
||||||
|
field :enabled_for, :type => Array, :default => nil
|
||||||
|
|
||||||
field :disk_space, :type => String
|
field :disk_space, :type => String
|
||||||
field :system_package_info, :type => Hash,:default=>{}
|
field :system_package_info, :type => Hash,:default=>{}
|
||||||
|
@ -34,6 +36,7 @@ class Site
|
||||||
field :sub_menu, localize: true
|
field :sub_menu, localize: true
|
||||||
field :terms_of_user, localize: true
|
field :terms_of_user, localize: true
|
||||||
field :google_analytics
|
field :google_analytics
|
||||||
|
field :default_locale
|
||||||
|
|
||||||
field :mobile_on, :type => Boolean, :default => false
|
field :mobile_on, :type => Boolean, :default => false
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted">Disable personal desktop</label>
|
<label class="control-label muted">Disable personal desktop</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="checkbox" class="toggle-check" data-disabled="true">
|
<%= f.check_box :desktop_open , :class=>"toggle-check" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -138,24 +138,29 @@
|
||||||
|
|
||||||
<!-- Language -->
|
<!-- Language -->
|
||||||
<div id="language-set" class="tab-pane fade">
|
<div id="language-set" class="tab-pane fade">
|
||||||
<div class="control-group">
|
<!-- <div class="control-group">
|
||||||
<label class="control-label muted">Enable User Language Detection</label>
|
<label class="control-label muted">Enable User Language Detection</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="checkbox" class="toggle-check" data-disabled="true">
|
<input type="checkbox" class="toggle-check" data-disabled="true">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted">Default Language</label>
|
<label class="control-label muted">Default Language</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="radio" name="def-lang" class="toggle-check" data-disabled="true" data-title="English" checked="checked">
|
<% @site_in_use_locales.each do |locale| %>
|
||||||
<input type="radio" name="def-lang" class="toggle-check" data-disabled="true" data-title="Chinese">
|
<%= check_box_tag :default_locale, locale, :class=>"toggle-check" %>
|
||||||
|
<%= I18nVariable.from_locale(locale) %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted">Enable Language</label>
|
<label class="control-label muted">Enable Language</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="checkbox" class="toggle-check" data-disabled="true" data-title="English">
|
<% @site_valid_locales.each do |valid_locale| %>
|
||||||
<input type="checkbox" class="toggle-check" data-disabled="true" data-title="Chinese">
|
<%= check_box_tag 'site[enabled_for][]', valid_locale, (@site.enabled_for.nil?), :class=>"toggle-check" %>
|
||||||
|
<%= I18nVariable.from_locale(valid_locale) %>
|
||||||
|
<% end %>
|
||||||
|
<%= hidden_field_tag 'site[enabled_for][]', '' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue