tr8n 3.0.3 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.3
1
+ 3.0.5
@@ -28,7 +28,6 @@
28
28
  <li><%=link_to("Tr8n Label Internationalization", "http://wiki.tr8n.org/index.php?title=Tr8n_Label_Internationalization")%></li>
29
29
  <li><%=link_to("Tr8n Rules Engine Configuration Guide", "http://wiki.tr8n.org/index.php?title=Tr8n_Rules_Engine_Configuration_Guide")%></li>
30
30
  </ul>
31
-
32
31
  </div>
33
32
 
34
33
  <% end %>
@@ -55,8 +55,10 @@ module ApplicationHelper
55
55
 
56
56
  # translation functions
57
57
  def tr(label, desc = "", tokens = {}, options = {})
58
- unless desc.nil? or desc.is_a?(String)
59
- raise Tr8n::Exception.new("The second parameter of the tr function must be a description")
58
+ if desc.is_a?(Hash)
59
+ options = desc
60
+ tokens = options[:tokens] || {}
61
+ desc = options[:context] || ""
60
62
  end
61
63
 
62
64
  begin
@@ -78,14 +78,10 @@ module Tr8n::ControllerMethods
78
78
 
79
79
  tr8n_current_user = nil
80
80
  if Tr8n::Config.site_user_info_enabled?
81
- if self.methods.include?(Tr8n::Config.current_user_method.to_sym)
82
- begin
83
- tr8n_current_user = eval(Tr8n::Config.current_user_method)
84
- tr8n_current_user = nil if tr8n_current_user.class.name != Tr8n::Config.user_class_name
85
- rescue Exception => ex
86
- raise Tr8n::Exception.new("Tr8n cannot be initialized because #{Tr8n::Config.current_user_method} failed with: #{ex.message}")
87
- end
88
- else
81
+ begin
82
+ tr8n_current_user = eval(Tr8n::Config.current_user_method)
83
+ tr8n_current_user = nil if tr8n_current_user.class.name != Tr8n::Config.user_class_name
84
+ rescue Exception => ex
89
85
  tr8n_current_user = Tr8n::Translator.new
90
86
  Tr8n::Logger.error("Site user integration is enabled, but #{Tr8n::Config.current_user_method} method is not defined")
91
87
  end
@@ -103,9 +99,19 @@ module Tr8n::ControllerMethods
103
99
  end
104
100
  end
105
101
 
102
+ ############################################################
103
+ # There are two ways to call the tr method
104
+ #
105
+ # tr(label, desc = "", tokens = {}, options = {})
106
+ # or
107
+ # tr(label, {:context => "", tokens => {}, ...})
108
+ ############################################################
109
+
106
110
  def tr(label, desc = "", tokens = {}, options = {})
107
- unless desc.nil? or desc.is_a?(String)
108
- raise Tr8n::Exception.new("The second parameter of the tr function must be a description")
111
+ if desc.is_a?(Hash)
112
+ options = desc
113
+ tokens = options[:tokens] || {}
114
+ desc = options[:context] || ""
109
115
  end
110
116
 
111
117
  begin
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tr8n
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 3
10
- version: 3.0.3
9
+ - 5
10
+ version: 3.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Berkovich
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-19 00:00:00 -07:00
18
+ date: 2011-06-22 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency