Sha256: 855b58f85bb0c4c92787094f4308ca172196a24e159490673f5e8be438110fb2
Contents?: true
Size: 1.13 KB
Versions: 14
Compression:
Stored size: 1.13 KB
Contents
module Enjoy::Localizeable extend ActiveSupport::Concern included do before_filter do I18n.locale = params[:locale] || I18n.default_locale Settings.ns_default = "main_#{I18n.locale}" Settings.ns_fallback = "main" end end private def default_url_options(options={}) {locale: params[:locale]} end def nav_get_menu_items(type) pages = menu_class.find(type.to_s).pages.enabled if Enjoy.mongoid? pages = pages.where(:"name.#{I18n.locale}".exists => true) elsif Enjoy.active_record? pages = pages.where(["EXIST(name_translations, ?) = TRUE AND name_translations -> ? != ''", I18n.locale, I18n.locale]) end pages.sorted.to_a end def nav_get_url(item) (params[:locale].blank? ? "" : "/#{params[:locale]}") + (item.redirect.blank? ? item.fullpath : item.redirect) end def find_seo_extra(path) page_class.enabled.where(fullpath: path.gsub(/(\/ru|\/en)/, "")).first end def page_class_name "Enjoy::Page" end def page_class page_class_name.constantize end def menu_class_name "Enjoy::Menu" end def menu_class menu_class_name.constantize end end
Version data entries
14 entries across 14 versions & 1 rubygems