singleton-client-test 0.7.0.31 → 0.7.0.32
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 +4 -2
- data/lib/sgtn-client/api/t.rb +4 -1
- data/lib/sgtn-client/api/translation.rb +15 -5
- data/lib/sgtn-client/cldr/core_ext.rb +4 -1
- data/lib/sgtn-client/cldr/localized_date.rb +4 -1
- data/lib/sgtn-client/cldr/localized_datetime.rb +4 -1
- data/lib/sgtn-client/cldr/localized_str.rb +3 -1
- data/lib/sgtn-client/cldr/localized_time.rb +4 -1
- data/lib/sgtn-client/core/cache.rb +4 -1
- data/lib/sgtn-client/core/config.rb +4 -1
- data/lib/sgtn-client/core/exceptions.rb +3 -0
- data/lib/sgtn-client/core/logging.rb +3 -1
- data/lib/sgtn-client/core/request.rb +4 -1
- data/lib/sgtn-client/formatters/plurals/plural_formatter.rb +4 -1
- data/lib/sgtn-client/sgtn-client.rb +6 -1
- data/lib/sgtn-client/util/cache-util.rb +5 -8
- data/lib/sgtn-client/util/file-util.rb +4 -1
- data/lib/sgtn-client/util/locale-util.rb +12 -1
- data/lib/sgtn-client/util/validate-util.rb +3 -1
- data/lib/singleton-ruby.rb +3 -0
- data/lib/version.rb +2 -0
- 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: 7c3518e9f8e872dd00acd151a9157c273f274c5398d773c42e75d07e0667413b
|
4
|
+
data.tar.gz: 0eec546d1df60f066a1f346c04da0cac374f1944980477ccb32b5055a70e62b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8eb7e6e83057a56fa3a0d618b14ef83e61458319ccbbea388028961bbeae0ea061c82c87ed34f89cfe43c2336fc390b4ffe6801c1e9e6c85e43a2c4dd366e9f
|
7
|
+
data.tar.gz: 10eb576187a7ff47e04e409ff292862397e956de6adfbe9f2a39565cd5219c22397a959a23b399c96627aeab85562992f0abc92edec3a590f0ec7a7b610c4794
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
1
3
|
|
2
4
|
module SgtnClient
|
3
5
|
|
@@ -15,7 +17,7 @@ module SgtnClient
|
|
15
17
|
else
|
16
18
|
SgtnClient.logger.debug "[Source][getSource]getting sources from cache with key: " + cache_key
|
17
19
|
end
|
18
|
-
s = items.nil
|
20
|
+
s = (items.nil? || items[locale].nil?)? nil : items[locale][key]
|
19
21
|
if items.nil? || s.nil?
|
20
22
|
SgtnClient.logger.debug "[Source][getSource]source not found, return key: " + key
|
21
23
|
#return key
|
@@ -68,4 +70,4 @@ module SgtnClient
|
|
68
70
|
|
69
71
|
end
|
70
72
|
|
71
|
-
end
|
73
|
+
end
|
data/lib/sgtn-client/api/t.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
|
+
|
1
4
|
require 'multi_json'
|
2
5
|
|
3
6
|
module SgtnClient
|
@@ -56,6 +59,7 @@ module SgtnClient
|
|
56
59
|
|
57
60
|
def self.getStrings(component, locale)
|
58
61
|
SgtnClient.logger.debug "[Translation][getStrings]component=#{component}, locale=#{locale}"
|
62
|
+
locale = SgtnClient::LocaleUtil.get_best_locale(locale)
|
59
63
|
items = get_cs(component, locale)
|
60
64
|
default = SgtnClient::Config.configurations.default
|
61
65
|
if items.nil? || items["messages"] == nil
|
@@ -77,6 +81,7 @@ module SgtnClient
|
|
77
81
|
private
|
78
82
|
|
79
83
|
def self.getTranslation(component, key, locale)
|
84
|
+
locale = SgtnClient::LocaleUtil.get_best_locale(locale)
|
80
85
|
items = get_cs(component, locale)
|
81
86
|
if items.nil? || items["messages"] == nil
|
82
87
|
nil
|
@@ -86,13 +91,18 @@ module SgtnClient
|
|
86
91
|
end
|
87
92
|
|
88
93
|
def self.get_cs(component, locale)
|
89
|
-
locale
|
90
|
-
|
91
|
-
|
94
|
+
# source locale always return source bundle
|
95
|
+
if locale == LocaleUtil.get_source_locale
|
96
|
+
sources = SgtnClient::Source.getSources(component, SgtnClient::Config.configurations.default)
|
97
|
+
messages = sources&.first&.last
|
98
|
+
return {'locale' => locale, 'component' => component, 'messages' => messages} if messages
|
99
|
+
end
|
100
|
+
|
101
|
+
cache_key = SgtnClient::CacheUtil.get_cachekey(component, locale)
|
92
102
|
SgtnClient.logger.debug "[Translation][get_cs]cache_key=#{cache_key}"
|
93
103
|
expired, items = SgtnClient::CacheUtil.get_cache(cache_key)
|
94
104
|
if items.nil? || expired
|
95
|
-
items = load(component,
|
105
|
+
items = load(component, locale)
|
96
106
|
if items.nil?
|
97
107
|
items = SgtnClient::Source.getSources(component, SgtnClient::Config.configurations.default)
|
98
108
|
SgtnClient::Core::Cache.put(cache_key, items, 60)
|
@@ -145,4 +155,4 @@ module SgtnClient
|
|
145
155
|
|
146
156
|
end
|
147
157
|
|
148
|
-
end
|
158
|
+
end
|
@@ -1,4 +1,7 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
|
+
|
1
4
|
require 'sgtn-client/cldr/localized_datetime'
|
2
5
|
require 'sgtn-client/cldr/localized_date'
|
3
6
|
require 'sgtn-client/cldr/localized_time'
|
4
|
-
require 'sgtn-client/cldr/localized_str'
|
7
|
+
require 'sgtn-client/cldr/localized_str'
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
|
+
|
1
4
|
require 'date'
|
2
5
|
require 'time'
|
3
6
|
|
@@ -24,4 +27,4 @@ Date.class_eval <<-LOCALIZE, __FILE__, __LINE__ + 1
|
|
24
27
|
def l_short_s(locale = TwitterCldr.locale)
|
25
28
|
self.to_datetime().localize(locale).to_date().to_short_s
|
26
29
|
end
|
27
|
-
LOCALIZE
|
30
|
+
LOCALIZE
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
|
+
|
1
4
|
require 'date'
|
2
5
|
require 'time'
|
3
6
|
|
@@ -60,4 +63,4 @@ DateTime.class_eval <<-LOCALIZE, __FILE__, __LINE__ + 1
|
|
60
63
|
tz.display_name_for(self, display_name)
|
61
64
|
end
|
62
65
|
end
|
63
|
-
LOCALIZE
|
66
|
+
LOCALIZE
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
1
3
|
|
2
4
|
String.class_eval <<-LOCALIZE, __FILE__, __LINE__ + 1
|
3
5
|
def to_plural_s(locale, arg)
|
@@ -8,4 +10,4 @@ String.class_eval <<-LOCALIZE, __FILE__, __LINE__ + 1
|
|
8
10
|
num_str
|
9
11
|
end
|
10
12
|
end
|
11
|
-
LOCALIZE
|
13
|
+
LOCALIZE
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
|
+
|
1
4
|
require 'date'
|
2
5
|
require 'time'
|
3
6
|
|
@@ -24,4 +27,4 @@ Time.class_eval <<-LOCALIZE, __FILE__, __LINE__ + 1
|
|
24
27
|
def l_short_s(locale = TwitterCldr.locale)
|
25
28
|
self.localize(locale).to_short_s
|
26
29
|
end
|
27
|
-
LOCALIZE
|
30
|
+
LOCALIZE
|
@@ -1,4 +1,9 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
|
+
|
1
4
|
module SgtnClient
|
5
|
+
LOGFILE_SHIFT_AGE = 4
|
6
|
+
|
2
7
|
module Core
|
3
8
|
autoload :Cache, "sgtn-client/core/cache"
|
4
9
|
end
|
@@ -44,7 +49,7 @@ module SgtnClient
|
|
44
49
|
end
|
45
50
|
file = File.open(file, 'a')
|
46
51
|
file.sync = true
|
47
|
-
SgtnClient.logger = Logger.new(file)
|
52
|
+
SgtnClient.logger = Logger.new(file, LOGFILE_SHIFT_AGE)
|
48
53
|
|
49
54
|
# Set log level for sandbox mode
|
50
55
|
env = SgtnClient::Config.default_environment
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
|
+
|
1
4
|
require 'erb'
|
2
5
|
require 'yaml'
|
3
6
|
|
@@ -38,14 +41,8 @@ module SgtnClient
|
|
38
41
|
env = SgtnClient::Config.default_environment
|
39
42
|
product_name = SgtnClient::Config.configurations[env]["product_name"]
|
40
43
|
version = SgtnClient::Config.configurations[env]["version"].to_s
|
41
|
-
|
42
|
-
if default_l == nil
|
43
|
-
default_l = 'en'
|
44
|
-
end
|
45
|
-
lc = locale == default_l ? SgtnClient::Config.configurations.default: locale
|
46
|
-
SgtnClient.logger.debug "[CacheUtil]get cache key: #{lc}"
|
47
|
-
return product_name + "_" + version + "_" + component + "_" + lc
|
44
|
+
product_name + "_" + version + "_" + component + "_" + locale
|
48
45
|
end
|
49
46
|
end
|
50
47
|
|
51
|
-
end
|
48
|
+
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
|
+
|
1
4
|
module SgtnClient
|
2
5
|
|
3
6
|
DEFAULT_LOCALES = ['en', 'de', 'es', 'fr', 'ko', 'ja', 'zh-Hans', 'zh-Hant']
|
@@ -10,6 +13,9 @@ module SgtnClient
|
|
10
13
|
}
|
11
14
|
|
12
15
|
class LocaleUtil
|
16
|
+
def self.get_best_locale(locale)
|
17
|
+
fallback(process_locale(locale))
|
18
|
+
end
|
13
19
|
def self.process_locale(locale=nil)
|
14
20
|
locale ||= SgtnClient::Config.configurations.default
|
15
21
|
locale.to_s
|
@@ -31,5 +37,10 @@ module SgtnClient
|
|
31
37
|
end
|
32
38
|
return locale
|
33
39
|
end
|
40
|
+
def self.get_source_locale
|
41
|
+
env = SgtnClient::Config.default_environment
|
42
|
+
source_locale = SgtnClient::Config.configurations[env]["default_language"]
|
43
|
+
source_locale || 'en'
|
44
|
+
end
|
34
45
|
end
|
35
|
-
end
|
46
|
+
end
|
data/lib/singleton-ruby.rb
CHANGED
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.32
|
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: 2022-
|
11
|
+
date: 2022-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|