devise-i18n 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/VERSION +1 -1
  4. data/app/views/devise/confirmations/new.html.erb +9 -5
  5. data/app/views/devise/mailer/confirmation_instructions.html.erb +3 -4
  6. data/app/views/devise/mailer/password_change.html.erb +2 -2
  7. data/app/views/devise/mailer/reset_password_instructions.html.erb +5 -5
  8. data/app/views/devise/mailer/unlock_instructions.html.erb +4 -4
  9. data/app/views/devise/passwords/edit.html.erb +13 -7
  10. data/app/views/devise/passwords/new.html.erb +9 -5
  11. data/app/views/devise/registrations/edit.html.erb +25 -17
  12. data/app/views/devise/registrations/new.html.erb +17 -9
  13. data/app/views/devise/sessions/new.html.erb +19 -10
  14. data/app/views/devise/shared/_links.html.erb +6 -6
  15. data/app/views/devise/unlocks/new.html.erb +9 -5
  16. data/lib/generators/devise/{views/locale → i18n}/locale_generator.rb +2 -2
  17. data/lib/generators/devise/i18n/views_generator.rb +105 -0
  18. data/rails/locales/ar.yml +2 -0
  19. data/rails/locales/az.yml +2 -0
  20. data/rails/locales/bg.yml +2 -0
  21. data/rails/locales/bn.yml +2 -0
  22. data/rails/locales/bs.yml +2 -0
  23. data/rails/locales/ca.yml +2 -0
  24. data/rails/locales/cs.yml +5 -3
  25. data/rails/locales/da.yml +2 -0
  26. data/rails/locales/de-CH.yml +5 -3
  27. data/rails/locales/de.yml +4 -2
  28. data/rails/locales/el.yml +2 -0
  29. data/rails/locales/en-GB.yml +2 -0
  30. data/rails/locales/en.yml +2 -0
  31. data/rails/locales/es-MX.yml +5 -3
  32. data/rails/locales/es.yml +3 -1
  33. data/rails/locales/et.yml +2 -0
  34. data/rails/locales/fa.yml +2 -0
  35. data/rails/locales/fi.yml +21 -19
  36. data/rails/locales/fr-CA.yml +7 -5
  37. data/rails/locales/fr.yml +2 -0
  38. data/rails/locales/he.yml +2 -0
  39. data/rails/locales/hr.yml +2 -0
  40. data/rails/locales/hu.yml +2 -0
  41. data/rails/locales/id.yml +48 -46
  42. data/rails/locales/is.yml +2 -0
  43. data/rails/locales/it.yml +2 -0
  44. data/rails/locales/ja.yml +2 -0
  45. data/rails/locales/ko.yml +2 -0
  46. data/rails/locales/lt.yml +2 -0
  47. data/rails/locales/lv.yml +2 -0
  48. data/rails/locales/my.yml +2 -0
  49. data/rails/locales/nb.yml +2 -0
  50. data/rails/locales/nl.yml +2 -0
  51. data/rails/locales/nn-NO.yml +120 -0
  52. data/rails/locales/no.yml +2 -0
  53. data/rails/locales/pl.yml +3 -1
  54. data/rails/locales/pt-BR.yml +2 -0
  55. data/rails/locales/pt.yml +2 -0
  56. data/rails/locales/ro.yml +50 -48
  57. data/rails/locales/ru.yml +5 -3
  58. data/rails/locales/sk.yml +2 -0
  59. data/rails/locales/sl.yml +2 -0
  60. data/rails/locales/sr-RS.yml +2 -0
  61. data/rails/locales/sr.yml +2 -0
  62. data/rails/locales/sv.yml +2 -0
  63. data/rails/locales/th.yml +2 -0
  64. data/rails/locales/tr.yml +5 -3
  65. data/rails/locales/uk.yml +2 -0
  66. data/rails/locales/vi.yml +2 -0
  67. data/rails/locales/zh-CN.yml +2 -0
  68. data/rails/locales/zh-HK.yml +2 -0
  69. data/rails/locales/zh-TW.yml +2 -0
  70. metadata +5 -4
  71. data/lib/generators/devise/views/i18n_templates/i18n_templates_generator.rb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5478e90a0ef44722c730d2349451fbd8b706e88
4
- data.tar.gz: 5be9e381ae5990f7920bb23aee2f18016e1492ae
3
+ metadata.gz: a89a0c24c1f3bf8a59e845f155b51283d809453e
4
+ data.tar.gz: d408786d64fe433285e540d5662f265e6f1f272c
5
5
  SHA512:
6
- metadata.gz: e23115dca727a2132c7e78c8bbf75ec7c76f91b58603e49a731e04732093a1905bd7145bdbc23d48e0be38d4b6c1f24d7d772ee245179c709bd3bf86595434ca
7
- data.tar.gz: e346d211dfa6ed2d896e2412e07fc9cab675a1e393413a1502307e99ca6aae75e9797ddaa13b830b5129f9d74d5eee5db88eaa7d3e80b79dbe66e745d3188475
6
+ metadata.gz: b8fa3d1ef3b0115ad4fd5a1926f481325efd3582826027f239eada99018e38831c41b830798b7903f5dfd0ee87303230c13420c70b3f79bfbed3a2199dc50113
7
+ data.tar.gz: af1b9e8d1d0bb2a42fcce5ec6ecfc31cadf5115e4987e41fda66db478ae14ce85fb4ad191154fbdddc5153fb432bbfa1cec8b23aa051184dc37b98cc6139983a
data/README.md CHANGED
@@ -18,13 +18,14 @@ gem 'devise-i18n'
18
18
 
19
19
  Assuming you have _not_ previously generated Devise's views into your project, that's all you need to do. If you _have_ previously done this, you will need to regenerate your views (see the next section) and then reapply whatever customizations that made you do this in the first place.
20
20
 
21
+ NOTE: If you have the ```simple_form``` gem in your Gemfile, this command will generate the corresponding views using the simple_form form builder.
21
22
 
22
23
  ## Customizing views
23
24
 
24
- The `devise:views:i18n_templates` generator will copy all devise-i18n's views to your application so that you can modify the files as you wish.
25
+ The `devise:i18n:views` generator will copy all devise-i18n's views to your application so that you can modify the files as you wish.
25
26
 
26
27
  ``` sh
27
- rails g devise:views:i18n_templates
28
+ rails g devise:i18n:views
28
29
  ```
29
30
  You should only do this if you really need to, though, because doing this will make it so that you won't get the updated views should they change in a future version of devise-i18n. To "uncustomize" the views, just delete them, and your app will go back to grabbing devise-i18n's default views.
30
31
 
@@ -33,10 +34,10 @@ You should only do this if you really need to, though, because doing this will m
33
34
 
34
35
  If, for whatever reason, you want to change devise-i18n's translations, you can generate the locale file into your project with
35
36
  ``` sh
36
- rails g devise:views:locale it
37
+ rails g devise:i18n:locale it
37
38
  ```
38
39
 
39
- which will generate `config/locales/devise.it.yml`. If you're doing this to add a missing translation or to improve an existing one, it'd be nice if you could share your suggestions with us!
40
+ which will generate `config/locales/devise.views.it.yml`. If you're doing this to add a missing translation or to improve an existing one, it'd be nice if you could share your suggestions with us!
40
41
 
41
42
 
42
43
  ## Contributing translations to devise-i18n
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.1.0
@@ -1,12 +1,16 @@
1
- <h2><%= t('.resend_confirmation_instructions', :default => 'Resend confirmation instructions') %></h2>
1
+ <h2><%= t('.resend_confirmation_instructions') %></h2>
2
2
 
3
- <%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
3
+ <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
- <div><%= f.label :email %><br />
7
- <%= f.email_field :email %></div>
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
9
+ </div>
8
10
 
9
- <div><%= f.submit t('.resend_confirmation_instructions', :default => 'Resend confirmation instructions') %></div>
11
+ <div class="actions">
12
+ <%= f.submit t('.resend_confirmation_instructions') %>
13
+ </div>
10
14
  <% end %>
11
15
 
12
16
  <%= render "devise/shared/links" %>
@@ -1,6 +1,5 @@
1
1
  <% require 'devise/version' %>
2
- <p><%= t('.greeting', :recipient => @resource.email, :default => "Welcome #{@resource.email}!") %></p>
2
+ <p><%= t('.greeting', recipient: @resource.email) %></p>
3
3
 
4
- <p><%= t('.instruction', :default => "You can confirm your account email through the link below:") %></p>
5
- <p><%= link_to t('.action', :default => "Confirm my account"),
6
- confirmation_url(@resource, :confirmation_token => (Devise::VERSION.start_with?('3.') ? @token : @resource.confirmation_token)) %></p>
4
+ <p><%= t('.instruction') %></p>
5
+ <p><%= link_to t('.action'), confirmation_url(@resource, confirmation_token: (Devise::VERSION.start_with?('3.') ? @token : @resource.confirmation_token)) %></p>
@@ -1,4 +1,4 @@
1
1
  <% require 'devise/version' %>
2
- <p><%= t('.greeting', :recipient => @resource.email, :default => "Hello #{@resource.email}!") %></p>
2
+ <p><%= t('.greeting', recipient: @resource.email) %></p>
3
3
 
4
- <p><%= t('.message', :default => "We're contacting you to notify you that your password has been changed.") %></p>
4
+ <p><%= t('.message') %></p>
@@ -1,9 +1,9 @@
1
1
  <% require 'devise/version' %>
2
- <p><%= t('.greeting', :recipient => @resource.email, :default => "Hello #{@resource.email}!") %></p>
2
+ <p><%= t('.greeting', recipient: @resource.email) %></p>
3
3
 
4
- <p><%= t('.instruction', :default => "Someone has requested a link to change your password, and you can do this through the link below.") %></p>
4
+ <p><%= t('.instruction') %></p>
5
5
 
6
- <p><%= link_to t('.action', :default => "Change my password"), edit_password_url(@resource, :reset_password_token => (Devise::VERSION.start_with?('3.') ? @token : @resource.reset_password_token)) %></p>
6
+ <p><%= link_to t('.action'), edit_password_url(@resource, reset_password_token: (Devise::VERSION.start_with?('3.', '4.') ? @token : @resource.reset_password_token)) %></p>
7
7
 
8
- <p><%= t('.instruction_2', :default => "If you didn't request this, please ignore this email.") %></p>
9
- <p><%= t('.instruction_3', :default => "Your password won't change until you access the link above and create a new one.") %></p>
8
+ <p><%= t('.instruction_2') %></p>
9
+ <p><%= t('.instruction_3') %></p>
@@ -1,8 +1,8 @@
1
1
  <% require 'devise/version' %>
2
- <p><%= t('.greeting', :recipient => @resource.email, :default => "Hello #{@resource.email}!") %></p>
2
+ <p><%= t('.greeting', recipient: @resource.email) %></p>
3
3
 
4
- <p><%= t('.message', :default => "Your account has been locked due to an excessive amount of unsuccessful sign in attempts.") %></p>
4
+ <p><%= t('.message') %></p>
5
5
 
6
- <p><%= t('.instruction', :default => "Click the link below to unlock your account:") %></p>
6
+ <p><%= t('.instruction') %></p>
7
7
 
8
- <p><%= link_to t('.action', :default => "Unlock my account"), unlock_url(@resource, :unlock_token => (Devise::VERSION.start_with?('3.') ? @token :@resource.unlock_token)) %></p>
8
+ <p><%= link_to t('.action'), unlock_url(@resource, unlock_token: (Devise::VERSION.start_with?('3.') ? @token :@resource.unlock_token)) %></p>
@@ -1,16 +1,22 @@
1
- <h2><%= t('.change_your_password', :default => 'Change your password') %></h2>
1
+ <h2><%= t('.change_your_password') %></h2>
2
2
 
3
- <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
3
+ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
  <%= f.hidden_field :reset_password_token %>
6
6
 
7
- <div><%= f.label :password, t('.new_password', :default => 'New password') %><br />
8
- <%= f.password_field :password %></div>
7
+ <div class="field">
8
+ <%= f.label :password, t('.new_password') %><br />
9
+ <%= f.password_field :password, autocomplete: "off" %>
10
+ </div>
9
11
 
10
- <div><%= f.label :password_confirmation, t('.confirm_new_password', :default => 'Confirm new password') %><br />
11
- <%= f.password_field :password_confirmation %></div>
12
+ <div class="field">
13
+ <%= f.label :password_confirmation, t('.confirm_new_password') %><br />
14
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
15
+ </div>
12
16
 
13
- <div><%= f.submit t('.change_my_password', :default => 'Change my password') %></div>
17
+ <div class="actions">
18
+ <%= f.submit t('.change_my_password') %>
19
+ </div>
14
20
  <% end %>
15
21
 
16
22
  <%= render "devise/shared/links" %>
@@ -1,12 +1,16 @@
1
- <h2><%= t('.forgot_your_password', :default => 'Forgot your password?') %></h2>
1
+ <h2><%= t('.forgot_your_password') %></h2>
2
2
 
3
- <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
3
+ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
- <div><%= f.label :email %><br />
7
- <%= f.email_field :email %></div>
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
8
10
 
9
- <div><%= f.submit t('.send_me_reset_password_instructions', :default => "Send me reset password instructions") %></div>
11
+ <div class="actions">
12
+ <%= f.submit t('.send_me_reset_password_instructions') %>
13
+ </div>
10
14
  <% end %>
11
15
 
12
16
  <%= render "devise/shared/links" %>
@@ -1,31 +1,39 @@
1
- <h2><%= t('.title', :resource => resource_class.model_name.human , :default => "Edit #{resource_name.to_s.humanize}") %></h2>
1
+ <h2><%= t('.title', resource: resource_class.model_name.human) %></h2>
2
2
 
3
- <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
3
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
- <div><%= f.label :email %><br />
7
- <%= f.email_field :email %></div>
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email %>
9
+ </div>
8
10
 
9
- <%- if devise_mapping.confirmable? && resource.pending_reconfirmation? -%>
11
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
10
12
  <p>
11
- <%= t('.currently_waiting_confirmation_for_email', :email => resource.unconfirmed_email, :default => "Currently waiting confirmation for: %{email}") %>
13
+ <%= t('.currently_waiting_confirmation_for_email', email: resource.unconfirmed_email) %>
12
14
  </p>
13
- <%- end -%>
15
+ <% end %>
14
16
 
15
- <div><%= f.label :password %> <i>(<%= t('.leave_blank_if_you_don_t_want_to_change_it', :default => "leave blank if you don't want to change it") %>)</i><br />
16
- <%= f.password_field :password, :autocomplete => "off" %></div>
17
+ <div class="field">
18
+ <%= f.label :password %> <i>(<%= t('.leave_blank_if_you_don_t_want_to_change_it') %>)</i><br />
19
+ <%= f.password_field :password, autocomplete: "off" %>
20
+ </div>
17
21
 
18
- <div><%= f.label :password_confirmation %><br />
19
- <%= f.password_field :password_confirmation %></div>
22
+ <div class="field">
23
+ <%= f.label :password_confirmation %><br />
24
+ <%= f.password_field :password_confirmation %>
25
+ </div>
20
26
 
21
- <div><%= f.label :current_password %> <i>(<%= t('.we_need_your_current_password_to_confirm_your_changes', :default => 'we need your current password to confirm your changes') %>)</i><br />
22
- <%= f.password_field :current_password %></div>
27
+ <div class="field">
28
+ <%= f.label :current_password %> <i>(<%= t('.we_need_your_current_password_to_confirm_your_changes') %>)</i><br />
29
+ <%= f.password_field :current_password %>
30
+ </div>
23
31
 
24
- <div><%= f.submit t('.update', :default => "Update") %></div>
32
+ <div><%= f.submit t('.update') %></div>
25
33
  <% end %>
26
34
 
27
- <h3><%= t('.cancel_my_account', :default => 'Cancel my account') %></h3>
35
+ <h3><%= t('.cancel_my_account') %></h3>
28
36
 
29
- <p><%= t('.unhappy', :default => 'Unhappy') %>? <%= link_to t('.cancel_my_account', :default => "Cancel my account"), registration_path(resource_name), :data => { :confirm => t('.are_you_sure', :default => "Are you sure?") }, :method => :delete %>.</p>
37
+ <p><%= t('.unhappy') %>? <%= link_to t('.cancel_my_account'), registration_path(resource_name), data: { confirm: t('.are_you_sure') }, method: :delete %>.</p>
30
38
 
31
- <%= link_to t('devise.shared.links.back', :default => "Back"), :back %>
39
+ <%= link_to t('devise.shared.links.back'), :back %>
@@ -1,18 +1,26 @@
1
- <h2><%= t('.sign_up', :default => "Sign up") %></h2>
1
+ <h2><%= t('.sign_up') %></h2>
2
2
 
3
- <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
3
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
- <div><%= f.label :email %><br />
7
- <%= f.email_field :email %></div>
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
8
10
 
9
- <div><%= f.label :password %><br />
10
- <%= f.password_field :password %></div>
11
+ <div class="field">
12
+ <%= f.label :password %><br />
13
+ <%= f.password_field :password, autocomplete: "off" %>
14
+ </div>
11
15
 
12
- <div><%= f.label :password_confirmation %><br />
13
- <%= f.password_field :password_confirmation %></div>
16
+ <div class="field">
17
+ <%= f.label :password_confirmation %><br />
18
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
19
+ </div>
14
20
 
15
- <div><%= f.submit t('.sign_up', :default => "Sign up") %></div>
21
+ <div class="actions">
22
+ <%= f.submit t('.sign_up') %>
23
+ </div>
16
24
  <% end %>
17
25
 
18
26
  <%= render "devise/shared/links" %>
@@ -1,17 +1,26 @@
1
- <h2><%= t('.sign_in', :default => "Sign in") %></h2>
1
+ <h2><%= t('.sign_in') %></h2>
2
2
 
3
- <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
4
- <div><%= f.label :email %><br />
5
- <%= f.email_field :email %></div>
3
+ <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
4
+ <div class="field">
5
+ <%= f.label :email %><br />
6
+ <%= f.email_field :email, autofocus: true %>
7
+ </div>
6
8
 
7
- <div><%= f.label :password %><br />
8
- <%= f.password_field :password %></div>
9
+ <div class="field">
10
+ <%= f.label :password %><br />
11
+ <%= f.password_field :password, autocomplete: "off" %>
12
+ </div>
9
13
 
10
- <% if devise_mapping.rememberable? -%>
11
- <div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
12
- <% end -%>
14
+ <% if devise_mapping.rememberable? %>
15
+ <div class="field">
16
+ <%= f.check_box :remember_me %>
17
+ <%= f.label :remember_me %>
18
+ </div>
19
+ <% end %>
13
20
 
14
- <div><%= f.submit t('.sign_in', :default => "Sign in") %></div>
21
+ <div class="actions">
22
+ <%= f.submit t('.sign_in') %>
23
+ </div>
15
24
  <% end %>
16
25
 
17
26
  <%= render "devise/shared/links" %>
@@ -1,25 +1,25 @@
1
1
  <%- if controller_name != 'sessions' %>
2
- <%= link_to t(".sign_in", :default => "Sign in"), new_session_path(resource_name) %><br />
2
+ <%= link_to t(".sign_in"), new_session_path(resource_name) %><br />
3
3
  <% end -%>
4
4
 
5
5
  <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
6
- <%= link_to t(".sign_up", :default => "Sign up"), new_registration_path(resource_name) %><br />
6
+ <%= link_to t(".sign_up"), new_registration_path(resource_name) %><br />
7
7
  <% end -%>
8
8
 
9
9
  <%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
10
- <%= link_to t(".forgot_your_password", :default => "Forgot your password?"), new_password_path(resource_name) %><br />
10
+ <%= link_to t(".forgot_your_password"), new_password_path(resource_name) %><br />
11
11
  <% end -%>
12
12
 
13
13
  <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
14
- <%= link_to t('.didn_t_receive_confirmation_instructions', :default => "Didn't receive confirmation instructions?"), new_confirmation_path(resource_name) %><br />
14
+ <%= link_to t('.didn_t_receive_confirmation_instructions'), new_confirmation_path(resource_name) %><br />
15
15
  <% end -%>
16
16
 
17
17
  <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
18
- <%= link_to t('.didn_t_receive_unlock_instructions', :default => "Didn't receive unlock instructions?"), new_unlock_path(resource_name) %><br />
18
+ <%= link_to t('.didn_t_receive_unlock_instructions'), new_unlock_path(resource_name) %><br />
19
19
  <% end -%>
20
20
 
21
21
  <%- if devise_mapping.omniauthable? %>
22
22
  <%- resource_class.omniauth_providers.each do |provider| %>
23
- <%= link_to t('.sign_in_with_provider', :provider => provider.to_s.titleize, :default => "Sign in with #{provider.to_s.titleize}"), omniauth_authorize_path(resource_name, provider) %><br />
23
+ <%= link_to t('.sign_in_with_provider', provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider) %><br />
24
24
  <% end -%>
25
25
  <% end -%>
@@ -1,12 +1,16 @@
1
- <h2><%= t('.resend_unlock_instructions', :default => "Resend unlock instructions") %></h2>
1
+ <h2><%= t('.resend_unlock_instructions') %></h2>
2
2
 
3
- <%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
3
+ <%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
- <div><%= f.label :email %><br />
7
- <%= f.email_field :email %></div>
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
8
10
 
9
- <div><%= f.submit t('.resend_unlock_instructions', :default => "Resend unlock instructions") %></div>
11
+ <div class="actions">
12
+ <%= f.submit t('.resend_unlock_instructions') %>
13
+ </div>
10
14
  <% end %>
11
15
 
12
16
  <%= render "devise/shared/links" %>
@@ -1,7 +1,7 @@
1
1
  module Devise
2
- module Views
2
+ module I18n
3
3
  class LocaleGenerator < Rails::Generators::NamedBase
4
- source_root File.expand_path('../../../../../../rails/locales', __FILE__)
4
+ source_root File.expand_path("../../../../../rails/locales", __FILE__)
5
5
  def copy_locale
6
6
  copy_file("#{name}.yml", Rails.root.join("config", "locales", "devise.views.#{name}.yml"))
7
7
  end
@@ -0,0 +1,105 @@
1
+ module Devise
2
+ module I18n
3
+ module ViewPathTemplates #:nodoc:
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ argument :scope, required: false, default: nil, desc: "The scope to copy views to"
8
+
9
+ class_option :form_builder, aliases: "-b"
10
+ class_option :views, aliases: "-v", type: :array, desc: "Select specific view directories to generate (confirmations, passwords, registrations, sessions, unlocks, mailer)"
11
+
12
+ public_task :copy_views
13
+ end
14
+
15
+ def copy_views
16
+ if options[:views]
17
+ options[:views].each { |directory| view_directory(directory.to_sym) }
18
+ else
19
+ view_directory :confirmations
20
+ view_directory :passwords
21
+ view_directory :registrations
22
+ view_directory :sessions
23
+ view_directory :unlocks
24
+ end
25
+ end
26
+
27
+ protected
28
+
29
+ def view_directory(name, target_path = nil)
30
+ directory name.to_s, target_path || "#{default_target_path}/#{name}" do |content|
31
+ if scope
32
+ content.gsub "devise/shared/links", "#{plural_scope}/shared/links"
33
+ else
34
+ content
35
+ end
36
+ end
37
+ end
38
+
39
+ def default_target_path
40
+ @default_target_path ||= "app/views/#{plural_scope || :devise}"
41
+ end
42
+
43
+ def plural_scope
44
+ @plural_scope ||= scope.presence && scope.underscore.pluralize
45
+ end
46
+ end
47
+
48
+ class SharedViewsGenerator < Rails::Generators::Base #:nodoc:
49
+ include ViewPathTemplates
50
+ source_root File.expand_path("../../../../../app/views/devise", __FILE__)
51
+ desc "Copies shared Devise views to your application."
52
+ hide!
53
+
54
+ # Override copy_views to just copy mailer and shared.
55
+ def copy_views
56
+ view_directory :shared
57
+ end
58
+ end
59
+
60
+ class FormForGenerator < Rails::Generators::Base #:nodoc:
61
+ include ViewPathTemplates
62
+ source_root File.expand_path("../../../../../app/views/devise", __FILE__)
63
+ desc "Copies default Devise views to your application."
64
+ hide!
65
+ end
66
+
67
+ class SimpleFormForGenerator < Rails::Generators::Base #:nodoc:
68
+ include ViewPathTemplates
69
+ source_root File.expand_path("../../templates/simple_form_for", __FILE__)
70
+ desc "Copies simple form enabled views to your application."
71
+ hide!
72
+
73
+ def copy_views
74
+ options[:views].delete("mailer") if options[:views]
75
+ super
76
+ end
77
+ end
78
+
79
+ class MailerViewsGenerator < Rails::Generators::Base #:nodoc:
80
+ include ViewPathTemplates
81
+ source_root File.expand_path("../../../../../app/views/devise", __FILE__)
82
+ desc "Copies Devise mail erb views to your application."
83
+ hide!
84
+
85
+ def copy_views
86
+ if !options[:views] || options[:views].include?("mailer")
87
+ view_directory :mailer
88
+ end
89
+ end
90
+ end
91
+
92
+ class ViewsGenerator < Rails::Generators::Base
93
+ desc "Copies Devise views to your application."
94
+
95
+ argument :scope, required: false, default: nil, desc: "The scope to copy views to"
96
+
97
+ invoke SharedViewsGenerator
98
+ invoke MailerViewsGenerator
99
+
100
+ hook_for :form_builder, aliases: "-b",
101
+ desc: "Form builder to be used",
102
+ default: "i18n:#{defined?(SimpleForm) ? 'simple_form_for' : 'form_for'}"
103
+ end
104
+ end
105
+ end