language switch for orbit bar can be enabled or disabled from backend.

This commit is contained in:
Harry Bomrah 2015-06-24 18:00:09 +08:00
parent 94f1de8de9
commit 4068d8488a
5 changed files with 35 additions and 20 deletions

View File

@ -25,6 +25,7 @@ class Site
field :enable_language_detection, :type => Boolean, :default => false
field :enable_redirect_index, :type => Boolean, :default => false
field :enable_zh_cn, :type => Boolean, :default => true
field :enable_language_options, :type => Boolean, :default => true
field :default_locale, :default => "zh_tw"
field :mobile_on, :type => Boolean, :default => false
field :announcement_category, :type => Array, :default=>[]

View File

@ -193,6 +193,14 @@
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('preferences.enable_language_options') %>
</label>
<div class="controls">
<%= f.check_box :enable_language_options, :class => "toggle-check", data: {disabled: true} %>
</div>
</div>
</div>
<!-- OrbitBar Them -->

View File

@ -116,30 +116,34 @@
</li>
<% end %>
<li>
<% if @site_in_use_locales.count > 1 || current_site.enable_zh_cn %>
<% locale = session[:zh_cn] ? :zh_cn : I18n.locale %>
<span id="language"><i class="icons-earth orbit-bar-language-icon"></i><span class="orbit-bar-language-text">Language</span></span>
<ul>
<% @site_in_use_locales.each do |l| %>
<% if l.to_s == I18n.locale.to_s and !session['zh_cn'] %>
<li class="<%= (l == I18n.locale and !session['zh_cn']) ? "active" : "" %>">
<%= t((l==:zh_tw ? :zh_tw_ : :_locale ), :locale => l) %>
</li>
<% else %>
<li class="<%= (l == I18n.locale and !session['zh_cn']) ? "active" : "" %>">
<a href="<%= switch_language(l) %>"><%= t((l==:zh_tw ? :zh_tw_ : :_locale ), :locale => l) %></a>
</li>
<% end %>
<% if current_site.enable_zh_cn and l == :zh_tw and !request.path.include?("/admin/") %>
<% if locale == :zh_cn %>
<li class="active">
<%= t(:zh_cn, :locale => :zh_tw) %>
<% if current_site.enable_language_options %>
<% if @site_in_use_locales.count > 1 || current_site.enable_zh_cn %>
<% zh_cn_added = 0 %>
<% locale = session[:zh_cn] ? :zh_cn : I18n.locale %>
<span id="language"><i class="icons-earth orbit-bar-language-icon"></i><span class="orbit-bar-language-text">Language</span></span>
<ul>
<% @site_in_use_locales.each do |l| %>
<% if l.to_s == I18n.locale.to_s and !session['zh_cn'] %>
<li class="<%= (l == I18n.locale and !session['zh_cn']) ? "active" : "" %>">
<%= t((l==:zh_tw ? :zh_tw_ : :_locale ), :locale => l) %>
</li>
<% else %>
<li>
<a href="<%= switch_language(:zh_cn) %>"><%= t(:zh_cn, :locale => :zh_tw) %></a>
<li class="<%= (l == I18n.locale and !session['zh_cn']) ? "active" : "" %>">
<a href="<%= switch_language(l) %>"><%= t((l==:zh_tw ? :zh_tw_ : :_locale ), :locale => l) %></a>
</li>
<% end %>
<% if current_site.enable_zh_cn and zh_cn_added == 0 and !request.path.include?("/admin/") %>
<% zh_cn_added = 1 %>
<% if locale == :zh_cn %>
<li class="active">
<%= t(:zh_cn, :locale => :zh_tw) %>
</li>
<% else %>
<li>
<a href="<%= switch_language(:zh_cn) %>"><%= t(:zh_cn, :locale => :zh_tw) %></a>
</li>
<% end %>
<% end %>
<% end %>
<% end %>
</ul>

View File

@ -412,6 +412,7 @@ en:
preferences:
backend_open: All users can visit backend pages
change: Change
enable_language_options: Enable language option on OrbitBar
classification: Classification
frontend_open: "If Checked, the frontend will be open for all users."
favicon: Favicon

View File

@ -422,6 +422,7 @@ zh_tw:
preference: 系統偏好
preferences:
backend_open: 開啟後台給所有使用者
enable_language_options: 在OrbitBar上打開語系選擇
change: 更改
classification: 類別
enable_zh_cn: 開啟簡體中文