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 +4 -4
- data/lib/tr8n/application.rb +1 -0
- data/lib/tr8n/config.rb +6 -0
- data/lib/tr8n/language.rb +3 -6
- data/lib/tr8n/tokens/transform.rb +2 -2
- data/lib/tr8n/translation_key.rb +3 -5
- data/lib/tr8n_core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb4ecbec7897fb75e2ed70e0490500b729ece962
|
4
|
+
data.tar.gz: 3ddd6b6eb884f695f599c4f7d1f78cfda744572d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8451854a7e0a9e54fa0c7970f4e09f75f245cbeb4553cd13cc496a01a48134502cd977ac4ea00714401bddff5a25a7413d1440802b81792596a00c31dbcc17a2
|
7
|
+
data.tar.gz: 5fccf44ca8a07e364c81d0c63a091a510a5fc0710e26588f5652e02b36fbca4a986b40182ba6490165fdc6b629fb4bf53dcfbc5b03d21bd338492900fa02e2f2
|
data/lib/tr8n/application.rb
CHANGED
@@ -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
|
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
|
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
|
173
|
+
Tr8n.logger.error("Piped params may not be empty for token \"#{key}\" in \"#{label}\"")
|
174
174
|
return label
|
175
175
|
end
|
176
176
|
|
data/lib/tr8n/translation_key.rb
CHANGED
@@ -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.
|
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
|
-
|
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
|
###############################################################
|
data/lib/tr8n_core/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2014-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|