remote_i18n_extension 1.0.6 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/templates/remote_i18n_extension_config.rb +4 -4
- data/lib/remote_i18n_extension/backend/initializer.rb +15 -0
- data/lib/remote_i18n_extension/backend/remote.rb +3 -3
- data/lib/remote_i18n_extension/version.rb +1 -1
- data/lib/remote_i18n_extension.rb +16 -20
- data/remote_i18n_extension.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c3bce95a44838b0a32f1185768b5455e6c096cc4a3231427512081acdf945a4
|
4
|
+
data.tar.gz: 51133a49f1b9fb6f7b3381790f5f0ce246dd0729352f59c5a218102f9ee5502c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3febda8ef89077970b89e7e156e1615c5c1b0f3be95d3c588b94721eee6fc88c19fe824afd86d346a6f83e71059dff95b112f5fa8f646de9c7bf3fa37f5804bd
|
7
|
+
data.tar.gz: 4fa8aafc02ad43c5d1144787b4d49a845689e04061a67eaa635e9ad4a7a87bffca1e229bee62e7326f39e1412b8298309cabfd8ae26971b5c4b993ee1ea43db7
|
@@ -4,9 +4,9 @@ RemoteI18nExtension.config do |config|
|
|
4
4
|
# All the configurations are mandatory
|
5
5
|
|
6
6
|
# URL to your remote locales folder housing all the translations
|
7
|
-
# Please make sure
|
8
|
-
#
|
9
|
-
# e.g. https://
|
7
|
+
# Please make sure this folder mirrors your local locales folder
|
8
|
+
# to avoid fallbacks to local
|
9
|
+
# e.g. https://raw.githubusercontent.com/Gooner91/locales-repo/master/locales
|
10
10
|
# config.remote_host = ENV['LOCALES_REMOTE_HOST']
|
11
11
|
|
12
12
|
|
@@ -20,6 +20,6 @@ RemoteI18nExtension.config do |config|
|
|
20
20
|
|
21
21
|
# Paths to the translation files
|
22
22
|
# Please make sure the paths to the translation files is same for local and remote locales folder
|
23
|
-
#
|
23
|
+
# e.g. Dir[Rails.root.join("config", "locales", "*.{rb,yml}")]
|
24
24
|
# config.load_path = %w[]
|
25
25
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'i18n'
|
2
|
+
require_relative 'remote'
|
3
|
+
|
4
|
+
module RemoteI18nExtension
|
5
|
+
module Backend
|
6
|
+
class Initializer
|
7
|
+
def self.call
|
8
|
+
I18n.backend = I18n::Backend::Chain.new(
|
9
|
+
RemoteI18nExtension::Backend::Remote.new,
|
10
|
+
I18n::Backend::Simple.new
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -10,7 +10,7 @@ module RemoteI18nExtension
|
|
10
10
|
# fallback to Simple backend fetching translations from locale files.
|
11
11
|
def load_yml(filename)
|
12
12
|
YAML.load(load_remote_locales(filename))
|
13
|
-
rescue
|
13
|
+
rescue OpenURI::HTTPError
|
14
14
|
{}
|
15
15
|
end
|
16
16
|
|
@@ -19,7 +19,7 @@ module RemoteI18nExtension
|
|
19
19
|
# fallback to Simple backend fetching translations from locale files.
|
20
20
|
def load_json(filename)
|
21
21
|
JSON.parse(load_remote_locales(filename))
|
22
|
-
rescue
|
22
|
+
rescue OpenURI::HTTPError
|
23
23
|
{}
|
24
24
|
end
|
25
25
|
|
@@ -28,7 +28,7 @@ module RemoteI18nExtension
|
|
28
28
|
# fallback to Simple backend fetching translations from locale files.
|
29
29
|
def load_rb(filename)
|
30
30
|
eval(load_remote_locales(filename), binding, filename)
|
31
|
-
rescue
|
31
|
+
rescue OpenURI::HTTPError
|
32
32
|
{}
|
33
33
|
end
|
34
34
|
|
@@ -1,33 +1,38 @@
|
|
1
1
|
require 'i18n'
|
2
|
-
require_relative 'remote_i18n_extension/backend/
|
2
|
+
require_relative 'remote_i18n_extension/backend/initializer'
|
3
3
|
|
4
4
|
module RemoteI18nExtension
|
5
|
-
|
6
|
-
RemoteI18nExtension::Backend::Remote.new,
|
7
|
-
I18n::Backend::Simple.new
|
8
|
-
)
|
5
|
+
RemoteI18nExtension::Backend::Initializer.call
|
9
6
|
|
10
7
|
class << self
|
11
|
-
attr_reader :load_path, :available_locales, :locale
|
12
8
|
attr_accessor :remote_host
|
13
9
|
|
14
10
|
def config
|
15
11
|
yield self
|
16
12
|
end
|
17
13
|
|
14
|
+
def available_locales=(locales_array)
|
15
|
+
I18n.available_locales = locales_array ? locales_array : [:en]
|
16
|
+
end
|
17
|
+
|
18
18
|
def locale=(locale)
|
19
19
|
I18n.locale = locale || :en
|
20
|
-
@locale = I18n.locale
|
21
20
|
end
|
22
21
|
|
23
22
|
def load_path=(paths_array)
|
24
23
|
I18n.load_path = paths_array
|
25
|
-
@load_path = I18n.load_path
|
26
24
|
end
|
27
25
|
|
28
|
-
def available_locales
|
29
|
-
I18n.available_locales
|
30
|
-
|
26
|
+
def available_locales
|
27
|
+
I18n.available_locales
|
28
|
+
end
|
29
|
+
|
30
|
+
def locale
|
31
|
+
I18n.locale
|
32
|
+
end
|
33
|
+
|
34
|
+
def load_path
|
35
|
+
I18n.load_path
|
31
36
|
end
|
32
37
|
|
33
38
|
def translate(*args)
|
@@ -39,13 +44,4 @@ module RemoteI18nExtension
|
|
39
44
|
I18n.reload!
|
40
45
|
end
|
41
46
|
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def init_i18n_backend
|
46
|
-
I18n.backend = I18n::Backend::Chain.new(
|
47
|
-
RemoteI18nExtension::Backend::Remote.new,
|
48
|
-
I18n::Backend::Simple.new
|
49
|
-
)
|
50
|
-
end
|
51
47
|
end
|
@@ -21,5 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'rubocop-rails', '~> 2.19.1'
|
22
22
|
spec.add_dependency 'rubocop-rspec', '~> 2.21.0'
|
23
23
|
spec.add_dependency 'rspec-rails', '~> 6.0.2'
|
24
|
+
spec.add_dependency 'webmock', '~> 3.18.1'
|
24
25
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
25
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_i18n_extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hassan Ahmed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 6.0.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.18.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.18.1
|
83
97
|
description: Support remote fetching of locales
|
84
98
|
email:
|
85
99
|
- hassan91ahmed@gmail.com
|
@@ -94,6 +108,7 @@ files:
|
|
94
108
|
- lib/generators/remote_i18n_extension/install_generator.rb
|
95
109
|
- lib/generators/templates/remote_i18n_extension_config.rb
|
96
110
|
- lib/remote_i18n_extension.rb
|
111
|
+
- lib/remote_i18n_extension/backend/initializer.rb
|
97
112
|
- lib/remote_i18n_extension/backend/remote.rb
|
98
113
|
- lib/remote_i18n_extension/version.rb
|
99
114
|
- remote_i18n_extension.gemspec
|