Add language switching menu into global nav

This commit is contained in:
uu59 2014-05-28 14:47:14 +09:00
parent 9f5c100b0d
commit d18a57e6c9
4 changed files with 24 additions and 0 deletions

View File

@ -1,3 +1,5 @@
# coding: utf-8
module ApplicationHelper
def need_restart?
Plugin.gemfile_changed?
@ -35,6 +37,14 @@ module ApplicationHelper
%Q|<li><a><div>#{icon icon_class} <span>#{text}</span></div></a></li>|.html_safe
end
def language_name(locale)
# NOTE: these are fixed terms, not i18n-ed
{
en: "English",
ja: "日本語",
}[locale] || locale
end
def link_to_other(text, path)
if current_page?(path)
# NOTE: sb-admin set style for element name instead of class name, such as ".nav a". So use "a" element even if it isn't a link.

View File

@ -37,6 +37,18 @@
<!-- /.navbar-header -->
<ul class="nav navbar-top-links navbar-right">
<li class="dropdown">
<a class="dropdown-toggle " data-toggle="dropdown" href="#">
<%= t("terms.switch_language") %>
<%= icon("fa-caret-down") %>
</a>
<ul class="nav dropdown-menu dropdown-alerts">
<% I18n.available_locales.each do |locale| %>
<li><a href="?lang=<%= locale %>"><%= language_name locale %></a></li>
<% end %>
</ul>
<!-- /.dropdown-alerts -->
</li>
<li class="dropdown">
<a class="dropdown-toggle <%= "btn-info" if has_alert? %>" data-toggle="dropdown" href="#">
<i class="fa fa-bell fa-fw"></i> <i class="fa fa-caret-down"></i>

View File

@ -24,6 +24,7 @@ en:
new: New
setup: "Setup %{target}"
install_it: "Install %{target}"
switch_language: Switch Language
plugins:
common: &plugin_common

View File

@ -24,6 +24,7 @@ ja:
new: 新規作成
setup: "%{target}をセットアップ"
install_it: "%{target}をインストール"
switch_language: 言語切り替え
plugins:
common: &plugin_common