Sha256: ebd745912e3d133af85fa1e508975a351983e591a52bbaa618dc8c38d673ab93
Contents?: true
Size: 1008 Bytes
Versions: 3
Compression:
Stored size: 1008 Bytes
Contents
module CMS module LocaleHelper def cms_locale_selector if RailsAdminCMS::Config.hide_current_locale? links = [] else links = [ link_to(t('cms.locale_selector.language'), '#', class: 'active') ] end I18n.available_locales.reject{ |l| l == locale }.each do |locale| path = current_url_for(locale) links << link_to(t('cms.locale_selector.language', locale: locale), path) end content_tag(:ul, class: 'cms-locale-selector') do links.each do |link| concat content_tag(:li, link) end end end private def current_url_for(locale) url = case controller_path when /^cms\/(pages|forms)/ if @cms_view @cms_view.other_uuid(locale).try(:url) else main_app.try("#{params[:cms_view_type]}_#{locale}_path") end else url_for(:locale => locale.to_s) end url.presence || main_app.root_path(locale: locale) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rails_admin_cms-0.1.1 | app/helpers/cms/locale_helper.rb |
rails_admin_cms-0.0.9 | app/helpers/cms/locale_helper.rb |
rails_admin_cms-0.0.7 | app/helpers/cms/locale_helper.rb |