tml 5.5.3 → 5.5.4

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: e4de2f5184318d3d0719cfe5de0495ab6e91e9f1
4
- data.tar.gz: bf574f2c89a6a5d7b4da3c5e2e54eaa4fe0af6b1
3
+ metadata.gz: 01627bae72095f4b9e7ce0e7075321bf8c6354fa
4
+ data.tar.gz: a2a539378307191e667ce9624a9c4708c3904412
5
5
  SHA512:
6
- metadata.gz: c81dca25c0ca6304bf7f3a21eca7fba9c27715e47426d21e66bb4a06b5b8794825fe1d931ff29e0763f132374870675af24569702639244381fbe4bac2afe34f
7
- data.tar.gz: 3f6dfccc814f762f526759a5291090e02bef34a86d8f47401d5ffbbcedfc7963d7f23d847d6731992c158798894c67559facf5d1dc25d113d161b98e963e70ba
6
+ metadata.gz: 40bb60e7df1e3a58d41c5fd8eec56848c7290e553646701d1895c69b73c37f51481fbb3be1aa96973b869804f16838458e565a135e2578ee0fab08f4be140372
7
+ data.tar.gz: f469500ca7422f2f43e58f11b8184ebd832c2aeb6a501482d83c89bb0b1dd443132204676e70525f4bbca1180ce2161cd62a544a3a722b859a8859141c42da94
@@ -367,7 +367,7 @@ module Tml
367
367
  #end
368
368
 
369
369
  def default_locale
370
- @locale[:default]
370
+ @locale[:default] || 'en'
371
371
  end
372
372
 
373
373
  def default_language
@@ -290,9 +290,11 @@ module Tml
290
290
 
291
291
  ##############################################################################
292
292
  #
293
+ # Hashes are often used with JSON structures. We can be smart about how to pull default values.
294
+ #
293
295
  # examples:
294
296
  #
295
- # tr("Hello {user}", {:user => {:value => "Michael", :gender => :male}}}
297
+ # tr("Hello {user}", {:user => {:name => "Michael", :gender => :male}}}
296
298
  #
297
299
  # tr("Hello {user}", {:user => {:object => {:gender => :male}, :value => "Michael"}}}
298
300
  # tr("Hello {user}", {:user => {:object => {:name => "Michael", :gender => :male}, :property => :name}}}
@@ -306,6 +308,13 @@ module Tml
306
308
 
307
309
  def token_value_from_hash_param(hash, language, options)
308
310
  value = Tml::Utils.hash_value(hash, :value)
311
+ [:name, :first_name, :display_name, :full_name, :username].each do |attr|
312
+ value ||= Tml::Utils.hash_value(hash, attr)
313
+ end
314
+
315
+ attr = Tml::Utils.hash_value(hash, :attribute) || Tml::Utils.hash_value(hash, :property)
316
+ value ||= Tml::Utils.hash_value(hash, attr)
317
+
309
318
  object = Tml::Utils.hash_value(hash, :object)
310
319
 
311
320
  unless value.nil?
@@ -316,8 +325,6 @@ module Tml
316
325
  return error("Missing value for hash token #{full_name} in #{label}")
317
326
  end
318
327
 
319
- attr = Tml::Utils.hash_value(hash, :attribute) || Tml::Utils.hash_value(hash, :property)
320
-
321
328
  if object.is_a?(Hash)
322
329
  unless attr.nil?
323
330
  return sanitize(Tml::Utils.hash_value(object, attr), object, language, options.merge(:safe => false))
@@ -31,7 +31,7 @@
31
31
  #++
32
32
 
33
33
  module Tml
34
- VERSION = '5.5.3'
34
+ VERSION = '5.5.4'
35
35
 
36
36
  def self.full_version
37
37
  "tml-ruby v#{Tml::VERSION} (Faraday v#{Faraday::VERSION})"
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.5.3
4
+ version: 5.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Berkovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-03 00:00:00.000000000 Z
11
+ date: 2016-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday