Module: TmlRails::ActionCommonMethods

Defined in:
lib/tml_rails/extensions/action_common_methods.rb

Instance Method Summary collapse

Instance Method Details

#tml_applicationObject



79
80
81
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 79

def tml_application
  tml_session.application
end

#tml_current_languageObject



103
104
105
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 103

def tml_current_language
  tml_session.current_language
end

#tml_current_localeObject



99
100
101
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 99

def tml_current_locale
  tml_session.current_language.locale
end

#tml_current_sourceObject



107
108
109
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 107

def tml_current_source
  tml_session.current_source
end

#tml_current_translatorObject



91
92
93
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 91

def tml_current_translator
  tml_session.current_translator
end

#tml_current_userObject



87
88
89
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 87

def tml_current_user
  tml_session.current_user
end

#tml_default_localeObject



95
96
97
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 95

def tml_default_locale
  tml_session.application.default_locale
end

#tml_language_dirObject



111
112
113
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 111

def tml_language_dir
  tml_current_language.dir
end

#tml_postofficeObject



83
84
85
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 83

def tml_postoffice
  Tml.postoffice
end

#tml_sessionObject

Common methods - wrappers



75
76
77
# 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) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
# 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 = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# 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 = {}) ⇒ Object

flash error



62
63
64
# 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 = {}) ⇒ Object

flash notice



57
58
59
# 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 = {}) ⇒ Object

flash warning



67
68
69
# 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 = {}) ⇒ Object

for translating labels



50
51
52
53
54
# 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