r18n-rails 3.2.0 → 4.0.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
2
  SHA256:
3
- metadata.gz: 7f79ef5e04b9b51bfd8c698efa9d80aaee1236a845bc008827854c55da5143b0
4
- data.tar.gz: 7f0d7aa7a517a72fb03b6f99b3627fd1fe2dcad6f5a5f5aa4bf7ae44aa304496
3
+ metadata.gz: bffe7c01c01781a342b1dd447c2bf438a307cc5a5c8113e7520af8d4de706787
4
+ data.tar.gz: e261678db0929a8ac27f39e6b91e7f954bde7c363a48e8fee5438d4b6060876e
5
5
  SHA512:
6
- metadata.gz: a6acb6276e10eef4bb7086b1918dfb766278503624a1e3f1b6cb02021404abf06aff66bcac81b61926acad42a10ce721e73595091a2ad493fa5a60eb6ef36b4c
7
- data.tar.gz: 2df93f4f7c9a34fc21dca3be1ca0666c4b32fad915310080b54412ca06f8cdb14286f48657c2a741bf23ad699c85ed899d3e31b1f10e713af976a02b2a42890f
6
+ metadata.gz: e100aec03ba69b888f04bf1bca45e8cd7d2e96b284d29478036e624e559bf9c663c0b1eeedec6dab8fd19fda2de3b45b7ced98d3b695972a2ed8613dbcab2802
7
+ data.tar.gz: 42f6d7bba9aad7561e312417f08c971840500587e2ab75e0a5299d786a89948d7f063891cd8cf523d37afe67040eaaa205ebc01a1c16ba22f7ac7f79bd1b55f9
data/README.md CHANGED
@@ -7,16 +7,16 @@ documentation for more information.
7
7
 
8
8
  ## Features
9
9
 
10
- R18n for Rails is fully compatibile with Rails I18n, and add extra features:
10
+ R18n for Rails is fully compatible with Rails I18n, and add extra features:
11
11
 
12
12
  * Nice Ruby-style syntax.
13
13
  * Filters.
14
14
  * Model Translation (or any Ruby object).
15
- * Autodetect user locales.
15
+ * Auto-detect user locales.
16
16
  * Flexible locales.
17
17
  * Total flexibility.
18
18
 
19
- See full features in [main README](https://github.com/ai/r18n/blob/master/README.md).
19
+ See full features in [main README](https://github.com/r18n/r18n/blob/master/README.md).
20
20
 
21
21
  ## How To
22
22
 
@@ -25,7 +25,7 @@ See full features in [main README](https://github.com/ai/r18n/blob/master/README
25
25
  ```
26
26
  gem 'r18n-rails'
27
27
  ```
28
- Now R18n will autodetect user locales.
28
+ Now R18n will auto-detect user locales.
29
29
  2. Define your way to set locale manually. R18n will find it in
30
30
  `params[:locale]` or `session[:locale]`. Best way is a put optional
31
31
  locale prefix to URLs:
@@ -46,7 +46,7 @@ See full features in [main README](https://github.com/ai/r18n/blob/master/README
46
46
  ```
47
47
 
48
48
  4. Translations in I18n format are stored in
49
- <tt>config/locales/<i>locale</i>.yml</tt>:
49
+ `config/locales/%{locale}.yml`:
50
50
 
51
51
  ```yaml
52
52
  en:
@@ -57,7 +57,7 @@ See full features in [main README](https://github.com/ai/r18n/blob/master/README
57
57
  one: "One user"
58
58
  many: "%{count} users"
59
59
  ```
60
- Translations in R18n format go to <tt>app/i18n/<i>locale</i>.yml</tt>:
60
+ Translations in R18n format go to `app/i18n/%{locale}.yml`:
61
61
 
62
62
  ```yaml
63
63
  user:
@@ -82,7 +82,7 @@ See full features in [main README](https://github.com/ai/r18n/blob/master/README
82
82
  t.user.count(5)
83
83
  ```
84
84
 
85
- 6. Print dates and numbers in users tradition:
85
+ 6. Print dates and numbers in user's tradition:
86
86
 
87
87
  ```ruby
88
88
  l Date.today, :standard #=> "2009-12-20"
@@ -94,7 +94,7 @@ See full features in [main README](https://github.com/ai/r18n/blob/master/README
94
94
  not only for ActiveRecord models
95
95
 
96
96
  1. Add to migration columns for each of the supported locales, named as
97
- <tt><i>name</i>_<i>locale</i></tt>:
97
+ `%{name}_%{locale}`:
98
98
 
99
99
  ```ruby
100
100
  t.string :title_en
@@ -121,8 +121,8 @@ See full features in [main README](https://github.com/ai/r18n/blob/master/README
121
121
  on current user locales.
122
122
 
123
123
  8. Download translations for Rails system messages (validation, etc) from
124
- https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale and
125
- put them to `config/locales/` (because them use Rails I18n format).
124
+ [svenfuchs/rails-i18n](https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale)
125
+ and put them to `config/locales/` (because them use Rails I18n format).
126
126
  9. Add your own translations filters to `app/i18n/filters.rb`:
127
127
 
128
128
  ```ruby
@@ -147,8 +147,8 @@ See full features in [main README](https://github.com/ai/r18n/blob/master/README
147
147
  ## License
148
148
 
149
149
  R18n is licensed under the GNU Lesser General Public License version 3.
150
- You can read it in LICENSE file or in http://www.gnu.org/licenses/lgpl.html.
150
+ You can read it in LICENSE file or in [www.gnu.org/licenses/lgpl-3.0.html](https://www.gnu.org/licenses/lgpl-3.0.html).
151
151
 
152
152
  ## Author
153
153
 
154
- Andrey “A.I.” Sitnik <andrey@sitnik.ru>
154
+ Andrey “A.I.” Sitnik [andrey@sitnik.ru](mailto:andrey@sitnik.ru)
@@ -28,7 +28,7 @@ require_relative 'r18n-rails/filters'
28
28
  R18n.default_places { [Rails.root.join('app/i18n'), R18n::Loader::Rails.new] }
29
29
 
30
30
  ActionController::Base.helper(R18n::Rails::Helpers)
31
- ActionController::Base.send(:include, R18n::Rails::Controller)
31
+ ActionController::Base.include R18n::Rails::Controller
32
32
 
33
33
  if ActionController::Base.respond_to? :before_action
34
34
  ActionController::Base.send(:before_action, :set_r18n)
@@ -52,7 +52,7 @@ ActiveSupport.on_load(:after_initialize) do
52
52
  i18n = R18n::I18n.new(
53
53
  locale, R18n.default_places,
54
54
  off_filters: :untranslated,
55
- on_filters: :untranslated_bash
55
+ on_filters: :untranslated_bash
56
56
  )
57
57
  R18n.set(i18n)
58
58
  else
@@ -29,6 +29,7 @@ module R18n
29
29
  attr_writer :path
30
30
  def path
31
31
  return @path if defined?(@path)
32
+
32
33
  ::Rails.root.join('app/i18n')
33
34
  end
34
35
 
@@ -21,17 +21,17 @@ module R18n
21
21
  module Rails
22
22
  module Helpers
23
23
  # Return current R18n I18n object, to use R18n API:
24
- # * <tt>r18n.available_locales</tt> – available application translations.
25
- # * <tt>r18n.locales</tt> – List of user locales
26
- # * <tt>r18n.reload!</tt> – Reload R18n translations
24
+ # * `r18n.available_locales` – available application translations.
25
+ # * `r18n.locales` – List of user locales
26
+ # * `r18n.reload!` – Reload R18n translations
27
27
  #
28
- # You can get translations by <tt>r18n.user.name</tt>, but +t+ helper is
28
+ # You can get translations by `r18n.user.name`, but `t` helper is
29
29
  # more beautiful, short and also support R18n syntax.
30
30
  def r18n
31
31
  R18n.get
32
32
  end
33
33
 
34
- # Extend +t+ helper to use also R18n syntax.
34
+ # Extend `t` helper to use also R18n syntax.
35
35
  #
36
36
  # t 'user.name' # Rails I18n style
37
37
  # t.user.name # R18n style
@@ -44,7 +44,7 @@ module R18n
44
44
  end
45
45
  alias translate t
46
46
 
47
- # Extend +l+ helper to use also R18n syntax.
47
+ # Extend `l` helper to use also R18n syntax.
48
48
  #
49
49
  # l Time.now # Rails I18n default format
50
50
  # l Time.now, format: :short # Rails I18n style
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.author = 'Andrey Sitnik'
27
27
  s.email = 'andrey@sitnik.ru'
28
- s.homepage = 'https://github.com/ai/r18n/tree/master/r18n-rails'
28
+ s.homepage = 'https://github.com/r18n/r18n/tree/master/r18n-rails'
29
29
  s.license = 'LGPL-3.0'
30
30
 
31
31
  s.add_dependency 'r18n-rails-api', "= #{R18n::VERSION}"
@@ -32,8 +32,8 @@ class TestController < ApplicationController
32
32
  end
33
33
 
34
34
  def time
35
- render plain: l(Time.at(0).utc) + "\n" +
36
- l(Time.at(0).utc, format: :short)
35
+ render plain:
36
+ l(Time.at(0).utc) + "\n" + l(Time.at(0).utc, format: :short)
37
37
  end
38
38
 
39
39
  def human_time
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Fix R18n Rails require, because it doesnt require in global Gemfile.
3
+ # Fix R18n Rails require, because it doesn't require in global Gemfile.
4
4
  require 'r18n-rails'
@@ -21,11 +21,27 @@ describe TestController, type: :controller do
21
21
  expect(response.body).to eq 'ru, en'
22
22
  end
23
23
 
24
- it 'gets locales from http' do
25
- request.env['HTTP_ACCEPT_LANGUAGE'] = 'ru,fr;q=0.9'
26
- get :locales
27
- expect(response).to have_http_status(200)
28
- expect(response.body).to eq 'ru, fr, en'
24
+ describe 'locales from http' do
25
+ it 'gets from regular locales' do
26
+ request.env['HTTP_ACCEPT_LANGUAGE'] = 'ru,fr;q=0.9'
27
+ get :locales
28
+ expect(response).to have_http_status(200)
29
+ expect(response.body).to eq 'ru, fr, en'
30
+ end
31
+
32
+ it 'gets from wildcard' do
33
+ request.env['HTTP_ACCEPT_LANGUAGE'] = '*'
34
+ get :locales
35
+ expect(response).to have_http_status(200)
36
+ expect(response.body).to eq 'ru'
37
+ end
38
+
39
+ it 'gets from regular locales with wildcard' do
40
+ request.env['HTTP_ACCEPT_LANGUAGE'] = 'ru, fr;q=0.9, *;q=0.5'
41
+ get :locales
42
+ expect(response).to have_http_status(200)
43
+ expect(response.body).to eq 'ru, fr, en'
44
+ end
29
45
  end
30
46
 
31
47
  it 'loads translations' do
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ## https://github.com/stevekinney/pizza/issues/103#issuecomment-136052789
4
- ## https://github.com/docker-library/ruby/issues/45
5
- Encoding.default_external = 'UTF-8'
6
-
7
3
  require 'pp'
8
4
 
9
5
  ENV['RAILS_ENV'] ||= 'test'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r18n-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Sitnik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-08 00:00:00.000000000 Z
11
+ date: 2020-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: r18n-rails-api
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.0
19
+ version: 4.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.0
26
+ version: 4.0.0
27
27
  description: |2
28
28
  Out-of-box R18n support for Ruby on Rails.
29
29
  It is just a wrapper for R18n Rails API and R18n core libraries.
@@ -73,7 +73,7 @@ files:
73
73
  - spec/app/db/schema.rb
74
74
  - spec/rails_spec.rb
75
75
  - spec/spec_helper.rb
76
- homepage: https://github.com/ai/r18n/tree/master/r18n-rails
76
+ homepage: https://github.com/r18n/r18n/tree/master/r18n-rails
77
77
  licenses:
78
78
  - LGPL-3.0
79
79
  metadata: {}
@@ -92,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.7.6
95
+ rubygems_version: 3.1.2
97
96
  signing_key:
98
97
  specification_version: 4
99
98
  summary: R18n for Rails