singleton-client-test 0.7.0.13 → 0.7.0.14

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
  SHA256:
3
- metadata.gz: 197fe36f1862932229b3e8901d19f8ad232e6f3a231615c7af28e77684ab906f
4
- data.tar.gz: aa84d7909dde95f9beb33d9343a4476263dedb72d61b1d50f23caff1fbfe5db2
3
+ metadata.gz: d6857a6d43824c3215fc8b7a1f924702d8dc859a1cdaa4445b381efc5fbbaa1c
4
+ data.tar.gz: 0f103e0cf2697e616c51e0f97c8a862eef177002f438e37c598987e78d311cbc
5
5
  SHA512:
6
- metadata.gz: c4dfc25597e7230f67e35835aa44cc22576dd9c873664f81e4c78d2f469511a7d44b336b7c8d2c399505b3cb197336ac944e1e14c81c028a431529815ebce510
7
- data.tar.gz: 21301320623975a97530889f17f11f0512730cef45aed8155c7186b4dd49e21b97e3da420e1ed1d4979d93efffaadb2207e6ad3acd2dadd203300836eb9d2cd7
6
+ metadata.gz: a507ec0cdfa8680d910ef10572955bc6494533edb2b3e7798d9d9c62946a9fb7e2c41c56a964033cf82290f0f1cd31d2b918f7631d3ebf713734df731998ba59
7
+ data.tar.gz: a1cbe10c90139f63dad0b9ae86cdacfb6e283f784664b1e2b51cfc8dc7b9b882c60ffacfa35fe4eefebd3f25f7bc0e7af62119a5c188055d2beb3c59a0724e6b
@@ -17,11 +17,14 @@ module SgtnClient
17
17
  else
18
18
  SgtnClient.logger.debug "Getting sources from cache with key: " + cache_key
19
19
  end
20
- if items.nil?
21
- return key
20
+ s = items[locale][key]
21
+ if items.nil? || s.nil?
22
+ SgtnClient.logger.debug "Source not found, return key: " + key
23
+ #return key
24
+ return nil
25
+ else
26
+ return s
22
27
  end
23
- str = items[locale][key]
24
- return str
25
28
  end
26
29
 
27
30
  def self.getSources(component, locale)
@@ -12,30 +12,25 @@ module SgtnClient
12
12
  class Translation
13
13
 
14
14
  def self.getString(component, key, locale)
15
- flocale = SgtnClient::LocaleUtil.fallback(locale)
16
- cache_key = SgtnClient::CacheUtil.get_cachekey(component, flocale)
17
- items = SgtnClient::CacheUtil.get_cache(cache_key)
18
- if items.nil?
19
- items = getTranslations(component, flocale)
20
- SgtnClient::CacheUtil.write_cache(cache_key, items)
21
- else
22
- SgtnClient.logger.debug "Getting translations from cache with key: " + cache_key
15
+ str = getTranslation(component, key, locale)
16
+ if str.nil?
17
+ str = SgtnClient::Source.getSource(component, key, SgtnClient::Config.configurations.default)
23
18
  end
19
+ str
20
+ end
24
21
 
25
- default = SgtnClient::Config.configurations.default
26
- if items.nil? || items["messages"] == nil
27
- return SgtnClient::Source.getSource(component, key, default)
28
- end
29
- str = items["messages"][key]
22
+ def self.getString_p(component, key, plural_args, locale)
23
+ str = getTranslation(component, key, locale)
30
24
  if str.nil?
31
- return SgtnClient::Source.getSource(component, key, default)
25
+ str = SgtnClient::Source.getSource(component, key, SgtnClient::Config.configurations.default)
26
+ str.to_plural_s(:en, plural_args)
32
27
  else
33
- return str
28
+ str.to_plural_s(locale, plural_args)
34
29
  end
35
- end
30
+ end
36
31
 
37
- def self.getString_f(component, key, args, locale)
38
- s = getString(component, key, locale)
32
+ def self.getString_f(component, key, args, locale, *optionals)
33
+ s = getString(component, key, locale, *optionals)
39
34
  if args.is_a?(Hash)
40
35
  args.each do |source, arg|
41
36
  s.gsub! "{#{source}}", arg
@@ -62,7 +57,7 @@ module SgtnClient
62
57
  items = {}
63
58
  s = SgtnClient::Source.getSources(component, default)
64
59
  default_component, value = s.first
65
- items["component"] = default_component
60
+ items["component"] = component
66
61
  items["messages"] = value
67
62
  items["locale"] = 'source'
68
63
  end
@@ -72,6 +67,23 @@ module SgtnClient
72
67
 
73
68
  private
74
69
 
70
+ def self.getTranslation(component, key, locale)
71
+ flocale = SgtnClient::LocaleUtil.fallback(locale)
72
+ cache_key = SgtnClient::CacheUtil.get_cachekey(component, flocale)
73
+ items = SgtnClient::CacheUtil.get_cache(cache_key)
74
+ if items.nil?
75
+ items = getTranslations(component, flocale)
76
+ SgtnClient::CacheUtil.write_cache(cache_key, items)
77
+ else
78
+ SgtnClient.logger.debug "Getting translations from cache with key: " + cache_key
79
+ end
80
+ if items.nil? || items["messages"] == nil
81
+ nil
82
+ else
83
+ items["messages"][key]
84
+ end
85
+ end
86
+
75
87
  def self.getTranslations(component, locale)
76
88
  env = SgtnClient::Config.default_environment
77
89
  mode = SgtnClient::Config.configurations[env]["bundle_mode"]
@@ -1,27 +1,63 @@
1
1
  require 'date'
2
2
  require 'time'
3
3
 
4
- DateTime.class_eval <<-LOCALIZE, __FILE__, __LINE__ + 1
5
- def l_full_s(locale = TwitterCldr.locale)
6
- self.localize(locale).to_full_s
4
+ DateTime.class_eval <<-LOCALIZE, __FILE__, __LINE__ + 2
5
+ def l_full_s(locale = TwitterCldr.locale, *args)
6
+ timezone = args[0]
7
+ display_name = args[1]
8
+ if timezone.nil?
9
+ self.localize(locale).to_full_s
10
+ elsif display_name.nil?
11
+ self.localize(locale).with_timezone(timezone).to_full_s
12
+ else
13
+ tz = TwitterCldr::Timezones::Timezone.instance(timezone, locale)
14
+ tz.display_name_for(self, display_name)
15
+ end
7
16
  end
8
17
  LOCALIZE
9
18
 
10
19
  DateTime.class_eval <<-LOCALIZE, __FILE__, __LINE__ + 1
11
- def l_long_s(locale = TwitterCldr.locale)
12
- self.localize(locale).to_long_s
20
+ def l_long_s(locale = TwitterCldr.locale, *args)
21
+ timezone = args[0]
22
+ display_name = args[1]
23
+ if timezone.nil?
24
+ self.localize(locale).to_long_s
25
+ elsif display_name.nil?
26
+ self.localize(locale).with_timezone(timezone).to_long_s
27
+ else
28
+ tz = TwitterCldr::Timezones::Timezone.instance(timezone, locale)
29
+ tz.display_name_for(self, display_name)
30
+ end
13
31
  end
14
32
  LOCALIZE
15
33
 
16
34
  DateTime.class_eval <<-LOCALIZE, __FILE__, __LINE__ + 1
17
- def l_medium_s(locale = TwitterCldr.locale)
18
- self.localize(locale).to_medium_s
35
+ def l_medium_s(locale = TwitterCldr.locale, *args)
36
+ timezone = args[0]
37
+ display_name = args[1]
38
+ if timezone.nil?
39
+ self.localize(locale).to_medium_s
40
+ elsif display_name.nil?
41
+ self.localize(locale).with_timezone(timezone).to_medium_s
42
+ else
43
+ tz = TwitterCldr::Timezones::Timezone.instance(timezone, locale)
44
+ tz.display_name_for(self, display_name)
45
+ end
19
46
  end
20
47
  LOCALIZE
21
48
 
22
49
 
23
50
  DateTime.class_eval <<-LOCALIZE, __FILE__, __LINE__ + 1
24
- def l_short_s(locale = TwitterCldr.locale)
25
- self.localize(locale).to_short_s
51
+ def l_short_s(locale = TwitterCldr.locale, *args)
52
+ timezone = args[0]
53
+ display_name = args[1]
54
+ if timezone.nil?
55
+ self.localize(locale).to_short_s
56
+ elsif display_name.nil?
57
+ self.localize(locale).with_timezone(timezone).to_short_s
58
+ else
59
+ tz = TwitterCldr::Timezones::Timezone.instance(timezone, locale)
60
+ tz.display_name_for(self, display_name)
61
+ end
26
62
  end
27
63
  LOCALIZE
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
 
2
- VERSION_INFO = [0, 1, 8].freeze
2
+ VERSION_INFO = [0, 2, 1].freeze
3
3
  VERSION = VERSION_INFO.map(&:to_s).join('.').freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singleton-client-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.13
4
+ version: 0.7.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware G11n Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-30 00:00:00.000000000 Z
11
+ date: 2021-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client