Default Locale
This commit is contained in:
1 parent
a3f1b8d54a
commit
fa857cfeea
5 files changed
+36
-15
No files matched your search
@@ -145,11 +145,14 @@ class ApplicationController < ActionController::Base
|
||||
condition = VALID_LOCALES.include?(session[:locale])
|
||||
elsif 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
|
||||
browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first rescue nil
|
||||
condition = @site.in_use_locales.include?(browser_locale)
|
||||
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
|
||||
@site_in_use_locales = site_locales_default_head(@site.in_use_locales)
|
||||
@site_valid_locales = site_locales_default_head(@site.valid_locales)
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
class DesktopController< ApplicationController
|
||||
layout 'desktop'
|
||||
before_filter :authenticate_user!
|
||||
before_filter :check_desktop_open, :only => [:index,:show]
|
||||
|
||||
#to load pages...
|
||||
|
||||
|
||||
# caches_page :index
|
||||
|
||||
def index
|
||||
@desktop = current_user.desktop
|
||||
@currentusername = current_user.name
|
||||
@@ -335,7 +338,14 @@ class DesktopController< ApplicationController
|
||||
b = {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_desktop_open
|
||||
if Me.desktop_closed && current_user.nil? #Need to be change
|
||||
redirect_to '/admin/dashboards'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -4,12 +4,6 @@ class PagesController < ApplicationController
|
||||
before_filter :check_frontend_open, :only => [:index,:show]
|
||||
# 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
|
||||
@item = Page.find_by_name('home')
|
||||
|
||||
@@ -117,6 +111,12 @@ class PagesController < ApplicationController
|
||||
end
|
||||
raise PageError,'Missing Frontend Page' if @item.nil?
|
||||
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
|
||||
if @item.nil? or !@item.enabled_for_lang(I18n.locale.to_s)
|
||||
|
||||
Reference in new issue
Block a user