lib/tr8n/extensions/action_controller_extension.rb in tr8n-3.1.8 vs lib/tr8n/extensions/action_controller_extension.rb in tr8n-3.2.0
- old
+ new
@@ -1,7 +1,7 @@
#--
-# Copyright (c) 2010-2011 Michael Berkovich
+# Copyright (c) 2010-2012 Michael Berkovich, tr8n.net
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
@@ -84,13 +84,11 @@
user = Tr8n::Translator.find_by_id(session[:tr8n_translator_id]) if session[:tr8n_translator_id]
user ||= Tr8n::Translator.new
return user
end
- user = eval(Tr8n::Config.current_user_method)
- user = nil if user.class.name != Tr8n::Config.user_class_name
- user
+ eval(Tr8n::Config.current_user_method)
rescue
Tr8n::Logger.error("Site user integration is enabled, but #{Tr8n::Config.current_user_method} method is not defined")
Tr8n::Translator.new
end
@@ -113,9 +111,12 @@
# tr(label, desc = "", tokens = {}, options = {})
# or
# tr(label, {:desc => "", tokens => {}, ...})
############################################################
def tr(label, desc = "", tokens = {}, options = {})
+
+ return label if label.tr8n_translated?
+
if desc.is_a?(Hash)
options = desc
tokens = options[:tokens] || {}
desc = options[:desc] || ""
end