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 +4 -4
- data/lib/sgtn-client/api/source.rb +7 -4
- data/lib/sgtn-client/api/translation.rb +31 -19
- data/lib/sgtn-client/cldr/localized_datetime.rb +45 -9
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6857a6d43824c3215fc8b7a1f924702d8dc859a1cdaa4445b381efc5fbbaa1c
|
4
|
+
data.tar.gz: 0f103e0cf2697e616c51e0f97c8a862eef177002f438e37c598987e78d311cbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
21
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
26
|
-
|
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
|
-
|
25
|
+
str = SgtnClient::Source.getSource(component, key, SgtnClient::Config.configurations.default)
|
26
|
+
str.to_plural_s(:en, plural_args)
|
32
27
|
else
|
33
|
-
|
28
|
+
str.to_plural_s(locale, plural_args)
|
34
29
|
end
|
35
|
-
|
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"] =
|
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__ +
|
5
|
-
def l_full_s(locale = TwitterCldr.locale)
|
6
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
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.
|
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
|
+
date: 2021-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|