Force english only

This commit is contained in:
chris 2013-07-18 22:37:35 +08:00
parent 09bb318d6a
commit 6b883f050f
3 changed files with 15 additions and 22 deletions

View File

@ -137,19 +137,20 @@ class ApplicationController < ActionController::Base
# Set I18n.locale
def set_locale
# update session if passed
session[:locale] = params[:locale] if params[:locale]
browser_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])
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
# # update session if passed
# session[:locale] = params[:locale] if params[:locale]
# browser_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])
# 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] = 'en'
I18n.locale = session[:locale].to_sym
end

View File

@ -35,14 +35,6 @@
<%= text_field_tag 'q','',{:class => "search-query span3",:placeholder=> t(:search_google) ,:disabled=> ((@site.search["sitesearch"] || @site.search["domains"] ).blank? rescue true)}%>
</form>
</li>
<li class="dropdown language">
<a class="dropdown-toggle orbit-bar-language" href="#" data-toggle="dropdown" data-icons="&#xe054;"></a>
<ul class="dropdown-menu language-menu">
<% @site_in_use_locales.compact.each do |locale| %>
<%= content_tag :li, (link_to t(:_locale, :locale => locale), add_locale(remove_locale((referer rescue request.fullpath)), locale)), :class => (I18n.locale.eql?(locale.to_sym) ? 'active' : nil) %>
<% end %>
</ul>
</li>
<% if user_signed_in? %>
<li class="dropdown active">
<a class="orbit-bar-account" href="#" data-toggle="dropdown">

View File

@ -54,7 +54,7 @@ module Orbit
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.i18n.load_path += Dir[Rails.root.join('vendor', 'built_in_modules', '*', 'config', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :zh_tw
config.i18n.default_locale = :en
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)