module TmlRails::ActionCommonMethods

Public Instance Methods

tml_application() click to toggle source
# File lib/tml_rails/extensions/action_common_methods.rb, line 79
def tml_application
  tml_session.application
end
tml_current_language() click to toggle source
# File lib/tml_rails/extensions/action_common_methods.rb, line 103
def tml_current_language
  tml_session.current_language
end
tml_current_locale() click to toggle source
# File lib/tml_rails/extensions/action_common_methods.rb, line 99
def tml_current_locale
  tml_session.current_language.locale
end
tml_current_source() click to toggle source
# File lib/tml_rails/extensions/action_common_methods.rb, line 107
def tml_current_source
  tml_session.current_source
end
tml_current_translator() click to toggle source
# File lib/tml_rails/extensions/action_common_methods.rb, line 91
def tml_current_translator
  tml_session.current_translator
end
tml_current_user() click to toggle source
# File lib/tml_rails/extensions/action_common_methods.rb, line 87
def tml_current_user
  tml_session.current_user
end
tml_default_locale() click to toggle source
# File lib/tml_rails/extensions/action_common_methods.rb, line 95
def tml_default_locale
  tml_session.application.default_locale
end
tml_language_dir() click to toggle source
# File lib/tml_rails/extensions/action_common_methods.rb, line 111
def tml_language_dir
  tml_current_language.dir
end
tml_postoffice() click to toggle source
# File lib/tml_rails/extensions/action_common_methods.rb, line 83
def tml_postoffice
  Tml.postoffice
end
tml_session() click to toggle source

Common methods - wrappers

# File lib/tml_rails/extensions/action_common_methods.rb, line 75
def tml_session
  Tml.session
end
tml_subdomain_locale_url(locale = tml_current_locale) click to toggle source
# File lib/tml_rails/extensions/action_common_methods.rb, line 115
def tml_subdomain_locale_url(locale = tml_current_locale)
  uri = URI::parse(request.url)
  host = uri.host.split('.')
  if host.count == 2
    host.unshift(locale)
  else
    host[0] = locale
  end
  uri.host = host.join('.')
  uri.to_s
end
tr(label, description = '', tokens = {}, options = {}) click to toggle source
# File lib/tml_rails/extensions/action_common_methods.rb, line 35
def tr(label, description = '', tokens = {}, options = {})
  params = Tml::Utils.normalize_tr_params(label, description, tokens, options)
  return params[:label].html_safe if params[:label].tml_translated?

  params[:options][:caller] = caller(1, 1)

  if request
    params[:options][:url]  = request.url
    params[:options][:host] = request.env['HTTP_HOST']
  end

  Tml.translate(params)
end
trfe(label, desc = '', tokens = {}, options = {}) click to toggle source

flash error

# File lib/tml_rails/extensions/action_common_methods.rb, line 62
def trfe(label, desc = '', tokens = {}, options = {})
  flash[:trfe] = tr(Tml::Utils.normalize_tr_params(label, desc, tokens, options))
end
trfn(label, desc = '', tokens = {}, options = {}) click to toggle source

flash notice

# File lib/tml_rails/extensions/action_common_methods.rb, line 57
def trfn(label, desc = '', tokens = {}, options = {})
  flash[:trfn] = tr(Tml::Utils.normalize_tr_params(label, desc, tokens, options))
end
trfw(label, desc = '', tokens = {}, options = {}) click to toggle source

flash warning

# File lib/tml_rails/extensions/action_common_methods.rb, line 67
def trfw(label, desc = '', tokens = {}, options = {})
  flash[:trfw] = tr(Tml::Utils.normalize_tr_params(label, desc, tokens, options))
end
trl(label, description = '', tokens = {}, options = {}) click to toggle source

for translating labels

# File lib/tml_rails/extensions/action_common_methods.rb, line 50
def trl(label, description = '', tokens = {}, options = {})
  params = Tml::Utils.normalize_tr_params(label, description, tokens, options)
  params[:options][:skip_decorations] = true
  tr(params)
end