roda-i18n 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9c2738c4186efd7bb356272c3fad656bd1a79237
4
- data.tar.gz: 72a1cb79f9dbc234b12411d58e7801e935933a7e
2
+ SHA256:
3
+ metadata.gz: 299cfc297f403c8b9d9c40dad750ddfbc2a868ffea9b8f8f6a2dbb8e39d88c50
4
+ data.tar.gz: b7581d6db878fb686b04383587dea2dee374ed86ab5b7a8d630ca71d8360796f
5
5
  SHA512:
6
- metadata.gz: 941708ff91f4da8c9da9d03e2dafe545d1845e9e679d0e66d249408832c8aa3ecd53dbc2dbde3b56e756b5c2091eeb0e0eb529a305154fb0857f4b8972ab6b6d
7
- data.tar.gz: 4781db341bd8d1fa1154dcc68d0ca45b56f7ccb76a9a4b3be103e066a26ea521472ff7af9a7e5515bed4d11e4d0e64de0812be79d89f77a9baca7597488590b7
6
+ metadata.gz: d228be9cfef332c4de8c8a8e83dc0401c0f9c361a612f417da1e8af239092c77399af7dc7fd721788f9ca1494f631c70ac7280355321bfd99e9231b3de7fa03c
7
+ data.tar.gz: 79bd150bdd0e4642326a1807274f4586e597558867bd0c539c59fe82c30a10f70f5f818736d34dd4cdaca7799ee2290f21c0e3fb0c14587335198f3ed3221fad
data/.gitignore CHANGED
@@ -1,9 +1,11 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
9
+
10
+ .tool-versions
11
+ .devcontainer/
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## next (unreleased)
4
+
5
+ * your changes here
6
+
7
+ ## 0.5.0 (unreleased)
8
+
9
+ * Merge pull request #5 from simonneutert/bump-dependencies - Add/Bump dependencies, minimum Ruby version to 3.0.0
10
+
11
+ * __Breaking Changes:__
12
+ * minimum Ruby version is now >= 3.0.0
13
+
14
+ * __Dependencies:__
15
+ * Add `date` to `gemspec`
16
+ * Bump `r18n-core` to `~> 5.0`
17
+ * Bump `roda` to `~> 3.8`
18
+ * Bump `rack-test` to `1.1.0`
19
+
20
+ * Bump `bundler` to `~> 2.5`
21
+ * Bump `rack-test` to `~> 2.1`
22
+ * Bump `rake` to `~> 13.2`
23
+
24
+ * __Tests:__
25
+ * switched from rack session to roda session (as plugin in test suite)
26
+ * fixed failing tests and updated fixtures for proper YAML due to the above changes (Psych was freaking out about the prior YAML formatting)
3
27
 
4
28
  ## 0.4.0 (2018-05-08)
5
29
 
@@ -53,7 +77,6 @@
53
77
  * Update development dependency `rake` to `12.3`
54
78
  * Remove noop check for exception
55
79
 
56
-
57
80
  ## 0.3.0 (2016-08-11)
58
81
 
59
82
  * Merged PR #3 by @jonduarte - Making routes behind #locale block work
@@ -64,15 +87,13 @@
64
87
 
65
88
  * Add alias for rake test
66
89
 
67
-
68
90
  ## 0.2.0 (2015-11-24)
69
91
 
70
92
  * Mainly internal build and setup improvements
71
93
 
72
-
73
94
  ## 0.1.0 (2015-09-13)
74
95
 
75
96
  * Initial public release
76
97
 
77
98
  * Big Thank You to @jeremyevans for his assistance in creating this initial version.
78
-
99
+
data/Gemfile CHANGED
@@ -1,4 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in roda-i18n.gemspec
4
6
  gemspec
7
+
8
+ gem 'bundler', '~> 2.5'
9
+ gem 'erubi'
10
+ gem 'kramdown'
11
+ gem 'minitest', '~> 5.7', '>= 5.7.0'
12
+ gem 'minitest-hooks', '~> 1.1', '>= 1.1.0'
13
+ gem 'minitest-rg'
14
+ gem 'rack-test', '~> 2.1'
15
+ gem 'rake', '~> 13.2'
16
+ gem 'rubocop'
17
+ gem 'rubocop-minitest'
18
+ gem 'rubocop-performance'
19
+ gem 'rubocop-rake'
20
+ gem 'simplecov'
data/Gemfile.lock ADDED
@@ -0,0 +1,104 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ roda-i18n (0.6.0)
5
+ date
6
+ r18n-core (~> 5)
7
+ roda (~> 3.8)
8
+ tilt
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ ast (2.4.2)
14
+ date (3.3.4)
15
+ date (3.3.4-java)
16
+ docile (1.4.1)
17
+ erubi (1.13.0)
18
+ json (2.7.2)
19
+ json (2.7.2-java)
20
+ kramdown (2.4.0)
21
+ rexml
22
+ language_server-protocol (3.17.0.3)
23
+ minitest (5.25.1)
24
+ minitest-hooks (1.5.2)
25
+ minitest (> 5.3)
26
+ minitest-rg (5.3.0)
27
+ minitest (~> 5.0)
28
+ parallel (1.26.3)
29
+ parser (3.3.5.0)
30
+ ast (~> 2.4.1)
31
+ racc
32
+ r18n-core (5.0.1)
33
+ racc (1.8.1)
34
+ racc (1.8.1-java)
35
+ rack (3.1.7)
36
+ rack-test (2.1.0)
37
+ rack (>= 1.3)
38
+ rainbow (3.1.1)
39
+ rake (13.2.1)
40
+ regexp_parser (2.9.2)
41
+ rexml (3.3.7)
42
+ roda (3.83.0)
43
+ rack
44
+ rubocop (1.66.1)
45
+ json (~> 2.3)
46
+ language_server-protocol (>= 3.17.0)
47
+ parallel (~> 1.10)
48
+ parser (>= 3.3.0.2)
49
+ rainbow (>= 2.2.2, < 4.0)
50
+ regexp_parser (>= 2.4, < 3.0)
51
+ rubocop-ast (>= 1.32.2, < 2.0)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (>= 2.4.0, < 3.0)
54
+ rubocop-ast (1.32.3)
55
+ parser (>= 3.3.1.0)
56
+ rubocop-minitest (0.36.0)
57
+ rubocop (>= 1.61, < 2.0)
58
+ rubocop-ast (>= 1.31.1, < 2.0)
59
+ rubocop-performance (1.21.1)
60
+ rubocop (>= 1.48.1, < 2.0)
61
+ rubocop-ast (>= 1.31.1, < 2.0)
62
+ rubocop-rake (0.6.0)
63
+ rubocop (~> 1.0)
64
+ ruby-progressbar (1.13.0)
65
+ simplecov (0.22.0)
66
+ docile (~> 1.1)
67
+ simplecov-html (~> 0.11)
68
+ simplecov_json_formatter (~> 0.1)
69
+ simplecov-html (0.13.1)
70
+ simplecov_json_formatter (0.1.4)
71
+ tilt (2.4.0)
72
+ unicode-display_width (2.5.0)
73
+
74
+ PLATFORMS
75
+ aarch64-linux
76
+ arm-linux
77
+ arm64-darwin
78
+ java
79
+ ruby
80
+ universal-java-17
81
+ universal-java-22
82
+ x64-mingw32
83
+ x86-linux
84
+ x86_64-darwin
85
+ x86_64-linux
86
+
87
+ DEPENDENCIES
88
+ bundler (~> 2.5)
89
+ erubi
90
+ kramdown
91
+ minitest (~> 5.7, >= 5.7.0)
92
+ minitest-hooks (~> 1.1, >= 1.1.0)
93
+ minitest-rg
94
+ rack-test (~> 2.1)
95
+ rake (~> 13.2)
96
+ roda-i18n!
97
+ rubocop
98
+ rubocop-minitest
99
+ rubocop-performance
100
+ rubocop-rake
101
+ simplecov
102
+
103
+ BUNDLED WITH
104
+ 2.5.18
data/README.md CHANGED
@@ -1,50 +1,39 @@
1
1
  # Roda-i18n
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/roda-i18n.svg)](https://badge.fury.io/rb/roda-i18n) [![Build Status](https://travis-ci.org/kematzy/roda-i18n.svg?branch=master)](https://travis-ci.org/kematzy/roda-i18n)
3
+ [![Gem Version](https://badge.fury.io/rb/roda-i18n.svg)](https://badge.fury.io/rb/roda-i18n) [![Ruby](https://github.com/kematzy/roda-i18n/actions/workflows/ruby.yml/badge.svg)](https://github.com/kematzy/roda-i18n/actions/workflows/ruby.yml)
4
4
 
5
5
 
6
- Add Internationalisation (i18n) and localisation support to your [Roda](http://roda.jeremyevans.net/)
7
- apps, based upon the [R18n](https://github.com/ai/r18n) gem.
6
+ Add Internationalisation (i18n) and localisation support to your [Roda](http://roda.jeremyevans.net/) apps, based upon the [R18n](https://github.com/ai/r18n) gem.
8
7
 
9
- Extensively tested and with 100% code test coverage.
8
+ Extensively tested and with a goal of 100% code test coverage.
10
9
 
11
10
 
12
11
  ## Installation
13
12
 
14
- To use this gem, just do
13
+ To install this gem:
15
14
 
16
15
  ```bash
17
- $ (sudo) gem install roda-i18n
16
+ $ gem install roda-i18n
18
17
  ```
19
18
 
20
- or if you use Bundler
19
+ Or if you use Bundler, add this to your Gemfile:
21
20
 
22
21
  ```ruby
23
- gem "roda-i18n"
22
+ gem 'roda-i18n'
24
23
  ```
25
24
 
26
- <br>
27
-
28
-
29
25
  ## Getting Started
30
26
 
31
- To add internationalisation and localisation support to your app just add the following code snippet
32
- in your app.
27
+ To add internationalisation and localisation support to your app just add the following code snippet in your app.
33
28
 
34
29
  ```ruby
35
30
  plugin :i18n
36
31
  ```
37
32
 
38
- By default the default locale is set to `'en'` and the translations directory is set to the `'i18n'`
39
- directory in the root of your app, ie: `'/path/2/app/i18n'`.
40
-
33
+ By default the default locale is set to `'en'` and the translations directory is set to the `'i18n'` directory in the root of your app, ie: `'/path/2/app/i18n'`.
41
34
 
42
- **IMPORTANT! Make sure you create the 'i18n' folder and add an `'en.yml'` file with at least one
43
- translation within it.**
44
35
 
45
-
46
- <br>
47
- ---
36
+ **IMPORTANT! Make sure you create the 'i18n' folder and add an `'en.yml'` file with at least one translation within it.**
48
37
 
49
38
 
50
39
  ## Configuration
@@ -59,36 +48,26 @@ plugin :i18n, :locale => ['de'], :translations => ['absolute/path/2/i18n']
59
48
 
60
49
  **NOTE!**
61
50
 
62
- 1. You must set `opts[:root]` in your app if you do not define the `:translations` path during
63
- plugin configuration.
64
-
65
- 3. When overriding `:translations` the **any path(s) given must be absolute**.
51
+ 1. You must set `opts[:root]` in your app if you do not define the `:translations` path during plugin configuration.
66
52
 
53
+ 2. When overriding `:translations`, then **any path(s) given must be absolute**.
67
54
 
68
55
  #### Loading translations from multiple i18n directories
69
56
 
70
- The `:translations` path supports 'wildcards', ie: `path/**/i18n` so you can load translations from
71
- multiple combined apps, each with their own `i18n` folder with translations.
57
+ The `:translations` path supports 'wildcards', ie: `path/**/i18n` so you can load translations from multiple combined apps, each with their own `i18n` folder with translations.
72
58
 
73
59
  **Please Note!**
74
60
 
75
- When loading translations from multiple sources and the same translation key is available in
76
- multiple files of the same locale, then **the translations in the first loaded translation file
77
- takes precedence over subsequent loaded translations**.
61
+ When loading translations from multiple sources and the same translation key is available in multiple files of the same locale, then **the translations in the first loaded translation file takes precedence over subsequent loaded translations**.
78
62
 
79
63
  * ie: translations in `./i18n/en.yml` takes precedence over translations in `./apps/app1/i18n/en.yml`
80
64
 
81
-
82
65
  You can also set a list of preferred locales as an array ordered by priority.
83
66
 
84
67
  ```ruby
85
68
  plugin :i18n, :locale => ['es','fr','en']
86
69
  ```
87
70
 
88
-
89
- <br>
90
- ---
91
-
92
71
  ## USAGE
93
72
 
94
73
  The **i18n** plugin depends upon simple YAML based translations files:
@@ -122,7 +101,6 @@ l Time.now, :human #=> "now"
122
101
  l Time.now, :full #=> "3rd of January, 2010 18:54"
123
102
  ```
124
103
 
125
-
126
104
  Both the `:t` and `:l` methods are available within the route and template (erb) scopes. ie:
127
105
 
128
106
  ```ruby
@@ -138,24 +116,18 @@ end
138
116
  <snip...>
139
117
  ```
140
118
 
141
- Please visit [R18n](https://github.com/ai/r18n/tree/master/r18n-core) for more information about the
119
+ Please visit [R18n-Core](https://github.com/ai/r18n/tree/master/r18n-core) for more information about the
142
120
  R18n gem used to create the above.
143
121
 
144
- <br>
145
- ---
146
-
147
122
  ## Key Methods / Functionality
148
123
 
149
-
150
- <br>
151
-
124
+ This plugin brings some methods and functionalities you can setup in your Roda project.
152
125
 
153
126
  ### `#locale(opts = {}, &blk)` - (request method)
154
127
 
155
128
  This request method makes it easy to handle translations based upon the **`:locale` prefix on a
156
129
  route / URL**. ie: `blog.com/**de**/posts`.
157
130
 
158
-
159
131
  To enable this, just use the following code structure:
160
132
 
161
133
  ```ruby
@@ -174,14 +146,7 @@ route do |r|
174
146
  end
175
147
  ```
176
148
 
177
-
178
-
179
- **NOTE!** Any URL / request with a non-present or not supported locale will be given the
180
- **configured default locale** or the EN (English) default locale.
181
-
182
-
183
- <br>
184
-
149
+ **NOTE!** Any URL / request with a non-present or not supported locale will be given the **configured default locale** or the EN (English) default locale.
185
150
 
186
151
  ### `#i18n_set_locale_from(type)` - (request method)
187
152
 
@@ -210,10 +175,6 @@ end
210
175
 
211
176
  **NOTE!** defaults to the configured default locale, or English, if the given locale type is invalid.
212
177
 
213
-
214
- <br>
215
-
216
-
217
178
  ### `i18n_set_locale(locale, &blk)` - (request method)
218
179
 
219
180
  Enables overriding the default locale and setting a temporary `:locale` within a route block.
@@ -235,27 +196,16 @@ route do |r|
235
196
  end
236
197
  ```
237
198
 
238
- <br>
239
- ---
240
-
241
199
  ## InstanceMethods
242
200
 
243
201
  ### `#t`
244
202
 
245
203
  This is the main translation output method. (See examples above)
246
204
 
247
-
248
- <br>
249
-
250
-
251
205
  ### `#l`
252
206
 
253
207
  Key localisation method. Handles dates etc. (See examples above)
254
208
 
255
-
256
- <br>
257
-
258
-
259
209
  ### `#i18n_available_locales`
260
210
 
261
211
  Returns a two-dimensional array of available locales.
@@ -264,30 +214,18 @@ Returns a two-dimensional array of available locales.
264
214
  puts i18n_available_locales #=> [ ['en', 'English'], ...]
265
215
  ```
266
216
 
267
-
268
-
269
217
  ### `#i18n_default_places`
270
218
 
271
-
272
- <br>
273
-
274
-
275
219
  ## Class Methods
276
220
 
277
221
  ### `#i18n_opts()`
278
222
 
279
223
  Return the i18n options for this class as a Hash.
280
224
 
281
-
282
- <br>
283
- ---
284
-
285
-
286
225
  ## Ideas
287
226
 
288
227
  A few ideas that may be outlandish, but possible?
289
228
 
290
-
291
229
  ### Ability to load translations from multiple locations via an array.
292
230
 
293
231
  ```ruby
@@ -301,16 +239,9 @@ plugin :i18n, :translations => ['app1/i18n', 'app2/i18n', 'app3/i18n']
301
239
  > R18n.default_places = [MyLoader.new, DBLoader.new, 'path/to/yaml']
302
240
  >
303
241
 
304
-
305
242
  ### Sequel DBLoader for DB based translations support
306
243
 
307
- Som form of built-in support for storing / loading translations from a Sequel based DB.
308
-
309
-
310
- <br>
311
-
312
-
313
- ----
244
+ Some form of built-in support for storing / loading translations from a Sequel based DB.
314
245
 
315
246
  ## TODOs
316
247
 
@@ -324,26 +255,26 @@ Som form of built-in support for storing / loading translations from a Sequel ba
324
255
 
325
256
  * ...and some more stuff that slipped my mind right now.
326
257
 
327
-
328
258
  ## Credits
329
259
 
330
- * This plugin have been inspired by the `sinatra-i18n` gem available at
331
- [github/ai/r18n](http://github.com/ai/r18n) created by [Andrey Sitnik](http://github.com/ai).
260
+ * This plugin has been inspired by the `sinatra-i18n` gem available at [github/ai/r18n](http://github.com/ai/r18n) created by [Andrey Sitnik](http://github.com/ai).
332
261
 
333
- * Testing code have been partly copied from [Forme](github.com/jeremyevans/forme).
262
+ * Testing code has been partly copied from [Forme](https://github.com/jeremyevans/forme).
334
263
 
335
- * Inspiration and assistance by [Jeremy Evans](github.com/jeremyevans). Many thanks Jeremy!!
264
+ * Inspiration and assistance by [Jeremy Evans](https://github.com/jeremyevans). Many thanks Jeremy!!
336
265
 
337
266
  * Code fixes and improvements by:
338
267
 
339
- * [Jonathan Duarte](github.com/jonduarte). Many thanks Jonathan
268
+ * [Jonathan Duarte](https://github.com/jonduarte). Many thanks Jonathan for PR [#3](https://github.com/kematzy/roda-i18n/pull/3)
269
+
270
+ * [Adam Daniels](https://github.com/adam12). Many thanks Adam for PR [#4](https://github.com/kematzy/roda-i18n/pull/4), [#5](https://github.com/kematzy/roda-i18n/pull/5) & [#6](https://github.com/kematzy/roda-i18n/pull/6)
340
271
 
272
+ * [Firas Zaidan](https://github.com/zaidan). Many thanks Firas for PR [#7](https://github.com/kematzy/roda-i18n/pull/7)
273
+
274
+ * [Simon Neutert](https://github.com/simonneutert). Many thanks Simon for PR [#8](https://github.com/kematzy/roda-i18n/pull/8)
341
275
 
342
276
  ## Licence
343
277
 
344
278
  MIT
345
279
 
346
- Copyright: 2015 Kematzy
347
-
348
-
349
-
280
+ Copyright: 2015 - 2024 Kematzy
data/RELEASING.md ADDED
@@ -0,0 +1,7 @@
1
+ # RubyGems Release Process
2
+
3
+ 1. Update/Check the version number in the gemspec file.
4
+ 2. Check the [CHANGELOG](CHANGELOG.md) for all contributions since the last release.
5
+ 3. Update the [README](README.md) in case of any changes.
6
+ 4. Run `bundle install` to update the Gemfile.lock file.
7
+ 5. Run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
data/Rakefile CHANGED
@@ -1,29 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
4
+ require 'rubocop/rake_task'
2
5
  require 'rake/testtask'
3
6
 
7
+ RuboCop::RakeTask.new
8
+
4
9
  Rake::TestTask.new(:spec) do |t|
5
10
  t.libs << 'spec'
6
11
  t.libs << 'lib'
7
12
  t.test_files = FileList['spec/**/*_spec.rb']
8
13
  end
9
14
 
10
- task :default => :spec
11
- task :test => :spec
15
+ task default: %i[rubocop coverage]
16
+
17
+ desc 'alias for spec task'
18
+ task test: :spec
12
19
 
13
20
  desc 'Run specs with coverage'
14
21
  task :coverage do
15
22
  ENV['COVERAGE'] = '1'
16
23
  Rake::Task['spec'].invoke
17
- # `open coverage/index.html` # if OSX
18
- end
19
-
20
- desc 'Run Rubocop report'
21
- task :rubocop do
22
- res = `which rubocop`
23
- if res != ""
24
- `rubocop -f html -o ./rubocop/report.html lib/`
25
- # `open rubocop/report.html` # if OSX
26
- else
27
- puts "\nERROR: 'rubocop' gem is not installed or available. Please install with 'gem install rubocop'."
28
- end
24
+ # `open coverage/index.html` # if OSX
29
25
  end
@@ -1,7 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Roda
2
-
3
4
  module I18n
4
- VERSION = '0.4.0'
5
+ VERSION = '0.6.0'
5
6
  end
6
-
7
7
  end
data/lib/roda/i18n.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'roda'
2
4
  require 'roda/i18n/version'
3
5
  require 'roda/plugins/i18n'