tr8n_core 4.0.5 → 4.0.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: 371fea5f20b7e2f8cfb06f4bda1515060fbb3ab6
4
- data.tar.gz: cf0ae840daf16a690b35243f5cb500b2f4c23548
3
+ metadata.gz: cb4ecbec7897fb75e2ed70e0490500b729ece962
4
+ data.tar.gz: 3ddd6b6eb884f695f599c4f7d1f78cfda744572d
5
5
  SHA512:
6
- metadata.gz: 1235999df54ca3cdcd5e959f1a4c71b6aeb92bae769da08bd3100f2654e81ce59cdbbf329000650edcf2e6dd78675e7e260e26f666048b26c3383f0720c3beb9
7
- data.tar.gz: af88480f1e4d56fbd6dad45503d33c99768581a0be32acb19e34abc08d49814c6e6ae5c62f2156859c2afbb12ead7c2ff9c4534393381a8d7ddceef7b84e177c
6
+ metadata.gz: 8451854a7e0a9e54fa0c7970f4e09f75f245cbeb4553cd13cc496a01a48134502cd977ac4ea00714401bddff5a25a7413d1440802b81792596a00c31dbcc17a2
7
+ data.tar.gz: 5fccf44ca8a07e364c81d0c63a091a510a5fc0710e26588f5652e02b36fbca4a986b40182ba6490165fdc6b629fb4bf53dcfbc5b03d21bd338492900fa02e2f2
@@ -171,6 +171,7 @@ class Tr8n::Application < Tr8n::Base
171
171
  next unless keys.values.any?
172
172
  params << {:source => source, :keys => keys.values.collect{|tkey| tkey.to_hash(:label, :description, :locale, :level)}}
173
173
  end
174
+
174
175
  api_client.post('source/register_keys', {:source_keys => params.to_json})
175
176
  @missing_keys_by_sources = nil
176
177
  end
data/lib/tr8n/config.rb CHANGED
@@ -309,6 +309,12 @@ module Tr8n
309
309
  default_tokens[format.to_sym][type.to_sym][token_name.to_sym]
310
310
  end
311
311
 
312
+ def set_default_token(token_name, value, type = :data, format = :html)
313
+ default_tokens[format.to_sym] ||= {}
314
+ default_tokens[format.to_sym][type.to_sym] ||= {}
315
+ default_tokens[format.to_sym][type.to_sym][token_name.to_sym] = value
316
+ end
317
+
312
318
  #########################################################
313
319
  ## Localization
314
320
  #########################################################
data/lib/tr8n/language.rb CHANGED
@@ -110,6 +110,7 @@ class Tr8n::Language < Tr8n::Base
110
110
  return label if label.tr8n_translated?
111
111
 
112
112
  params = Tr8n::Utils.normalize_tr_params(label, description, tokens, options)
113
+
113
114
  key_locale = hash_value(params[:options], :locale) || hash_value(Tr8n.session.block_options, :locale) || Tr8n.config.default_locale
114
115
  key_level = hash_value(params[:options], :level) || hash_value(Tr8n.session.block_options, :level) || Tr8n.config.default_level
115
116
 
@@ -126,7 +127,7 @@ class Tr8n::Language < Tr8n::Base
126
127
 
127
128
  params[:tokens].merge!(:viewing_user => Tr8n.session.current_user)
128
129
 
129
- if Tr8n.config.disabled? or locale == key_locale
130
+ if Tr8n.config.disabled? or self.locale == key_locale
130
131
  return temp_key.substitute_tokens(params[:label], params[:tokens], self, params[:options]).tr8n_translated
131
132
  end
132
133
 
@@ -136,15 +137,11 @@ class Tr8n::Language < Tr8n::Base
136
137
  end
137
138
 
138
139
  # no cache or translator is using inline mode - use service, otherwise load from cache
139
- if not Tr8n.config.cache[:enabled] or (Tr8n.session.current_translator and Tr8n.session.current_translator.inline?)
140
+ if Tr8n.config.disabled? or (Tr8n.session.current_translator and Tr8n.session.current_translator.inline?)
140
141
  return translate_from_service(temp_key, params[:tokens], params[:options]).tr8n_translated
141
142
  end
142
143
 
143
144
  translate_from_cache(temp_key, params[:tokens], params[:options]).tr8n_translated
144
- #rescue Exception => ex
145
- # Tr8n.logger.error("Failed to translate: #{params[:label]} : #{ex.message}")
146
- # Tr8n.logger.error(ex.backtrace)
147
- # params[:label]
148
145
  end
149
146
  alias :tr :translate
150
147
 
@@ -165,12 +165,12 @@ class Tr8n::Tokens::Transform < Tr8n::Tokens::Data
165
165
  object = self.class.token_object(context, key)
166
166
 
167
167
  unless object
168
- Tr8n::Logger.error("Missing value for a token \"#{key}\" in \"#{label}\"")
168
+ Tr8n.logger.error("Missing value for a token \"#{key}\" in \"#{label}\"")
169
169
  return label
170
170
  end
171
171
 
172
172
  if piped_params.empty?
173
- Tr8n::Logger.error("Piped params may not be empty for token \"#{key}\" in \"#{label}\"")
173
+ Tr8n.logger.error("Piped params may not be empty for token \"#{key}\" in \"#{label}\"")
174
174
  return label
175
175
  end
176
176
 
@@ -114,7 +114,7 @@ class Tr8n::TranslationKey < Tr8n::Base
114
114
  end
115
115
 
116
116
  def translate(language, token_values = {}, options = {})
117
- if Tr8n.config.disabled? or language.locale == self.attributes[:locale]
117
+ if Tr8n.config.disabled? or language.locale == self.locale
118
118
  return substitute_tokens(label, token_values, language, options.merge(:fallback => false))
119
119
  end
120
120
 
@@ -126,10 +126,8 @@ class Tr8n::TranslationKey < Tr8n::Base
126
126
  return decorator.decorate(translated_label, translation.language, language, self, options)
127
127
  end
128
128
 
129
- #Tr8n.logger.info("Translating: #{label}")
130
-
131
- translated_label = substitute_tokens(label, token_values, self.attributes[:language], options)
132
- decorator.decorate(translated_label, self.attributes[:language], language, self, options)
129
+ translated_label = substitute_tokens(label, token_values, self.language, options)
130
+ decorator.decorate(translated_label, self.language, language, self, options)
133
131
  end
134
132
 
135
133
  ###############################################################
@@ -23,5 +23,5 @@
23
23
 
24
24
 
25
25
  module Tr8nCore
26
- VERSION = "4.0.5"
26
+ VERSION = "4.0.6"
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tr8n_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.5
4
+ version: 4.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Berkovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-08 00:00:00.000000000 Z
11
+ date: 2014-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday