Module: Controllers::ContentLocalizable

Extended by:
ActiveSupport::Concern
Included in:
CatalogItemsController, ItemsController, ProductLinesController, ProductSpecificationsController
Defined in:
app/concerns/controllers/content_localizable.rb

Overview

This concern assists with content/mobility localization vs interface
localization, since this concern is purely CRM, I chosed to separate it
in its own concern for now - CB
This code is largely copied from lokalize example: https://www.youtube.com/watch?v=2Fyg-22iA9I

Instance Method Summary collapse

Instance Method Details

#allow_content_locale_switchBoolean

Flags the controller to render the content-locale selector in the CRM menu.

Returns:

  • (Boolean)

    always true



36
37
38
39
# File 'app/concerns/controllers/content_localizable.rb', line 36

def allow_content_locale_switch
  # This variable will determine if we need to show a locale selector in the menu interface of crm
  @content_localizable = true
end

#default_url_optionsHash

Merges the current Mobility content locale into generated URLs.

Returns:

  • (Hash)

    URL options including +content_locale+



44
45
46
# File 'app/concerns/controllers/content_localizable.rb', line 44

def default_url_options
  super.merge(content_locale: Mobility.locale)
end

#set_content_localeSymbol

This is for UI editing and mobility

Returns:

  • (Symbol)

    the content locale now assigned to +Mobility.locale+



28
29
30
31
# File 'app/concerns/controllers/content_localizable.rb', line 28

def set_content_locale
  @content_locale = extract_locale(:content_locale) || I18n.default_locale
  Mobility.locale = @content_locale
end