remote_i18n_extension 1.0.7 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b885cbc4c2a2e72f5522af0dafb7d4d1260be08a34553000f7d5efda6745be77
4
- data.tar.gz: e282541fbf8c25af450710de61654fe0bd48998df3809757740ed2378af87105
3
+ metadata.gz: 1d39598ad005dbd539128eee44e2268057997da793b9b4d02dd5e21833b2ddd3
4
+ data.tar.gz: dd65bf84f074976cec0dc388b5c7747fbd8515fe8790fc653f1b2460cbca53d0
5
5
  SHA512:
6
- metadata.gz: f8dca24fd803c98f25438d4a632d922571c782e21f1af26ed1704e83d7e4c2f299a5671f69d42d92ccfae0abe2c3384c051560427520d01075b3ce514d6432fa
7
- data.tar.gz: 54a7b08beca98c561e14426451ba761347d00e8963e1915c56147d0be3addb16d112a449cd8b89e11c897ce1a598f94ed53ff814fe428a351e8baae4417113e2
6
+ metadata.gz: e188c887f2bfd729a4052aaecf932108f74297a734944b16e4da63f60f115d07823c2b3e85688eb91f38a340c9481bd5516eac42d640d0cee9c8d3dcf66526fd
7
+ data.tar.gz: 3190ea3504cc94f43a3a7ae52933e84b6eddb246c0529ed5ae859744500096f201bf8d6ebf26cf6a1c83151db6765830745568d0fcfc235884126bc6db2602a8
data/CHANGELOG.md CHANGED
@@ -2,4 +2,9 @@
2
2
 
3
3
  ## 1.0.0 (06-May-23)
4
4
 
5
- * Initial release
5
+ * Initial release
6
+
7
+ ## 1.0.9 (09-May-23)
8
+
9
+ * Base level test coverage added
10
+ * Adds generator for configuration files
data/README.md CHANGED
@@ -1,9 +1,89 @@
1
- # Remote-I18n-Extension-Hcc
1
+ # Remote-I18n-Extension
2
2
 
3
- This gem provides an extension to the exsiting url(https://github.com/ruby-i18n/i18n)[I18n] gem by providing the ability to fetch locales from remote files
3
+ This gem is built on top of the popular [I18n](https://github.com/ruby-i18n/i18n) gem providing the ability to fetch translations from remotely hosted locale files. In case of a missing translation the gem fallbacks to serving translations from local files(present under `config/locales`) folder of your rails project.
4
4
 
5
+ ## Requirements
5
6
 
6
- # Getting Started
7
+ This gem requires `ruby 3.1.3` and `Rails 7.0.4.3`
7
8
 
8
- # Requirements
9
- This gem requires `ruby 3.1.3` and `Rails 7.0.4.3`
9
+ ## Installation
10
+ To get started paste the following inside your Gemfile and run `bundle`
11
+ ```
12
+ gem 'remote_i18n_extension', '~> 1.0', '>= 1.0.9'
13
+ ```
14
+ or install via terminal using the following command:
15
+ ```
16
+ gem install remote_i18n_extension
17
+ ```
18
+
19
+ After that run the following command to generate the config file
20
+ ```
21
+ rails g remote_i18n_extension:install
22
+ ```
23
+ This will create the following config file `config/initializers/remote_i18n_extension.rb`
24
+
25
+ ### Generated Configuration File
26
+ ```
27
+ require 'remote_i18n_extension'
28
+
29
+ RemoteI18nExtension.config do |config|
30
+ # All the configurations are mandatory
31
+
32
+ # URL to your remote locales folder housing all the translations
33
+ # For now the library expects all the locales to be stored in a single (root) folder
34
+ # e.g. https://raw.githubusercontent.com/Gooner91/locales-repo/master/locales
35
+ # config.remote_host = ENV['LOCALES_REMOTE_HOST']
36
+
37
+
38
+ # Below configurations are for the ruby I18n module
39
+
40
+ # List of available locales
41
+ # config.available_locales = [:en, :de]
42
+
43
+
44
+ # config.locale = :en
45
+
46
+ # Paths to the translation files (in your local rails project for fallback)
47
+ # e.g. Dir[Rails.root.join("config", "locales", "*.{rb,yml}")]
48
+ # config.load_path = %w[]
49
+ end
50
+
51
+ ```
52
+
53
+ ### Configurations values
54
+ #### remote_host
55
+ - base URL/URL to the folder hosting the remote files
56
+ - an example URL would be `https://raw.githubusercontent.com/Gooner91/locales-repo/master/locales` if all the translation files are uploaded in side the `locales` folder provided in the above URL
57
+ #### available_locales
58
+ - the standard I18n configuration option e.g. `%i[:en :de]`
59
+ #### locale
60
+ - the standard I18n configuration option e.g. `:en`
61
+ #### load_path
62
+ - the standard I18n configuration option e.g. ` Dir[Rails.root.join("config", "locales", "*.yml")]`
63
+
64
+ ## Usage
65
+ Fire up the server and you should be able to reference translations using the following method:
66
+ ```
67
+ RemoteI18nExtension.t('activerecord.attributes.user.confirmation_sent_at')
68
+ ```
69
+
70
+ ## Demo Video
71
+ A demo of the working of this gem can be seen on the following loom link:
72
+ https://www.loom.com/share/78825da1d74248f1b80949bf4e72b1cc
73
+
74
+ ## Constraints:
75
+
76
+ This gem facilitates fetching the `locales` that are hosted online. For that purpose the gem expects all the `locales`/`translation` files to be stored at one place.
77
+
78
+
79
+ ## Future Aspects:
80
+
81
+ Since this was a time bound activity, there are some improvments/fine tuning that can be done even further:
82
+
83
+ - Better look up support, nested file structure support for remote locales
84
+ - Increasing the overall test coverage of the gem, for now just a few basic unit test cases are added to check the behavior of the `Remote` backend, test coverage should be increased
85
+ - During testing with a demo Rails project, sometimes the gem behaves inconsistently when it comes to fallback behavior, understanding the edge cases and consistencies better and handle those as well
86
+ - Improving code quality, fixing offences pointed out by rubocop as well as properly setting up rubocop rules
87
+ - Better error handling
88
+ - Tools for measuring test coverage should be integrated i.e. simplecov
89
+ - Enforcing validation on configurations, in case some configuration is missing (raising appropriate errors)
@@ -4,8 +4,7 @@ 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 this folder mirrors your local locales folder
8
- # to avoid fallbacks to local
7
+ # For now the library expects all the locales to be stored in a single (root) folder
9
8
  # e.g. https://raw.githubusercontent.com/Gooner91/locales-repo/master/locales
10
9
  # config.remote_host = ENV['LOCALES_REMOTE_HOST']
11
10
 
@@ -18,8 +17,7 @@ RemoteI18nExtension.config do |config|
18
17
 
19
18
  # config.locale = :en
20
19
 
21
- # Paths to the translation files
22
- # Please make sure the paths to the translation files is same for local and remote locales folder
20
+ # Paths to the translation files (in your local rails project for fallback)
23
21
  # e.g. Dir[Rails.root.join("config", "locales", "*.{rb,yml}")]
24
22
  # config.load_path = %w[]
25
23
  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 TypeError, ScriptError, StandardError
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 TypeError, StandardError
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 StandardError
31
+ rescue OpenURI::HTTPError
32
32
  {}
33
33
  end
34
34
 
@@ -1,3 +1,3 @@
1
1
  module RemoteI18nExtension
2
- VERSION = '1.0.7'.freeze
2
+ VERSION = '1.0.9'.freeze
3
3
  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.7
4
+ version: 1.0.9
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-08 00:00:00.000000000 Z
11
+ date: 2023-05-09 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