tml-rails 4.3.5 → 4.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/i18n/backend/tml.rb +24 -1
- data/lib/tml_rails/extensions/action_controller_extension.rb +16 -12
- data/lib/tml_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31518cae75a56656469869252dc6393c4685f142
|
4
|
+
data.tar.gz: 99b866f3875844de045df3cdd2a2b9875c29d5a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63d6f040d7c11669c625a4f9c9eb97229f44c88eb1d780f16557c74375a0858deba3a884bedee6e6ae2ef23704ec0b6f0b84d132a8e36cb83353747b683fe6da
|
7
|
+
data.tar.gz: 0aca72492fd0871e46dbcd67dde9ce1394718c5312c2c316ce3c72bf48ee67b8c93d03a9eb1d25ed86bf83a613d116a0eb752626288df9aba3686a720160269d
|
data/lib/i18n/backend/tml.rb
CHANGED
@@ -31,6 +31,7 @@
|
|
31
31
|
|
32
32
|
require 'i18n/backend/base'
|
33
33
|
require 'tml'
|
34
|
+
require 'pp'
|
34
35
|
|
35
36
|
module I18n
|
36
37
|
module Backend
|
@@ -47,10 +48,32 @@ module I18n
|
|
47
48
|
application.locales
|
48
49
|
end
|
49
50
|
|
51
|
+
def translate(locale, key, options = {})
|
52
|
+
super(locale, key, options).html_safe
|
53
|
+
end
|
54
|
+
|
50
55
|
def lookup(locale, key, scope = [], options = {})
|
56
|
+
#pp ''
|
57
|
+
#pp [locale, key, scope, options]
|
58
|
+
|
51
59
|
default_key = super(application.default_locale, key, scope, options)
|
60
|
+
|
61
|
+
#pp default_key
|
62
|
+
|
52
63
|
default_key ||= key
|
53
|
-
|
64
|
+
if default_key.is_a?(String)
|
65
|
+
translated_key = default_key.gsub('%{', '{')
|
66
|
+
translated_key = application.language(locale.to_s).translate(translated_key, options, options)
|
67
|
+
elsif default_key.is_a?(Hash)
|
68
|
+
translated_key = {}
|
69
|
+
default_key.each do |key, value|
|
70
|
+
value = value.gsub('%{', '{')
|
71
|
+
translated_key[key] = application.language(locale.to_s).translate(value, options, options)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
#pp translated_key
|
76
|
+
translated_key
|
54
77
|
end
|
55
78
|
|
56
79
|
end
|
@@ -81,14 +81,6 @@ module TmlRails
|
|
81
81
|
not session[:tml_tools_disabled]
|
82
82
|
end
|
83
83
|
|
84
|
-
def tml_locale
|
85
|
-
self.send(Tml.config.current_locale_method) if Tml.config.current_locale_method
|
86
|
-
rescue
|
87
|
-
session[:locale] = tml_user_preferred_locale unless session[:locale]
|
88
|
-
session[:locale] = params[:locale] if params[:locale]
|
89
|
-
session[:locale] || Tml.config.default_locale
|
90
|
-
end
|
91
|
-
|
92
84
|
def tml_init_client_sdk
|
93
85
|
return if Tml.config.disabled?
|
94
86
|
|
@@ -112,10 +104,22 @@ module TmlRails
|
|
112
104
|
end
|
113
105
|
end
|
114
106
|
|
115
|
-
if
|
116
|
-
|
117
|
-
|
118
|
-
|
107
|
+
if Tml.config.current_locale_method
|
108
|
+
begin
|
109
|
+
tml_session_params.merge!(:locale => self.send(Tml.config.current_locale_method))
|
110
|
+
rescue
|
111
|
+
# Tml.logger.error('Current locale method is specified but not provided')
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
unless tml_session_params[:locale]
|
116
|
+
if tml_tools_enabled? # gets translator and locale from the cookie
|
117
|
+
tml_session_params.merge!(:cookies => request.cookies)
|
118
|
+
else
|
119
|
+
session[:locale] = tml_user_preferred_locale unless session[:locale]
|
120
|
+
session[:locale] = params[:locale] if params[:locale]
|
121
|
+
tml_session_params.merge!(:locale => session[:locale] || Tml.config.default_locale)
|
122
|
+
end
|
119
123
|
end
|
120
124
|
|
121
125
|
Tml.session.init(tml_session_params)
|
data/lib/tml_rails/version.rb
CHANGED