tml 5.2.4 → 5.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tml.rb +1 -1
- data/lib/tml/api/client.rb +2 -2
- data/lib/tml/api/post_office.rb +1 -1
- data/lib/tml/application.rb +16 -6
- data/lib/tml/base.rb +1 -1
- data/lib/tml/cache.rb +1 -1
- data/lib/tml/cache_adapters/file.rb +1 -1
- data/lib/tml/cache_adapters/memcache.rb +1 -1
- data/lib/tml/cache_adapters/redis.rb +1 -1
- data/lib/tml/config.rb +1 -1
- data/lib/tml/decorators/base.rb +1 -1
- data/lib/tml/decorators/default.rb +1 -1
- data/lib/tml/decorators/html.rb +1 -1
- data/lib/tml/decorators/json.rb +1 -1
- data/lib/tml/exception.rb +1 -1
- data/lib/tml/ext/array.rb +1 -1
- data/lib/tml/ext/date.rb +1 -1
- data/lib/tml/ext/fixnum.rb +1 -1
- data/lib/tml/ext/hash.rb +1 -1
- data/lib/tml/ext/string.rb +1 -1
- data/lib/tml/ext/time.rb +1 -1
- data/lib/tml/generators/base.rb +1 -1
- data/lib/tml/generators/file.rb +1 -1
- data/lib/tml/language.rb +15 -7
- data/lib/tml/language_case.rb +1 -1
- data/lib/tml/language_case_rule.rb +1 -1
- data/lib/tml/language_context.rb +1 -1
- data/lib/tml/language_context_rule.rb +1 -1
- data/lib/tml/logger.rb +1 -1
- data/lib/tml/rules_engine/evaluator.rb +1 -1
- data/lib/tml/rules_engine/parser.rb +1 -1
- data/lib/tml/session.rb +1 -1
- data/lib/tml/source.rb +18 -9
- data/lib/tml/tokenizers/data.rb +1 -1
- data/lib/tml/tokenizers/decoration.rb +1 -1
- data/lib/tml/tokenizers/dom.rb +1 -1
- data/lib/tml/tokens/data.rb +1 -1
- data/lib/tml/tokens/method.rb +1 -1
- data/lib/tml/tokens/transform.rb +1 -1
- data/lib/tml/translation.rb +1 -1
- data/lib/tml/translation_key.rb +1 -1
- data/lib/tml/translator.rb +1 -1
- data/lib/tml/utils.rb +1 -1
- data/lib/tml/version.rb +3 -2
- 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: ca7c1dfef205eefe379f774bc49de55d1eb50dcc
|
4
|
+
data.tar.gz: e9065037f9b73333ce3b6a704d378e9a3fbd9271
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c684706b6e54885793601d9e7ad722ee49605ab99162b3cc091e78a277ef5b9172b660c1bbc25f6a5a0ddc25bd4676bb7a718d8fc3df2614e148a2e0dd504d7
|
7
|
+
data.tar.gz: 40eb5e560cf0350a0bf061974e951762df90be62e90afba55597faac3884dea5181d538b2af8489ee78bac057d75282c30910ca7579ef56aeeedde2b7648ab09
|
data/lib/tml.rb
CHANGED
data/lib/tml/api/client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
#--
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2016 Translation Exchange, Inc
|
4
4
|
#
|
5
5
|
# _______ _ _ _ ______ _
|
6
6
|
# |__ __| | | | | (_) | ____| | |
|
@@ -267,7 +267,7 @@ class Tml::Api::Client < Tml::Base
|
|
267
267
|
|
268
268
|
def process_response(data, opts)
|
269
269
|
return nil if data.nil?
|
270
|
-
return data if opts[
|
270
|
+
return data if opts[:raw] or opts[:raw_json]
|
271
271
|
|
272
272
|
if data.is_a?(Hash) and data['results']
|
273
273
|
#Tml.logger.debug("received #{data['results'].size} result(s)")
|
data/lib/tml/api/post_office.rb
CHANGED
data/lib/tml/application.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
#--
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2016 Translation Exchange, Inc
|
4
4
|
#
|
5
5
|
# _______ _ _ _ ______ _
|
6
6
|
# |__ __| | | | | (_) | ____| | |
|
@@ -39,6 +39,7 @@ class Tml::Application < Tml::Base
|
|
39
39
|
|
40
40
|
attributes :host, :id, :key, :access_token, :name, :description, :threshold, :default_locale, :default_level, :tools
|
41
41
|
has_many :features, :languages, :languages_by_locale, :sources, :tokens, :css, :shortcuts, :translations, :extensions
|
42
|
+
has_many :ignored_keys
|
42
43
|
|
43
44
|
# Returns application cache key
|
44
45
|
def self.cache_key
|
@@ -66,7 +67,8 @@ class Tml::Application < Tml::Base
|
|
66
67
|
def fetch
|
67
68
|
data = api_client.get('projects/current/definition',{
|
68
69
|
locale: Tml.session.current_locale,
|
69
|
-
source: Tml.session.current_source
|
70
|
+
source: Tml.session.current_source,
|
71
|
+
ignored: true
|
70
72
|
}, {
|
71
73
|
cache_key: self.class.cache_key
|
72
74
|
})
|
@@ -125,7 +127,7 @@ class Tml::Application < Tml::Base
|
|
125
127
|
application: self,
|
126
128
|
source: source
|
127
129
|
)
|
128
|
-
self.sources[source].update_translations(source_locale, data
|
130
|
+
self.sources[source].update_translations(source_locale, data)
|
129
131
|
end
|
130
132
|
end
|
131
133
|
end
|
@@ -239,19 +241,27 @@ class Tml::Application < Tml::Base
|
|
239
241
|
@missing_keys_by_sources = nil
|
240
242
|
end
|
241
243
|
|
244
|
+
def ignored_key?(key)
|
245
|
+
return false if ignored_keys.nil?
|
246
|
+
not ignored_keys.index(key).nil?
|
247
|
+
end
|
248
|
+
|
242
249
|
def fetch_translations(locale)
|
243
250
|
self.translations ||= {}
|
244
251
|
self.translations[locale] ||= begin
|
245
252
|
results = Tml.cache.fetch(Tml::Application.translations_cache_key(locale)) do
|
246
253
|
data = {}
|
247
254
|
unless Tml.cache.read_only?
|
248
|
-
api_client.
|
249
|
-
data.merge!(translations)
|
250
|
-
end
|
255
|
+
data = api_client.get('projects/current/translations', :all => true, :ignored => true, :raw_json => true)
|
251
256
|
end
|
252
257
|
data
|
253
258
|
end
|
254
259
|
|
260
|
+
if results.is_a?(Hash) and results['results']
|
261
|
+
results = results['results']
|
262
|
+
self.ignored_keys = results['ignored_keys'] || []
|
263
|
+
end
|
264
|
+
|
255
265
|
translations_by_key = {}
|
256
266
|
results.each do |key, data|
|
257
267
|
translations_data = data.is_a?(Hash) ? data['translations'] : data
|
data/lib/tml/base.rb
CHANGED
data/lib/tml/cache.rb
CHANGED
data/lib/tml/config.rb
CHANGED
data/lib/tml/decorators/base.rb
CHANGED
data/lib/tml/decorators/html.rb
CHANGED
data/lib/tml/decorators/json.rb
CHANGED
data/lib/tml/exception.rb
CHANGED
data/lib/tml/ext/array.rb
CHANGED
data/lib/tml/ext/date.rb
CHANGED
data/lib/tml/ext/fixnum.rb
CHANGED
data/lib/tml/ext/hash.rb
CHANGED
data/lib/tml/ext/string.rb
CHANGED
data/lib/tml/ext/time.rb
CHANGED
data/lib/tml/generators/base.rb
CHANGED
data/lib/tml/generators/file.rb
CHANGED
data/lib/tml/language.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
#--
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2016 Translation Exchange, Inc
|
4
4
|
#
|
5
5
|
# _______ _ _ _ ______ _
|
6
6
|
# |__ __| | | | | (_) | ____| | |
|
@@ -130,6 +130,7 @@ class Tml::Language < Tml::Base
|
|
130
130
|
|
131
131
|
def translate(label, description = nil, tokens = {}, options = {})
|
132
132
|
params = Tml::Utils.normalize_tr_params(label, description, tokens, options)
|
133
|
+
return params[:label] if params[:label].to_s.strip == '' or params[:label].index('tml:label')
|
133
134
|
return params[:label] if params[:label].tml_translated?
|
134
135
|
|
135
136
|
translation_key = Tml::TranslationKey.new({
|
@@ -141,18 +142,19 @@ class Tml::Language < Tml::Base
|
|
141
142
|
:translations => []
|
142
143
|
})
|
143
144
|
|
145
|
+
# pp "Translating #{params[:label]} from: #{translation_key.locale.inspect} to #{locale.inspect}"
|
144
146
|
# Tml.logger.info("Translating #{params[:label]} from: #{translation_key.locale.inspect} to #{locale.inspect}")
|
145
147
|
|
146
148
|
params[:tokens] ||= {}
|
147
149
|
params[:tokens][:viewing_user] ||= Tml.session.current_user
|
148
150
|
|
149
151
|
if Tml.config.disabled? or application.nil?
|
150
|
-
return translation_key.substitute_tokens(
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
).tml_translated
|
152
|
+
return translation_key.substitute_tokens(params[:label], params[:tokens], self, params[:options]).tml_translated
|
153
|
+
end
|
154
|
+
|
155
|
+
# check if key was ignored on the application level
|
156
|
+
if application.ignored_key?(translation_key.key)
|
157
|
+
return translation_key.substitute_tokens(params[:label], params[:tokens], self, params[:options]).tml_translated
|
156
158
|
end
|
157
159
|
|
158
160
|
# if translations have already been cached in the application, use them
|
@@ -182,6 +184,12 @@ class Tml::Language < Tml::Base
|
|
182
184
|
# Tml.logger.debug("#{params[:label]} : #{source_key}")
|
183
185
|
|
184
186
|
source = application.source(source_key, locale)
|
187
|
+
|
188
|
+
# check if a key was ignored on the source level
|
189
|
+
if source.ignored_key?(translation_key.key)
|
190
|
+
return translation_key.substitute_tokens(params[:label], params[:tokens], self, params[:options]).tml_translated
|
191
|
+
end
|
192
|
+
|
185
193
|
cached_translations = source.cached_translations(locale, translation_key.key)
|
186
194
|
|
187
195
|
if cached_translations
|
data/lib/tml/language_case.rb
CHANGED
data/lib/tml/language_context.rb
CHANGED
data/lib/tml/logger.rb
CHANGED
data/lib/tml/session.rb
CHANGED
data/lib/tml/source.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
#--
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2016 Translation Exchange, Inc
|
4
4
|
#
|
5
5
|
# _______ _ _ _ ______ _
|
6
6
|
# |__ __| | | | | (_) | ____| | |
|
@@ -35,7 +35,7 @@ require 'digest/md5'
|
|
35
35
|
class Tml::Source < Tml::Base
|
36
36
|
belongs_to :application
|
37
37
|
attributes :key, :source, :url, :name, :description
|
38
|
-
has_many :translations
|
38
|
+
has_many :translations, :ignored_keys
|
39
39
|
|
40
40
|
def self.normalize(url)
|
41
41
|
return nil if url.nil? or url == ''
|
@@ -64,11 +64,19 @@ class Tml::Source < Tml::Base
|
|
64
64
|
self.key ||= Tml::Source.generate_key(attrs[:source])
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
67
|
+
def ignored_key?(key)
|
68
|
+
return false if ignored_keys.nil?
|
69
|
+
not ignored_keys.index(key).nil?
|
70
|
+
end
|
71
|
+
|
72
|
+
def update_translations(locale, data)
|
68
73
|
self.translations ||= {}
|
69
74
|
self.translations[locale] = {}
|
75
|
+
self.ignored_keys = data['ignored_keys'] || []
|
76
|
+
|
77
|
+
data = data['results'] if data.is_a?(Hash) and data['results']
|
70
78
|
|
71
|
-
|
79
|
+
data.each do |key, data|
|
72
80
|
translations_data = data.is_a?(Hash) ? data['translations'] : data
|
73
81
|
self.translations[locale][key] = translations_data.collect do |t|
|
74
82
|
Tml::Translation.new(
|
@@ -83,17 +91,18 @@ class Tml::Source < Tml::Base
|
|
83
91
|
|
84
92
|
def fetch_translations(locale)
|
85
93
|
self.translations ||= {}
|
94
|
+
return self if Tml.session.block_option(:dry)
|
86
95
|
return self if self.translations[locale]
|
87
96
|
|
88
97
|
# Tml.logger.debug("Fetching #{source}")
|
89
98
|
|
90
|
-
|
99
|
+
data = self.application.api_client.get(
|
91
100
|
"sources/#{self.key}/translations",
|
92
|
-
{:locale => locale, :
|
93
|
-
{:cache_key => Tml::Source.cache_key(locale, self.source)}
|
94
|
-
) ||
|
101
|
+
{:locale => locale, :all => true, :ignored => true},
|
102
|
+
{:cache_key => Tml::Source.cache_key(locale, self.source), :raw_json => true}
|
103
|
+
) || {}
|
95
104
|
|
96
|
-
update_translations(locale,
|
105
|
+
update_translations(locale, data)
|
97
106
|
|
98
107
|
self
|
99
108
|
rescue Tml::Exception => ex
|
data/lib/tml/tokenizers/data.rb
CHANGED
data/lib/tml/tokenizers/dom.rb
CHANGED
data/lib/tml/tokens/data.rb
CHANGED
data/lib/tml/tokens/method.rb
CHANGED
data/lib/tml/tokens/transform.rb
CHANGED
data/lib/tml/translation.rb
CHANGED
data/lib/tml/translation_key.rb
CHANGED
data/lib/tml/translator.rb
CHANGED
data/lib/tml/utils.rb
CHANGED
data/lib/tml/version.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
#--
|
2
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
|
3
4
|
#
|
4
5
|
# _______ _ _ _ ______ _
|
5
6
|
# |__ __| | | | | (_) | ____| | |
|
@@ -30,5 +31,5 @@
|
|
30
31
|
#++
|
31
32
|
|
32
33
|
module Tml
|
33
|
-
VERSION = '5.2.
|
34
|
+
VERSION = '5.2.5'
|
34
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Berkovich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|