singleton-client-test 0.7.7.7 → 0.7.7.8
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/translation.rb +20 -11
- data/lib/sgtn-client/common/data.rb +7 -1
- data/lib/sgtn-client/core/config.rb +6 -2
- data/lib/sgtn-client/fallbacks.rb +3 -12
- data/lib/sgtn-client/loader/cache.rb +1 -1
- data/lib/sgtn-client/loader/chain_loader.rb +4 -4
- data/lib/sgtn-client/loader/consts.rb +0 -1
- data/lib/sgtn-client/loader/loader_factory.rb +1 -0
- data/lib/sgtn-client/loader/local_translation.rb +5 -6
- data/lib/sgtn-client/loader/pseudo.rb +21 -0
- data/lib/sgtn-client/loader/server.rb +4 -2
- data/lib/sgtn-client/loader/source.rb +2 -2
- data/lib/sgtn-client/loader/source_comparer.rb +19 -15
- data/lib/sgtn-client/loader.rb +1 -0
- data/lib/sgtn-client/sgtn-client.rb +1 -2
- data/lib/sgtn-client/util/locale-util.rb +26 -28
- data/lib/sgtn-client/util/{string-util.rb → localized_string.rb} +3 -3
- data/lib/{sgtn-client → singleton-client}/i18n_backend.rb +7 -3
- data/lib/singleton-client/pseudo.rb +14 -0
- data/lib/singleton-client.rb +15 -10
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54400e87e847568bead1be140a4374acced859dc3fa9f3fa954b3ddd3fae7192
|
4
|
+
data.tar.gz: 073364cb409f2b2fdfa40d0ebadd6c6d36983c262dad8cd9f1d57bae602d419f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b213886e41d561eb73c20008920a2ddf87ddd98645f64efdda180f1e157749302494c944f581b87d529ed688e44858d3d0c8cb01cb7eeed9c6a50106b0494f8
|
7
|
+
data.tar.gz: efc69bd188f29815770d8c65541ade62268d063cf38a88b3a3cd416ad4c5e961b3bf7e290d4c9faec9510f3ac76e3c15bd6e2070e1e175e2f1969bb09f0d0bae
|
@@ -39,10 +39,6 @@ module SgtnClient
|
|
39
39
|
get_translations(component, locale)
|
40
40
|
end
|
41
41
|
|
42
|
-
def get_translation!(key, component, locale)
|
43
|
-
[get_bundle!(component, locale)[key], locale]
|
44
|
-
end
|
45
|
-
|
46
42
|
def translate(key, component, locale = nil, **kwargs, &block)
|
47
43
|
translate!(key, component, locale, **kwargs, &block)
|
48
44
|
rescue StandardError => e
|
@@ -56,8 +52,8 @@ module SgtnClient
|
|
56
52
|
SgtnClient.logger.debug { "[#{method(__callee__).owner}.#{__callee__}] key: #{key}, component: #{component}, locale: #{locale}, args: #{kwargs}" }
|
57
53
|
|
58
54
|
begin
|
59
|
-
|
60
|
-
result, actual_locale =
|
55
|
+
picked_locale = pickup_locale(locale || SgtnClient.locale, component)
|
56
|
+
result, actual_locale = get_string!(key, component, picked_locale)
|
61
57
|
rescue StandardError => e
|
62
58
|
raise e if block.nil?
|
63
59
|
end
|
@@ -68,7 +64,7 @@ module SgtnClient
|
|
68
64
|
return if result.nil?
|
69
65
|
end
|
70
66
|
|
71
|
-
kwargs.empty? ? result : result
|
67
|
+
kwargs.empty? ? result : interpolate(result, actual_locale, **kwargs)
|
72
68
|
end
|
73
69
|
alias t! translate!
|
74
70
|
|
@@ -82,13 +78,19 @@ module SgtnClient
|
|
82
78
|
def get_translations!(component, locale = nil)
|
83
79
|
SgtnClient.logger.debug { "[#{method(__callee__).owner}.#{__callee__}] component: #{component}, locale: #{locale}" }
|
84
80
|
|
85
|
-
|
86
|
-
|
81
|
+
picked_locale = pickup_locale(locale || SgtnClient.locale, component)
|
82
|
+
get_bundle!(component, picked_locale)
|
83
|
+
end
|
87
84
|
|
88
|
-
|
85
|
+
protected
|
86
|
+
|
87
|
+
def pickup_locale(locale, component)
|
88
|
+
LocaleUtil.get_best_locale(locale, component)
|
89
89
|
end
|
90
90
|
|
91
|
-
|
91
|
+
def interpolate(translation, locale, **kwargs)
|
92
|
+
translation.localize(locale) % kwargs
|
93
|
+
end
|
92
94
|
|
93
95
|
def get_bundle!(component, locale)
|
94
96
|
SgtnClient.config.loader.get_bundle(component, locale)
|
@@ -100,6 +102,13 @@ module SgtnClient
|
|
100
102
|
SgtnClient.config.notify_observers(:available_locales, component)
|
101
103
|
raise
|
102
104
|
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def get_string!(key, component, locale)
|
109
|
+
bundle = get_bundle!(component, locale)
|
110
|
+
[bundle.fetch(key), bundle.locale]
|
111
|
+
end
|
103
112
|
end
|
104
113
|
|
105
114
|
extend Implementation
|
@@ -50,13 +50,19 @@ module SgtnClient
|
|
50
50
|
class BundleData < Hash # :nodoc:
|
51
51
|
include DataInfo
|
52
52
|
|
53
|
-
|
53
|
+
attr_reader :origin, :locale, :component
|
54
|
+
|
55
|
+
def initialize(*args, origin: nil, locale: nil, component: nil)
|
54
56
|
if !args.empty? && args[0].is_a?(Hash)
|
55
57
|
update(args[0])
|
56
58
|
super()
|
57
59
|
else
|
58
60
|
super
|
59
61
|
end
|
62
|
+
|
63
|
+
@origin = origin
|
64
|
+
@locale = locale
|
65
|
+
@component = component
|
60
66
|
end
|
61
67
|
end
|
62
68
|
|
@@ -11,9 +11,13 @@ module SgtnClient
|
|
11
11
|
include Observable
|
12
12
|
include Singleton
|
13
13
|
|
14
|
-
attr_accessor :product_name, :version, :vip_server, :translation_bundle, :source_bundle, :cache_expiry_period,
|
14
|
+
attr_accessor :product_name, :version, :vip_server, :translation_bundle, :source_bundle, :cache_expiry_period,
|
15
|
+
:log_file, :log_level
|
16
|
+
attr_writer :logger, :pseudo_tag
|
15
17
|
|
16
|
-
|
18
|
+
def pseudo_tag
|
19
|
+
@pseudo_tag ||= '@@'
|
20
|
+
end
|
17
21
|
|
18
22
|
def logger
|
19
23
|
@logger ||= if log_file
|
@@ -3,21 +3,12 @@
|
|
3
3
|
|
4
4
|
module SgtnClient
|
5
5
|
module Fallbacks # :nodoc:
|
6
|
-
|
7
|
-
error = nil
|
8
|
-
localechain(locale) do |l|
|
9
|
-
return super(key, component, l)
|
10
|
-
rescue StandardError => e
|
11
|
-
error = e
|
12
|
-
end
|
13
|
-
raise error if error
|
14
|
-
end
|
6
|
+
protected
|
15
7
|
|
16
|
-
def
|
8
|
+
def get_bundle!(component, locale)
|
17
9
|
error = nil
|
18
10
|
localechain(locale) do |l|
|
19
|
-
|
20
|
-
return result if result
|
11
|
+
return super(component, l)
|
21
12
|
rescue StandardError => e
|
22
13
|
error = e
|
23
14
|
end
|
@@ -35,7 +35,7 @@ module SgtnClient
|
|
35
35
|
def load_bundle(component, locale)
|
36
36
|
SgtnClient.logger.debug { "[#{__FILE__}][#{__callee__}] CacheFiller, component=#{component}, locale=#{locale}" }
|
37
37
|
|
38
|
-
@cache_hash[Common::BundleID.new(component, locale)] =
|
38
|
+
@cache_hash[Common::BundleID.new(component, locale)] = super
|
39
39
|
end
|
40
40
|
|
41
41
|
def available_bundles
|
@@ -6,16 +6,16 @@ require 'set'
|
|
6
6
|
module SgtnClient
|
7
7
|
module TranslationLoader
|
8
8
|
class Chain
|
9
|
-
|
9
|
+
attr_reader :loaders
|
10
10
|
|
11
11
|
def initialize(*loaders)
|
12
|
-
|
12
|
+
@loaders = loaders
|
13
13
|
end
|
14
14
|
|
15
15
|
def load_bundle(component, locale)
|
16
16
|
exception = nil
|
17
17
|
|
18
|
-
loaders.each do |loader|
|
18
|
+
@loaders.each do |loader|
|
19
19
|
begin
|
20
20
|
bundle = loader.load_bundle(component, locale)
|
21
21
|
return bundle if bundle
|
@@ -32,7 +32,7 @@ module SgtnClient
|
|
32
32
|
exception = nil
|
33
33
|
total_data = Set.new
|
34
34
|
|
35
|
-
loaders.each do |loader|
|
35
|
+
@loaders.each do |loader|
|
36
36
|
begin
|
37
37
|
item = loader.available_bundles
|
38
38
|
total_data += item
|
@@ -26,17 +26,16 @@ module SgtnClient
|
|
26
26
|
|
27
27
|
raise SingletonError, "no messages in local bundle file: #{file_path}." unless messages
|
28
28
|
|
29
|
-
messages
|
29
|
+
Common::BundleData.new(messages, origin: self, component: component,
|
30
|
+
locale: locale == CONSTS::REAL_SOURCE_LOCALE ? LocaleUtil.get_source_locale : locale)
|
30
31
|
end
|
31
32
|
|
32
33
|
def available_bundles
|
33
34
|
SgtnClient.logger.debug { "[#{method(__callee__).owner}.#{__callee__}]" }
|
34
35
|
|
35
|
-
@available_bundles
|
36
|
-
|
37
|
-
|
38
|
-
bundles.add Common::BundleID.new(f.parent.basename.to_s, locale)
|
39
|
-
end
|
36
|
+
@available_bundles = @base_path.glob('*/*.json').reduce(Set.new) do |bundles, f|
|
37
|
+
locale = f.basename.to_s.sub(/\A#{BUNDLE_PREFIX}/i, '').sub(/#{BUNDLE_SUFFIX}\z/i, '')
|
38
|
+
bundles.add Common::BundleID.new(f.parent.basename.to_s, locale)
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
|
+
|
4
|
+
module SgtnClient
|
5
|
+
module TranslationLoader
|
6
|
+
module Pseudo # :nodoc:
|
7
|
+
def initialize(*)
|
8
|
+
super
|
9
|
+
@pseudo_tag = Sgtn.pseudo_tag
|
10
|
+
end
|
11
|
+
|
12
|
+
def load_bundle(component, locale)
|
13
|
+
return super unless locale == Sgtn::PSEUDO_LOCALE
|
14
|
+
|
15
|
+
SgtnClient.logger.debug { "[#{__FILE__}][#{__callee__}] component=#{component}, locale=#{locale}" }
|
16
|
+
|
17
|
+
super(component, LocaleUtil.get_source_locale).transform_values! { |v| "#{@pseudo_tag}#{v}#{@pseudo_tag}" }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -27,16 +27,18 @@ module SgtnClient
|
|
27
27
|
|
28
28
|
@conn = Faraday.new(config.vip_server, request: REQUEST_ARGUMENTS) do |f|
|
29
29
|
f.response :json # decode response bodies as JSON
|
30
|
-
f.use :gzip
|
31
30
|
f.response :raise_error
|
32
31
|
f.response :logger, config.logger, { log_level: :debug, headers: false, bodies: true }
|
32
|
+
f.use :gzip
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def load_bundle(component, locale)
|
37
37
|
SgtnClient.logger.debug { "[#{method(__callee__).owner}.#{__callee__}] component=#{component}, locale=#{locale}" }
|
38
38
|
|
39
|
-
query_server(format(@bundle_url, locale, component), ['messages'])
|
39
|
+
data = query_server(format(@bundle_url, locale, component), ['messages'])
|
40
|
+
Common::BundleData.new(data, origin: self, component: component,
|
41
|
+
locale: locale == CONSTS::REAL_SOURCE_LOCALE ? LocaleUtil.get_source_locale : locale)
|
40
42
|
end
|
41
43
|
|
42
44
|
def available_bundles
|
@@ -7,7 +7,7 @@ require 'yaml'
|
|
7
7
|
|
8
8
|
module SgtnClient
|
9
9
|
module TranslationLoader
|
10
|
-
class Source
|
10
|
+
class Source # :nodoc:
|
11
11
|
def initialize(config)
|
12
12
|
@source_bundle_path = Pathname.new(config.source_bundle)
|
13
13
|
end
|
@@ -31,7 +31,7 @@ module SgtnClient
|
|
31
31
|
|
32
32
|
raise SingletonError, "no local source messages for component #{component}" if total_messages.empty?
|
33
33
|
|
34
|
-
total_messages
|
34
|
+
Common::BundleData.new(total_messages, origin: self, component: component, locale: LocaleUtil.get_source_locale)
|
35
35
|
end
|
36
36
|
|
37
37
|
def available_bundles
|
@@ -11,41 +11,45 @@ module SgtnClient
|
|
11
11
|
real_locale = cache_to_real_map[locale]
|
12
12
|
return super(component, real_locale) if real_locale
|
13
13
|
|
14
|
-
old_source_bundle_thread = Thread.new { load_bundle(component, CONSTS::OLD_SOURCE_LOCALE) }
|
15
14
|
source_bundle_thread = Thread.new { load_bundle(component, LocaleUtil.get_source_locale) }
|
16
|
-
translation_bundle = super
|
15
|
+
translation_bundle = super
|
16
|
+
|
17
|
+
begin
|
18
|
+
old_source_bundle = translation_bundle.origin.load_bundle(component, old_source_locale(locale))
|
19
|
+
rescue StandardError => e
|
20
|
+
SgtnClient.logger.error "[#{__FILE__}][#{__callee__}] failed to load old source bundle. component:#{component}. error: #{e}"
|
21
|
+
end
|
17
22
|
|
18
23
|
begin
|
19
|
-
old_source_bundle = old_source_bundle_thread.value
|
20
24
|
source_bundle = source_bundle_thread.value
|
21
25
|
rescue StandardError => e
|
22
|
-
SgtnClient.logger.error "[#{__FILE__}][#{__callee__}] failed to load
|
26
|
+
SgtnClient.logger.error "[#{__FILE__}][#{__callee__}] failed to load source bundle. component:#{component}. error: #{e}"
|
23
27
|
return translation_bundle
|
24
28
|
end
|
25
29
|
|
26
30
|
compare_source(translation_bundle, old_source_bundle, source_bundle)
|
27
31
|
end
|
28
32
|
|
29
|
-
|
33
|
+
protected
|
30
34
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
return translation_bundle
|
35
|
-
end
|
35
|
+
def old_source_locale(_locale)
|
36
|
+
LocaleUtil.get_source_locale
|
37
|
+
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
def compare_source(translation_bundle, old_source_bundle, source_bundle)
|
40
|
+
source_bundle.each do |k, v|
|
41
|
+
if translation_bundle[k].nil? || (!old_source_bundle.nil? && old_source_bundle[k] != v)
|
42
|
+
translation_bundle[k] = LocalizedString.new(v, LocaleUtil.get_source_locale) if v
|
40
43
|
end
|
41
44
|
end
|
42
45
|
translation_bundle
|
43
46
|
end
|
44
47
|
|
48
|
+
private
|
49
|
+
|
45
50
|
def cache_to_real_map
|
46
51
|
@cache_to_real_map ||= {
|
47
|
-
LocaleUtil.get_source_locale => CONSTS::REAL_SOURCE_LOCALE
|
48
|
-
CONSTS::OLD_SOURCE_LOCALE => LocaleUtil.get_source_locale
|
52
|
+
LocaleUtil.get_source_locale => CONSTS::REAL_SOURCE_LOCALE
|
49
53
|
}.freeze
|
50
54
|
end
|
51
55
|
end
|
data/lib/sgtn-client/loader.rb
CHANGED
@@ -11,6 +11,7 @@ module SgtnClient
|
|
11
11
|
autoload :CONSTS, 'sgtn-client/loader/consts'
|
12
12
|
autoload :LoaderFactory, 'sgtn-client/loader/loader_factory'
|
13
13
|
autoload :LocalTranslation, 'sgtn-client/loader/local_translation'
|
14
|
+
autoload :Pseudo, 'sgtn-client/loader/pseudo'
|
14
15
|
autoload :SgtnServer, 'sgtn-client/loader/server'
|
15
16
|
autoload :SingleLoader, 'sgtn-client/loader/single_loader'
|
16
17
|
autoload :SourceComparer, 'sgtn-client/loader/source_comparer'
|
@@ -16,9 +16,8 @@ module SgtnClient # :nodoc:
|
|
16
16
|
autoload :Exceptions, 'sgtn-client/core/exceptions'
|
17
17
|
autoload :ValidateUtil, 'sgtn-client/util/validate-util'
|
18
18
|
autoload :LocaleUtil, 'sgtn-client/util/locale-util'
|
19
|
-
autoload :
|
19
|
+
autoload :LocalizedString, 'sgtn-client/util/localized_string'
|
20
20
|
autoload :SingletonError, 'sgtn-client/exceptions'
|
21
|
-
autoload :I18nBackend, 'sgtn-client/i18n_backend'
|
22
21
|
|
23
22
|
module Formatters # :nodoc:
|
24
23
|
autoload :PluralFormatter, 'sgtn-client/formatters/plurals/plural_formatter'
|
@@ -15,40 +15,38 @@ module SgtnClient
|
|
15
15
|
}.freeze
|
16
16
|
LOCALE_SEPARATOR = '-'
|
17
17
|
EN_LOCALE = 'en'
|
18
|
-
|
18
|
+
|
19
|
+
@locale_match_results = Concurrent::Map.new do |hash, component|
|
20
|
+
components = SgtnClient.config.available_components
|
21
|
+
unless components.empty? || components.include?(component)
|
22
|
+
raise SingletonError, "component '#{component}' doesn't exist!"
|
23
|
+
end
|
24
|
+
|
25
|
+
hash[component] = Concurrent::Map.new
|
26
|
+
end
|
19
27
|
@lowercase_locales_map = Concurrent::Map.new
|
20
28
|
|
21
29
|
def self.get_best_locale(locale, component)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
30
|
+
return locale if SgtnClient.config.available_locales(component).include?(locale)
|
31
|
+
|
32
|
+
component_result = @locale_match_results[component]
|
33
|
+
component_result[locale] ||= begin
|
34
|
+
if component_result.size >= 50
|
35
|
+
component_result.delete(component_result.keys[Random.rand(component_result.size)])
|
26
36
|
end
|
27
37
|
|
28
|
-
|
38
|
+
locale = locale.to_s
|
39
|
+
if locale.empty?
|
40
|
+
get_fallback_locale
|
41
|
+
else
|
42
|
+
candidates = lowercase_locales_map(component)
|
43
|
+
if candidates.empty?
|
44
|
+
locale
|
45
|
+
else
|
46
|
+
get_best_match(locale.gsub('_', LOCALE_SEPARATOR).downcase, candidates)
|
47
|
+
end
|
48
|
+
end
|
29
49
|
end
|
30
|
-
|
31
|
-
component_result[locale] ||= begin
|
32
|
-
component_result.delete(component_result.keys[Random.rand(component_result.size)]) if component_result.size >= 50
|
33
|
-
|
34
|
-
if SgtnClient.config.available_locales(component).include?(locale)
|
35
|
-
locale
|
36
|
-
elsif locale.nil?
|
37
|
-
get_fallback_locale
|
38
|
-
else
|
39
|
-
locale = locale.to_s
|
40
|
-
if locale.empty?
|
41
|
-
get_fallback_locale
|
42
|
-
else
|
43
|
-
candidates = lowercase_locales_map(component)
|
44
|
-
if candidates.empty?
|
45
|
-
locale
|
46
|
-
else
|
47
|
-
get_best_match(locale.gsub('_', LOCALE_SEPARATOR).downcase, candidates)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
50
|
end
|
53
51
|
|
54
52
|
def self.get_best_match(locale, candidates)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
require 'i18n'
|
5
5
|
|
6
|
-
module
|
6
|
+
module Sgtn # :nodoc:
|
7
7
|
# When integrating Singleton in a client application that is already using [I18n::Backend (https://www.rubydoc.info/github/svenfuchs/i18n/master/I18n/Backend/), it would be useful to have Singleton override the said module in order to minimize necessary changes. Here is a common usage:
|
8
8
|
#
|
9
9
|
# I18n::Backend::Simple.include(I18n::Backend::Fallbacks) # add fallbacks behavior to current backend
|
@@ -13,6 +13,10 @@ module SgtnClient # :nodoc:
|
|
13
13
|
class I18nBackend
|
14
14
|
def initialize(component)
|
15
15
|
@component = component
|
16
|
+
@translation = Class.new do
|
17
|
+
include SgtnClient::Translation::Implementation
|
18
|
+
include Sgtn::Pseudo
|
19
|
+
end.new
|
16
20
|
end
|
17
21
|
|
18
22
|
def initialized?
|
@@ -34,13 +38,13 @@ module SgtnClient # :nodoc:
|
|
34
38
|
def translations; end
|
35
39
|
|
36
40
|
def exists?(locale, key, options)
|
37
|
-
!!
|
41
|
+
!!translate(locale, key, options)
|
38
42
|
end
|
39
43
|
|
40
44
|
def translate(locale, key, options)
|
41
45
|
flat_key = I18n::Backend::Flatten.normalize_flat_keys(locale, key, options[:scope], '.')
|
42
46
|
values = options.except(*I18n::RESERVED_KEYS)
|
43
|
-
|
47
|
+
@translation.translate(flat_key, @component, locale, **values) { nil }
|
44
48
|
end
|
45
49
|
|
46
50
|
def localize(locale, object, format, options) end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2022 VMware, Inc.
|
4
|
+
# SPDX-License-Identifier: EPL-2.0
|
5
|
+
|
6
|
+
module Sgtn
|
7
|
+
module Pseudo # :nodoc:
|
8
|
+
protected
|
9
|
+
|
10
|
+
def pickup_locale(locale, _component)
|
11
|
+
locale == PSEUDO_LOCALE ? PSEUDO_LOCALE : super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/singleton-client.rb
CHANGED
@@ -5,6 +5,15 @@ require 'forwardable'
|
|
5
5
|
require_relative 'singleton-ruby'
|
6
6
|
|
7
7
|
module Sgtn # :nodoc:
|
8
|
+
autoload :Pseudo, 'singleton-client/pseudo'
|
9
|
+
autoload :I18nBackend, 'singleton-client/i18n_backend'
|
10
|
+
|
11
|
+
extend SgtnClient::Translation::Implementation
|
12
|
+
extend SgtnClient::Fallbacks
|
13
|
+
extend Sgtn::Pseudo
|
14
|
+
|
15
|
+
PSEUDO_LOCALE = 'pseudo'.freeze
|
16
|
+
|
8
17
|
class << self
|
9
18
|
extend Forwardable
|
10
19
|
|
@@ -13,14 +22,6 @@ module Sgtn # :nodoc:
|
|
13
22
|
SgtnClient.load(config_file, env)
|
14
23
|
end
|
15
24
|
|
16
|
-
def_delegator SgtnClient::Config, :instance, :config
|
17
|
-
delegate %i[translate! t! translate t get_translations! get_translations] => SgtnClient::Translation,
|
18
|
-
%i[locale locale=] => SgtnClient,
|
19
|
-
%i[logger product_name version vip_server translation_bundle
|
20
|
-
source_bundle cache_expiry_period log_file log_level].flat_map { |m|
|
21
|
-
[m, "#{m}=".to_sym]
|
22
|
-
} => :config
|
23
|
-
|
24
25
|
def with_locale(tmp_locale = nil)
|
25
26
|
if tmp_locale.nil?
|
26
27
|
yield
|
@@ -34,7 +35,11 @@ module Sgtn # :nodoc:
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
37
|
-
end
|
38
38
|
|
39
|
-
|
39
|
+
def_delegator SgtnClient::Config, :instance, :config
|
40
|
+
delegate %i[locale locale=] => SgtnClient,
|
41
|
+
%i[logger product_name version vip_server translation_bundle
|
42
|
+
source_bundle cache_expiry_period log_file log_level
|
43
|
+
pseudo_tag ].flat_map { |m| [m, "#{m}=".to_sym] } => :config
|
44
|
+
end
|
40
45
|
end
|
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.7.
|
4
|
+
version: 0.7.7.8
|
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-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -146,22 +146,24 @@ files:
|
|
146
146
|
- lib/sgtn-client/exceptions.rb
|
147
147
|
- lib/sgtn-client/fallbacks.rb
|
148
148
|
- lib/sgtn-client/formatters/plurals/plural_formatter.rb
|
149
|
-
- lib/sgtn-client/i18n_backend.rb
|
150
149
|
- lib/sgtn-client/loader.rb
|
151
150
|
- lib/sgtn-client/loader/cache.rb
|
152
151
|
- lib/sgtn-client/loader/chain_loader.rb
|
153
152
|
- lib/sgtn-client/loader/consts.rb
|
154
153
|
- lib/sgtn-client/loader/loader_factory.rb
|
155
154
|
- lib/sgtn-client/loader/local_translation.rb
|
155
|
+
- lib/sgtn-client/loader/pseudo.rb
|
156
156
|
- lib/sgtn-client/loader/server.rb
|
157
157
|
- lib/sgtn-client/loader/single_loader.rb
|
158
158
|
- lib/sgtn-client/loader/source.rb
|
159
159
|
- lib/sgtn-client/loader/source_comparer.rb
|
160
160
|
- lib/sgtn-client/sgtn-client.rb
|
161
161
|
- lib/sgtn-client/util/locale-util.rb
|
162
|
-
- lib/sgtn-client/util/
|
162
|
+
- lib/sgtn-client/util/localized_string.rb
|
163
163
|
- lib/sgtn-client/util/validate-util.rb
|
164
164
|
- lib/singleton-client.rb
|
165
|
+
- lib/singleton-client/i18n_backend.rb
|
166
|
+
- lib/singleton-client/pseudo.rb
|
165
167
|
- lib/singleton-ruby.rb
|
166
168
|
- lib/version.rb
|
167
169
|
homepage: https://github.com/vmware/singleton
|
@@ -183,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
185
|
- !ruby/object:Gem::Version
|
184
186
|
version: '0'
|
185
187
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
188
|
+
rubygems_version: 3.3.26
|
187
189
|
signing_key:
|
188
190
|
specification_version: 4
|
189
191
|
summary: Singleton Ruby client
|