singleton-client-test 0.7.0.11 → 0.7.0.15
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: 332b39a0bf24294e31ed737dcfa87b3e681471f786876162c47b6f03326cccf7
|
4
|
+
data.tar.gz: 486a9c58afc2505444237a764d80b715617f50ee2496033cf91e631b12b905f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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.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
|
+
date: 2021-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|