revise_auth 0.4.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +120 -7
- data/app/controllers/revise_auth/email_controller.rb +3 -3
- data/app/controllers/revise_auth/password_controller.rb +2 -2
- data/app/controllers/revise_auth/password_resets_controller.rb +5 -7
- data/app/controllers/revise_auth/registrations_controller.rb +4 -4
- data/app/controllers/revise_auth/sessions_controller.rb +1 -1
- data/app/views/revise_auth/mailer/confirm_email.html.erb +4 -4
- data/app/views/revise_auth/mailer/password_reset.html.erb +3 -4
- data/app/views/revise_auth/password_resets/edit.html.erb +3 -3
- data/app/views/revise_auth/password_resets/new.html.erb +4 -2
- data/app/views/revise_auth/registrations/edit.html.erb +13 -13
- data/app/views/revise_auth/registrations/new.html.erb +5 -3
- data/app/views/revise_auth/sessions/new.html.erb +4 -6
- data/app/views/revise_auth/shared/_links.html.erb +15 -0
- data/config/i18n-tasks.yml +161 -0
- data/config/locales/cs.yml +68 -0
- data/config/locales/de.yml +66 -14
- data/config/locales/el.yml +66 -14
- data/config/locales/en.yml +66 -16
- data/config/locales/es.yml +68 -0
- data/config/locales/fr.yml +66 -14
- data/config/locales/nl.yml +67 -15
- data/config/locales/pt.yml +66 -14
- data/config/locales/tr.yml +66 -14
- data/config/locales/zh-TW.yml +66 -14
- data/lib/generators/revise_auth/model_generator.rb +16 -30
- data/lib/generators/revise_auth/templates/README +4 -1
- data/lib/generators/revise_auth/templates/initializer.rb +5 -0
- data/lib/revise_auth/authentication.rb +1 -1
- data/lib/revise_auth/model.rb +8 -3
- data/lib/revise_auth/test/helpers.rb +16 -0
- data/lib/revise_auth/version.rb +1 -1
- data/lib/revise_auth.rb +10 -0
- metadata +12 -7
- data/lib/tasks/revise_auth_tasks.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1de4a4179dd70dbb344db212f06a055ed6641f877a42164d70470e40e8a1bb3c
|
4
|
+
data.tar.gz: c0b9d5f458248ff21f1e87566fd66258b8c564f01fdafde62ab8051ec0979390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9cd05318740e67028f89d798608bb7ee779b844321003def73c022aca05f18f82d7544af28a7020958779fc34e9bc9820eab69f5f4622ba57f66b343a469329
|
7
|
+
data.tar.gz: e00041b1ec907eafae11c4b52e74807ecfa855f3ad8cd2e5e560ee6e5323c58fd4804d056ab47aa3e9380b15cc40e891ccb9fed654404d7666db927c6eb50bb1
|
data/README.md
CHANGED
@@ -9,20 +9,40 @@ A pure Ruby on Rails authentication system like Devise.
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
|
12
|
+
gem "revise_auth"
|
13
13
|
```
|
14
14
|
|
15
|
-
|
15
|
+
and then run `bundle install`.
|
16
|
+
|
17
|
+
Or run this command:
|
18
|
+
|
16
19
|
```bash
|
17
|
-
|
18
|
-
$ rails db:migrate
|
20
|
+
bundle add "revise_auth"
|
19
21
|
```
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
23
|
-
|
25
|
+
### Models
|
26
|
+
|
27
|
+
ReviseAuth is designed around a single `User` model. Execute the following to generate the `User` model:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
$ rails g revise_auth:model
|
31
|
+
```
|
32
|
+
|
33
|
+
Optionally, you can add other fields such as `first_name` and `last_name`:
|
34
|
+
|
35
|
+
```bash
|
36
|
+
$ rails g revise_auth:model first_name last_name
|
37
|
+
```
|
38
|
+
|
39
|
+
And then run:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
$ rails db:migrate
|
43
|
+
```
|
24
44
|
|
25
|
-
|
45
|
+
#### Roles / Other User Types
|
26
46
|
|
27
47
|
ReviseAuth only works with a single model to keep things simple. We recommend adding roles to handle other types of users.
|
28
48
|
|
@@ -31,6 +51,44 @@ You can accomplish this in a few different ways:
|
|
31
51
|
* A `roles` attribute on the `User` model
|
32
52
|
* The Rolify gem
|
33
53
|
|
54
|
+
### Routes
|
55
|
+
|
56
|
+
The model generator will automatically add ReviseAuth's routes to your router:
|
57
|
+
|
58
|
+
```
|
59
|
+
# config/routes.rb
|
60
|
+
|
61
|
+
revise_auth
|
62
|
+
```
|
63
|
+
|
64
|
+
You will want to define a root path. After login (see below), the user will be redirected to the root path.
|
65
|
+
|
66
|
+
### Filters and Helpers
|
67
|
+
|
68
|
+
To protect your actions from unauthenticated users, you can use the `authenticate_user!` filter:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
before_action :authenticate_user!
|
72
|
+
```
|
73
|
+
|
74
|
+
In your views, you can use `user_signed_in?` to verify if a user is signed in and `current_user` for using the signed in user.
|
75
|
+
|
76
|
+
### Mailer
|
77
|
+
|
78
|
+
ReviseAuth will send some emails:
|
79
|
+
|
80
|
+
* password reset
|
81
|
+
* confirmation instructions
|
82
|
+
|
83
|
+
Make sure you have the default url options set:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
# in config/environments/development.rb
|
87
|
+
config.action_mailer.default_url_options = {host: "localhost", port: 3000}
|
88
|
+
```
|
89
|
+
|
90
|
+
Note: This should be set in all environments.
|
91
|
+
|
34
92
|
## Customizing
|
35
93
|
|
36
94
|
To customize views, you can run:
|
@@ -41,11 +99,22 @@ $ rails g revise_auth:views
|
|
41
99
|
|
42
100
|
This will copy the views into `app/views/revise_auth` in your application.
|
43
101
|
|
102
|
+
### Form Permitted Params
|
103
|
+
|
104
|
+
To customize the form parameters, you can add/remove params in `config/initializers/revise_auth.rb`
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
ReviseAuth.configure do |config|
|
108
|
+
config.sign_up_params += [:time_zone]
|
109
|
+
config.update_params += [:time_zone]
|
110
|
+
end
|
111
|
+
```
|
112
|
+
|
44
113
|
### After Login Path
|
45
114
|
|
46
115
|
After a user logs in they will be redirected to the stashed location or the root path, by default. When a GET request hits `authenticate_user!`, it will stash the request path in the session and redirect back after login.
|
47
116
|
|
48
|
-
To override this, define `after_login_path` in your ApplicationController
|
117
|
+
To override this, define `after_login_path` in your `ApplicationController`. You can also override `ReviseAuthController` and define it there.
|
49
118
|
|
50
119
|
```ruby
|
51
120
|
class ApplicationController < ActionController::Base
|
@@ -71,6 +140,50 @@ authenticated do
|
|
71
140
|
end
|
72
141
|
```
|
73
142
|
|
143
|
+
### Password Length
|
144
|
+
|
145
|
+
The minimum acceptable password length for validation defaults to 12 characters but this can be configured in either `config/initializers/revise_auth.rb` or your environment configuration:
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
ReviseAuth.configure do |config|
|
149
|
+
config.minimum_password_length = 42
|
150
|
+
end
|
151
|
+
```
|
152
|
+
|
153
|
+
## Test helpers
|
154
|
+
|
155
|
+
ReviseAuth comes with handy helpers you can use in your tests:
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
# POST /login with the given user and password
|
159
|
+
login(user, password: "password")
|
160
|
+
# DELETE /logout
|
161
|
+
logout
|
162
|
+
```
|
163
|
+
|
164
|
+
Include the `ReviseAuth::Test::Helpers` module to make them available in your tests.
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
class ActionDispatch::IntegrationTest
|
168
|
+
include ReviseAuth::Test::Helpers
|
169
|
+
end
|
170
|
+
```
|
171
|
+
|
172
|
+
Then in your tests:
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
class MyControllerTest < ActionDispatch::IntegrationTest
|
176
|
+
setup do
|
177
|
+
@user = users(:bob)
|
178
|
+
login @user
|
179
|
+
end
|
180
|
+
|
181
|
+
test "..." do
|
182
|
+
# ...
|
183
|
+
end
|
184
|
+
end
|
185
|
+
```
|
186
|
+
|
74
187
|
## Contributing
|
75
188
|
|
76
189
|
If you have an issue you'd like to submit, please do so using the issue tracker in GitHub. In order for us to help you in the best way possible, please be as detailed as you can.
|
@@ -4,17 +4,17 @@ class ReviseAuth::EmailController < ReviseAuthController
|
|
4
4
|
# GET /profile/email?confirmation_token=abcdef
|
5
5
|
def show
|
6
6
|
if User.find_by_token_for(:email_verification, params[:confirmation_token])&.confirm_email_change
|
7
|
-
flash[:notice] =
|
7
|
+
flash[:notice] = t(".email_confirmed")
|
8
8
|
redirect_to(user_signed_in? ? profile_path : root_path)
|
9
9
|
else
|
10
|
-
redirect_to root_path, alert:
|
10
|
+
redirect_to root_path, alert: t(".email_confirm_failed")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def update
|
15
15
|
if current_user.update(email_params)
|
16
16
|
current_user.send_confirmation_instructions
|
17
|
-
flash[:notice] =
|
17
|
+
flash[:notice] = t(".confirmation_email_sent", email: current_user.unconfirmed_email)
|
18
18
|
end
|
19
19
|
|
20
20
|
redirect_to profile_path
|
@@ -3,9 +3,9 @@ class ReviseAuth::PasswordController < ReviseAuthController
|
|
3
3
|
|
4
4
|
def update
|
5
5
|
if current_user.update(password_params)
|
6
|
-
redirect_to profile_path, notice:
|
6
|
+
redirect_to profile_path, notice: t(".password_changed")
|
7
7
|
else
|
8
|
-
flash[:alert] =
|
8
|
+
flash[:alert] = t(".incorrect_password")
|
9
9
|
render "revise_auth/registrations/edit", status: :unprocessable_entity
|
10
10
|
end
|
11
11
|
end
|
@@ -6,12 +6,10 @@ class ReviseAuth::PasswordResetsController < ReviseAuthController
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def create
|
9
|
-
|
10
|
-
|
11
|
-
ReviseAuth::Mailer.with(user: user, token: token).password_reset.deliver_later
|
12
|
-
end
|
9
|
+
user = User.find_by(email: user_params[:email])
|
10
|
+
user&.send_password_reset_instructions
|
13
11
|
|
14
|
-
flash[:notice] =
|
12
|
+
flash[:notice] = t(".password_reset_sent")
|
15
13
|
redirect_to login_path
|
16
14
|
end
|
17
15
|
|
@@ -20,7 +18,7 @@ class ReviseAuth::PasswordResetsController < ReviseAuthController
|
|
20
18
|
|
21
19
|
def update
|
22
20
|
if @user.update(password_params)
|
23
|
-
flash[:notice] =
|
21
|
+
flash[:notice] = t("revise_auth.password.update.password_changed")
|
24
22
|
redirect_to login_path
|
25
23
|
else
|
26
24
|
render :edit, status: :unprocessable_entity
|
@@ -34,7 +32,7 @@ class ReviseAuth::PasswordResetsController < ReviseAuthController
|
|
34
32
|
|
35
33
|
return if @user.present?
|
36
34
|
|
37
|
-
flash[:alert] =
|
35
|
+
flash[:alert] = t(".invalid_password_link")
|
38
36
|
redirect_to new_password_reset_path
|
39
37
|
end
|
40
38
|
|
@@ -20,7 +20,7 @@ class ReviseAuth::RegistrationsController < ReviseAuthController
|
|
20
20
|
|
21
21
|
def update
|
22
22
|
if current_user.update(profile_params)
|
23
|
-
redirect_to profile_path, notice:
|
23
|
+
redirect_to profile_path, notice: t(".account_updated")
|
24
24
|
else
|
25
25
|
render :edit, status: :unprocessable_entity
|
26
26
|
end
|
@@ -29,16 +29,16 @@ class ReviseAuth::RegistrationsController < ReviseAuthController
|
|
29
29
|
def destroy
|
30
30
|
current_user.destroy
|
31
31
|
logout
|
32
|
-
redirect_to root_path, status: :see_other, alert:
|
32
|
+
redirect_to root_path, status: :see_other, alert: t(".account_deleted")
|
33
33
|
end
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def sign_up_params
|
38
|
-
params.require(:user).permit(
|
38
|
+
params.require(:user).permit(ReviseAuth.sign_up_params)
|
39
39
|
end
|
40
40
|
|
41
41
|
def profile_params
|
42
|
-
params.require(:user).permit(
|
42
|
+
params.require(:user).permit(ReviseAuth.update_params)
|
43
43
|
end
|
44
44
|
end
|
@@ -7,7 +7,7 @@ class ReviseAuth::SessionsController < ReviseAuthController
|
|
7
7
|
login(user)
|
8
8
|
redirect_to resolve_after_login_path
|
9
9
|
else
|
10
|
-
flash[:alert] =
|
10
|
+
flash[:alert] = t(".invalid_email_or_password")
|
11
11
|
render :new, status: :unprocessable_entity
|
12
12
|
end
|
13
13
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
<p
|
1
|
+
<p><%=t ".welcome", email: @user.unconfirmed_email %></p>
|
2
2
|
|
3
|
-
<p
|
3
|
+
<p><%=t ".confirm_below" %></p>
|
4
4
|
|
5
|
-
<p><%= link_to "
|
5
|
+
<p><%= link_to t(".confirm"), profile_email_url(confirmation_token: @token) %></p>
|
6
6
|
|
7
|
-
<p
|
7
|
+
<p><%=t ".expiration_notice" %></p>
|
@@ -1,6 +1,5 @@
|
|
1
|
-
<p
|
2
|
-
the link below to finish up. If it wasn't you, you can simply ignore this email.</p>
|
1
|
+
<p><%=t ".reset_password_below" %></p>
|
3
2
|
|
4
|
-
<p><%= link_to "
|
3
|
+
<p><%= link_to t(".reset_password"), edit_password_reset_url(token: @token) %></p>
|
5
4
|
|
6
|
-
<p
|
5
|
+
<p><%=t ".expiration_notice" %></p>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<h1
|
1
|
+
<h1><%=t ".reset_password" %></h1>
|
2
2
|
|
3
|
-
<%= form_with model: @user, url:
|
3
|
+
<%= form_with model: @user, url: password_reset_path do |form| %>
|
4
4
|
<% if form.object.errors.any? %>
|
5
5
|
<ul>
|
6
6
|
<% form.object.errors.full_messages.each do |message| %>
|
@@ -20,6 +20,6 @@
|
|
20
20
|
</div>
|
21
21
|
|
22
22
|
<div>
|
23
|
-
<%= form.button "
|
23
|
+
<%= form.button t(".reset_password") %>
|
24
24
|
</div>
|
25
25
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<h1
|
1
|
+
<h1><%=t ".send_password_reset_instructions" %></h1>
|
2
2
|
|
3
3
|
<%= form_with model: @user, url: password_resets_path do |form| %>
|
4
4
|
<% if form.object.errors.any? %>
|
@@ -15,6 +15,8 @@
|
|
15
15
|
</div>
|
16
16
|
|
17
17
|
<div>
|
18
|
-
<%= form.button "
|
18
|
+
<%= form.button t(".send_password_reset_instructions") %>
|
19
19
|
</div>
|
20
20
|
<% end %>
|
21
|
+
|
22
|
+
<%= render "revise_auth/shared/links" %>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<h1
|
1
|
+
<h1><%=t ".profile" %></h1>
|
2
2
|
|
3
3
|
<%= form_with model: current_user, url: profile_email_path do |form| %>
|
4
4
|
<fieldset>
|
5
|
-
<legend
|
5
|
+
<legend><%=t ".change_email_address" %></legend>
|
6
6
|
|
7
7
|
<% if current_user.unconfirmed_email? %>
|
8
|
-
<p
|
8
|
+
<p><%=t ".waiting_confirmation", email: current_user.unconfirmed_email %></p>
|
9
9
|
<% end %>
|
10
10
|
|
11
11
|
<% if form.object.errors.any? %>
|
@@ -16,23 +16,23 @@
|
|
16
16
|
</ul>
|
17
17
|
<% end %>
|
18
18
|
|
19
|
-
<p
|
20
|
-
<p
|
19
|
+
<p><%=t ".current_email_address", email: current_user.email %></p>
|
20
|
+
<p><%=t ".confirmation_instructions" %></p>
|
21
21
|
|
22
22
|
<div>
|
23
|
-
<%= form.label :unconfirmed_email, "
|
23
|
+
<%= form.label :unconfirmed_email, t(".new_email") %>
|
24
24
|
<%= form.email_field :unconfirmed_email, required: true %>
|
25
25
|
</div>
|
26
26
|
|
27
27
|
<div>
|
28
|
-
<%= form.button "
|
28
|
+
<%= form.button t(".save") %>
|
29
29
|
</div>
|
30
30
|
</fieldset>
|
31
31
|
<% end %>
|
32
32
|
|
33
33
|
<%= form_with model: current_user, url: profile_password_path do |form| %>
|
34
34
|
<fieldset>
|
35
|
-
<legend
|
35
|
+
<legend><%=t ".change_password" %></legend>
|
36
36
|
|
37
37
|
<% if form.object.errors.any? %>
|
38
38
|
<ul>
|
@@ -43,12 +43,12 @@
|
|
43
43
|
<% end %>
|
44
44
|
|
45
45
|
<div>
|
46
|
-
<%= form.label :password_challenge
|
46
|
+
<%= form.label :password_challenge %>
|
47
47
|
<%= form.password_field :password_challenge, required: true %>
|
48
48
|
</div>
|
49
49
|
|
50
50
|
<div>
|
51
|
-
<%= form.label :password, "
|
51
|
+
<%= form.label :password, t(".new_password") %>
|
52
52
|
<%= form.password_field :password, required: true %>
|
53
53
|
</div>
|
54
54
|
|
@@ -58,14 +58,14 @@
|
|
58
58
|
</div>
|
59
59
|
|
60
60
|
<div>
|
61
|
-
<%= form.button "
|
61
|
+
<%= form.button t(".save") %>
|
62
62
|
</div>
|
63
63
|
</fieldset>
|
64
64
|
<% end %>
|
65
65
|
|
66
66
|
<%= form_with url: profile_path, method: :delete do |form| %>
|
67
67
|
<fieldset>
|
68
|
-
<legend
|
69
|
-
<%= form.button "
|
68
|
+
<legend><%=t ".delete_account" %></legend>
|
69
|
+
<%= form.button t(".delete_account"), data: { turbo_confirm: t(".confirm") } %>
|
70
70
|
</fieldset>
|
71
71
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<h1
|
1
|
+
<h1><%=t ".sign_up" %></h1>
|
2
2
|
|
3
3
|
<%= form_with model: @user, url: sign_up_path do |form| %>
|
4
4
|
<% if form.object.errors.any? %>
|
@@ -6,9 +6,9 @@
|
|
6
6
|
<% form.object.errors.full_messages.each do |message| %>
|
7
7
|
<li><%= message %></li>
|
8
8
|
<% end %>
|
9
|
-
</ul>
|
10
9
|
<% end %>
|
11
10
|
|
11
|
+
</ul>
|
12
12
|
<div>
|
13
13
|
<%= form.label :email %>
|
14
14
|
<%= form.email_field :email, required: true, autofocus: true %>
|
@@ -25,6 +25,8 @@
|
|
25
25
|
</div>
|
26
26
|
|
27
27
|
<div>
|
28
|
-
<%= form.button "
|
28
|
+
<%= form.button t(".sign_up") %>
|
29
29
|
</div>
|
30
30
|
<% end %>
|
31
|
+
|
32
|
+
<%= render "revise_auth/shared/links" %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<h1
|
1
|
+
<h1><%=t ".log_in" %></h1>
|
2
2
|
|
3
3
|
<%= form_with url: login_path do |form| %>
|
4
4
|
<div>
|
@@ -12,10 +12,8 @@
|
|
12
12
|
</div>
|
13
13
|
|
14
14
|
<div>
|
15
|
-
<%= form.button "
|
16
|
-
</div>
|
17
|
-
|
18
|
-
<div>
|
19
|
-
<%= link_to "Reset your password", new_password_reset_path %>
|
15
|
+
<%= form.button t(".log_in") %>
|
20
16
|
</div>
|
21
17
|
<% end %>
|
18
|
+
|
19
|
+
<%= render "revise_auth/shared/links" %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% if controller_name == "sessions" %>
|
2
|
+
<div>
|
3
|
+
<%= link_to t(".reset_password"), new_password_reset_path %>
|
4
|
+
</div>
|
5
|
+
<% else %>
|
6
|
+
<div>
|
7
|
+
<%= link_to t(".log_in"), login_path %>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<% if controller_name != "registrations" %>
|
12
|
+
<div>
|
13
|
+
<%= link_to t(".sign_up"), sign_up_path %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
@@ -0,0 +1,161 @@
|
|
1
|
+
# i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
|
2
|
+
|
3
|
+
# The "main" locale.
|
4
|
+
base_locale: en
|
5
|
+
## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
|
6
|
+
# locales: [es, fr]
|
7
|
+
## Reporting locale, default: en. Available: en, ru.
|
8
|
+
# internal_locale: en
|
9
|
+
|
10
|
+
# Read and write translations.
|
11
|
+
data:
|
12
|
+
## Translations are read from the file system. Supported format: YAML, JSON.
|
13
|
+
## Provide a custom adapter:
|
14
|
+
# adapter: I18n::Tasks::Data::FileSystem
|
15
|
+
|
16
|
+
# Locale files or `Find.find` patterns where translations are read from:
|
17
|
+
read:
|
18
|
+
## Default:
|
19
|
+
# - config/locales/%{locale}.yml
|
20
|
+
## More files:
|
21
|
+
# - config/locales/**/*.%{locale}.yml
|
22
|
+
|
23
|
+
# Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
|
24
|
+
# `i18n-tasks normalize -p` will force move the keys according to these rules
|
25
|
+
write:
|
26
|
+
## For example, write devise and simple form keys to their respective files:
|
27
|
+
# - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
|
28
|
+
## Catch-all default:
|
29
|
+
# - config/locales/%{locale}.yml
|
30
|
+
|
31
|
+
# External locale data (e.g. gems).
|
32
|
+
# This data is not considered unused and is never written to.
|
33
|
+
external:
|
34
|
+
## Example (replace %#= with %=):
|
35
|
+
# - "<%#= %x[bundle info vagrant --path].chomp %>/templates/locales/%{locale}.yml"
|
36
|
+
|
37
|
+
## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
|
38
|
+
# router: conservative_router
|
39
|
+
|
40
|
+
yaml:
|
41
|
+
write:
|
42
|
+
# do not wrap lines at 80 characters
|
43
|
+
line_width: -1
|
44
|
+
|
45
|
+
## Pretty-print JSON:
|
46
|
+
# json:
|
47
|
+
# write:
|
48
|
+
# indent: ' '
|
49
|
+
# space: ' '
|
50
|
+
# object_nl: "\n"
|
51
|
+
# array_nl: "\n"
|
52
|
+
|
53
|
+
# Find translate calls
|
54
|
+
search:
|
55
|
+
## Paths or `Find.find` patterns to search in:
|
56
|
+
# paths:
|
57
|
+
# - app/
|
58
|
+
|
59
|
+
## Root directories for relative keys resolution.
|
60
|
+
# relative_roots:
|
61
|
+
# - app/controllers
|
62
|
+
# - app/helpers
|
63
|
+
# - app/mailers
|
64
|
+
# - app/presenters
|
65
|
+
# - app/views
|
66
|
+
|
67
|
+
## Directories where method names which should not be part of a relative key resolution.
|
68
|
+
# By default, if a relative translation is used inside a method, the name of the method will be considered part of the resolved key.
|
69
|
+
# Directories listed here will not consider the name of the method part of the resolved key
|
70
|
+
#
|
71
|
+
# relative_exclude_method_name_paths:
|
72
|
+
# -
|
73
|
+
|
74
|
+
## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
|
75
|
+
## *.jpg *.jpeg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less
|
76
|
+
## *.yml *.json *.zip *.tar.gz *.swf *.flv *.mp3 *.wav *.flac *.webm *.mp4 *.ogg *.opus *.webp *.map *.xlsx
|
77
|
+
exclude:
|
78
|
+
- app/assets/images
|
79
|
+
- app/assets/fonts
|
80
|
+
- app/assets/videos
|
81
|
+
- app/assets/builds
|
82
|
+
|
83
|
+
## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
|
84
|
+
## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
|
85
|
+
# only: ["*.rb", "*.html.slim"]
|
86
|
+
|
87
|
+
## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`.
|
88
|
+
# strict: true
|
89
|
+
|
90
|
+
## Allows adding ast_matchers for finding translations using the AST-scanners
|
91
|
+
## The available matchers are:
|
92
|
+
## - RailsModelMatcher
|
93
|
+
## Matches ActiveRecord translations like
|
94
|
+
## User.human_attribute_name(:email) and User.model_name.human
|
95
|
+
##
|
96
|
+
## To implement your own, please see `I18n::Tasks::Scanners::AstMatchers::BaseMatcher`.
|
97
|
+
# <%# I18n::Tasks.add_ast_matcher('I18n::Tasks::Scanners::AstMatchers::RailsModelMatcher') %>
|
98
|
+
|
99
|
+
## Multiple scanners can be used. Their results are merged.
|
100
|
+
## The options specified above are passed down to each scanner. Per-scanner options can be specified as well.
|
101
|
+
## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example
|
102
|
+
|
103
|
+
## Translation Services
|
104
|
+
# translation:
|
105
|
+
# # Google Translate
|
106
|
+
# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
|
107
|
+
# google_translate_api_key: "AbC-dEf5"
|
108
|
+
# # DeepL Pro Translate
|
109
|
+
# # Get an API key and subscription at https://www.deepl.com/pro to use DeepL Pro
|
110
|
+
# deepl_api_key: "48E92789-57A3-466A-9959-1A1A1A1A1A1A"
|
111
|
+
# # deepl_host: "https://api.deepl.com"
|
112
|
+
# # deepl_version: "v2"
|
113
|
+
# # add additional options to the DeepL.translate call: https://www.deepl.com/docs-api/translate-text/translate-text/
|
114
|
+
# deepl_options:
|
115
|
+
# formality: prefer_less
|
116
|
+
## Do not consider these keys missing:
|
117
|
+
# ignore_missing:
|
118
|
+
# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
|
119
|
+
# - '{devise,simple_form}.*'
|
120
|
+
ignore_missing:
|
121
|
+
- revise_auth.password_resets.set_user.invalid_password_link
|
122
|
+
|
123
|
+
## Consider these keys used:
|
124
|
+
# ignore_unused:
|
125
|
+
# - 'activerecord.attributes.*'
|
126
|
+
# - '{devise,kaminari,will_paginate}.*'
|
127
|
+
# - 'simple_form.{yes,no}'
|
128
|
+
# - 'simple_form.{placeholders,hints,labels}.*'
|
129
|
+
# - 'simple_form.{error_notification,required}.:'
|
130
|
+
ignore_unused:
|
131
|
+
- "activerecord.attributes.*"
|
132
|
+
- "revise_auth.sign_up_or_login"
|
133
|
+
- "revise_auth.password_resets.edit.invalid_password_link"
|
134
|
+
|
135
|
+
## Exclude these keys from the `i18n-tasks eq-base' report:
|
136
|
+
# ignore_eq_base:
|
137
|
+
# all:
|
138
|
+
# - common.ok
|
139
|
+
# fr,es:
|
140
|
+
# - common.brand
|
141
|
+
|
142
|
+
## Exclude these keys from the `i18n-tasks check-consistent-interpolations` report:
|
143
|
+
# ignore_inconsistent_interpolations:
|
144
|
+
# - 'activerecord.attributes.*'
|
145
|
+
|
146
|
+
## Ignore these keys completely:
|
147
|
+
# ignore:
|
148
|
+
# - kaminari.*
|
149
|
+
|
150
|
+
## Sometimes, it isn't possible for i18n-tasks to match the key correctly,
|
151
|
+
## e.g. in case of a relative key defined in a helper method.
|
152
|
+
## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.:
|
153
|
+
#
|
154
|
+
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
|
155
|
+
# only: %w(*.html.haml *.html.slim),
|
156
|
+
# patterns: [['= title\b', '.page_title']] %>
|
157
|
+
#
|
158
|
+
# The PatternMapper can also match key literals via a special %{key} interpolation, e.g.:
|
159
|
+
#
|
160
|
+
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
|
161
|
+
# patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %>
|