singleton-client-test 0.7.0.11 → 0.7.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e383b9b5f7d7ecb475fea3c26f2d0206d104d1d1c2f123a2b0e7b713c4caa38
4
- data.tar.gz: c9f1e6766601af5c3bb6110850b9c14e3d2536cdabdce1528b549588d9e11937
3
+ metadata.gz: 332b39a0bf24294e31ed737dcfa87b3e681471f786876162c47b6f03326cccf7
4
+ data.tar.gz: 486a9c58afc2505444237a764d80b715617f50ee2496033cf91e631b12b905f5
5
5
  SHA512:
6
- metadata.gz: 6baf69345a6ba4be2762dd6072392b1a2dedd7e40d62f05266a43e825df44e1b65e0760c28bd1335a9f77c43858e77e6b9debc73f7c995eb24a36e43378e7e39
7
- data.tar.gz: ffd2122264ae556007ac8050f9eaf7d2638abbca12866eb0aa0460d67083ec24cb56a24e628515195c04ce94caab450b69341a887074d402bbfc58d7f4c65cfd
6
+ metadata.gz: 6427e56f2e9b213a0491f5980a580ad40786fd836d96d08f664592e99fa3fdae45eb38b17e350b1843f5986b208f4bebb0283a2739feefe9c8f847d9be9371d7
7
+ data.tar.gz: 82262acff173efbdea7abd8d2ebadb7555e6e5c53a24733e536d01a8a57d0eef4feec3918e6214208800aba1d38ae20735a9e148b7fbf1d716fcd96d4c8b0d37
@@ -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.11
4
+ version: 0.7.0.15
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-28 00:00:00.000000000 Z
11
+ date: 2021-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client