Sha256: e96de77bf5707ef0b0e3bb2d7f9d90ae5230d1ab3272b0787b3fb22ad8e11665
Contents?: true
Size: 1.92 KB
Versions: 4
Compression:
Stored size: 1.92 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) _connectable = item.connectable if _connectable and _connectable.enabled begin _routes_namespace = _connectable.respond_to?(:routes_namespace) ? _connectable.routes_namespace : :main_app _url = send(_routes_namespace.to_sym).url_for([_connectable, {only_path: true}]) rescue Exception => exception Rails.logger.error exception.message Rails.logger.error exception.backtrace.join("\n") puts exception.message puts exception.backtrace.join("\n") capture_exception(exception) if respond_to?(:capture_exception) _url = item.redirect.blank? ? item.fullpath : item.redirect end else _url = item.redirect.blank? ? item.fullpath : item.redirect end (params[:locale].blank? ? "" : "/#{params[:locale]}") + _url end def find_seo_extra(path) _localizable_regexp = Regexp.new("^(#{I18n.available_locales.map { |l| "\\/#{l}"}.join("|")})") page_class.enabled.where(fullpath: path.sub(_localizable_regexp, "")).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
4 entries across 4 versions & 1 rubygems