Module: TmlRails::ActionCommonMethods
- Defined in:
- lib/tml_rails/extensions/action_common_methods.rb
Instance Method Summary collapse
- #tml_application ⇒ Object
- #tml_current_language ⇒ Object
- #tml_current_locale ⇒ Object
- #tml_current_source ⇒ Object
- #tml_current_translator ⇒ Object
- #tml_current_user ⇒ Object
- #tml_default_locale ⇒ Object
- #tml_language_dir ⇒ Object
- #tml_postoffice ⇒ Object
-
#tml_session ⇒ Object
Common methods - wrappers.
- #tml_subdomain_locale_url(locale = tml_current_locale) ⇒ Object
- #tr(label, description = '', tokens = {}, options = {}) ⇒ Object
-
#trfe(label, desc = '', tokens = {}, options = {}) ⇒ Object
flash error.
-
#trfn(label, desc = '', tokens = {}, options = {}) ⇒ Object
flash notice.
-
#trfw(label, desc = '', tokens = {}, options = {}) ⇒ Object
flash warning.
-
#trl(label, description = '', tokens = {}, options = {}) ⇒ Object
for translating labels.
Instance Method Details
#tml_application ⇒ Object
79 80 81 |
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 79 def tml_application tml_session.application end |
#tml_current_language ⇒ Object
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_locale ⇒ Object
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_source ⇒ Object
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_translator ⇒ Object
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_user ⇒ Object
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_locale ⇒ Object
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_dir ⇒ Object
111 112 113 |
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 111 def tml_language_dir tml_current_language.dir end |
#tml_postoffice ⇒ Object
83 84 85 |
# File 'lib/tml_rails/extensions/action_common_methods.rb', line 83 def tml_postoffice Tml.postoffice end |
#tml_session ⇒ Object
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 = {}, = {}) params = Tml::Utils.normalize_tr_params(label, description, tokens, ) 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 = {}, = {}) flash[:trfe] = tr(Tml::Utils.normalize_tr_params(label, desc, tokens, )) 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 = {}, = {}) flash[:trfn] = tr(Tml::Utils.normalize_tr_params(label, desc, tokens, )) 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 = {}, = {}) flash[:trfw] = tr(Tml::Utils.normalize_tr_params(label, desc, tokens, )) 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 = {}, = {}) params = Tml::Utils.normalize_tr_params(label, description, tokens, ) params[:options][:skip_decorations] = true tr(params) end |