Full localization implementation
This commit is contained in:
@@ -109,4 +109,20 @@ module ApplicationHelper
|
||||
end
|
||||
end
|
||||
|
||||
def page_path(record)
|
||||
str = case record
|
||||
when Page then record.name
|
||||
else record
|
||||
end
|
||||
go_to_path(str, locale: I18n.locale)
|
||||
end
|
||||
|
||||
def find_page(name)
|
||||
Page.find_by_name_and_locale(name, I18n.locale)
|
||||
end
|
||||
|
||||
def locale_root_path
|
||||
I18n.locale == I18n.default_locale ? '/' : "/#{I18n.locale}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
span.icon-bar
|
||||
|
||||
ul.nav
|
||||
li[class=(current_page?(controller: '/pages', action: 'home') ? :active : nil)]= link_to t('menu.home'), root_path
|
||||
li[class=(current_page?(controller: '/pages', action: 'show', name: 'about') ? :active : nil)]= link_to t('menu.about'), page_path('about')
|
||||
li[class=(current_page?(controller: '/pages', action: 'home') ? :active : nil)]= link_to find_page('home').try(:menu_text), locale_root_path
|
||||
li[class=(current_page?(controller: '/pages', action: 'show', name: 'about') ? :active : nil)]= link_to find_page('about').try(:menu_text), page_path('about')
|
||||
.nav-collapse.collapse
|
||||
ul.nav
|
||||
- Page.top_menu.each do |page|
|
||||
|
||||
Reference in New Issue
Block a user