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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d7f5a9a456ca1ea9c40a7071fe7363242c95fe1
4
- data.tar.gz: d714d0fbb8069f74721cc0ed781d8fc7d50ad86e
3
+ metadata.gz: 31518cae75a56656469869252dc6393c4685f142
4
+ data.tar.gz: 99b866f3875844de045df3cdd2a2b9875c29d5a0
5
5
  SHA512:
6
- metadata.gz: 3974f5d3981a72d883ff8b62f7d26801cfe7e3bb66663ac48939b2ba4ce0f1309a15104b0009b6fad22a6007e04e79232af40f360afd197b4ef102efa0ae78c9
7
- data.tar.gz: 43c8b91a78091f2fc434d83e13ea37b2eb099f9b31f7a22b6e32c88d20e64d27e0c65fd86c9383f91c55756bd7df3f1cafd98f9e96553ae01d323657b77e25fc
6
+ metadata.gz: 63d6f040d7c11669c625a4f9c9eb97229f44c88eb1d780f16557c74375a0858deba3a884bedee6e6ae2ef23704ec0b6f0b84d132a8e36cb83353747b683fe6da
7
+ data.tar.gz: 0aca72492fd0871e46dbcd67dde9ce1394718c5312c2c316ce3c72bf48ee67b8c93d03a9eb1d25ed86bf83a613d116a0eb752626288df9aba3686a720160269d
@@ -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
- application.language(locale.to_s).translate(default_key)
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 tml_tools_enabled? # gets translator and locale from the cookie
116
- tml_session_params.merge!(:cookies => request.cookies)
117
- else # uses default locale
118
- tml_session_params.merge!(:locale => tml_locale)
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)
@@ -30,5 +30,5 @@
30
30
  #++
31
31
 
32
32
  module TmlRails
33
- VERSION = '4.3.5'
33
+ VERSION = '4.3.6'
34
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tml-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.5
4
+ version: 4.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Berkovich