]> git.openstreetmap.org Git - rails.git/commitdiff
Use lazy translation lookups for the oauth controller.
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 25 Apr 2018 07:42:34 +0000 (15:42 +0800)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 25 Apr 2018 07:42:34 +0000 (15:42 +0800)
app/controllers/oauth_controller.rb
app/views/oauth/authorize.html.erb
app/views/oauth/authorize_failure.html.erb
app/views/oauth/authorize_success.html.erb
config/locales/en.yml

index 84bbcf1850e5c95cf6d6d925c0c009b3f7e83315..ae6d0983b8fbcb89f10c9ef123d515b3fc6ccb29 100644 (file)
@@ -30,7 +30,7 @@ class OauthController < ApplicationController
     @token = current_user.oauth_tokens.find_by :token => params[:token]
     if @token
       @token.invalidate!
     @token = current_user.oauth_tokens.find_by :token => params[:token]
     if @token
       @token.invalidate!
-      flash[:notice] = t("oauth.revoke.flash", :application => @token.client_application.name)
+      flash[:notice] = t(".flash", :application => @token.client_application.name)
     end
     redirect_to oauth_clients_url(:display_name => @token.user.display_name)
   end
     end
     redirect_to oauth_clients_url(:display_name => @token.user.display_name)
   end
@@ -41,7 +41,7 @@ class OauthController < ApplicationController
     append_content_security_policy_directives(:form_action => %w[*])
 
     if @token.invalidated?
     append_content_security_policy_directives(:form_action => %w[*])
 
     if @token.invalidated?
-      @message = t "oauth.oauthorize_failure.invalid"
+      @message = t "oauth.authorize_failure.invalid"
       render :action => "authorize_failure"
     elsif request.post?
       if user_authorizes_token?
       render :action => "authorize_failure"
     elsif request.post?
       if user_authorizes_token?
@@ -69,7 +69,7 @@ class OauthController < ApplicationController
         end
       else
         @token.invalidate!
         end
       else
         @token.invalidate!
-        @message = t("oauth.oauthorize_failure.denied", :app_name => @token.client_application.name)
+        @message = t("oauth.authorize_failure.denied", :app_name => @token.client_application.name)
         render :action => "authorize_failure"
       end
     end
         render :action => "authorize_failure"
       end
     end
index 6c8bc3a9e92f8e384d6aae20dd506eb8ced9a5fc..3108c551af65054394244d0cb6d393d7917aea4d 100644 (file)
@@ -1,19 +1,19 @@
 <% content_for :heading do %>
 <% content_for :heading do %>
-  <h1><%= t "oauth.oauthorize.title" %></h1>
+  <h1><%= t ".title" %></h1>
 <% end %>
 
 <% end %>
 
-<p><%= raw t("oauth.oauthorize.request_access", :app_name => link_to(@token.client_application.name, @token.client_application.url), :user => link_to(current_user.display_name, :controller => :user, :action => :view, :display_name => current_user.display_name)) %></p>
+<p><%= raw t(".request_access", :app_name => link_to(@token.client_application.name, @token.client_application.url), :user => link_to(current_user.display_name, :controller => :user, :action => :view, :display_name => current_user.display_name)) %></p>
 
 <%= form_tag authorize_url do %>
   <%= hidden_field_tag "oauth_token", @token.token %>
   <%- if params[:oauth_callback] -%>
     <%= hidden_field_tag "oauth_callback", params[:oauth_callback] %>
   <%- end -%>
 
 <%= form_tag authorize_url do %>
   <%= hidden_field_tag "oauth_token", @token.token %>
   <%- if params[:oauth_callback] -%>
     <%= hidden_field_tag "oauth_callback", params[:oauth_callback] %>
   <%- end -%>
-  <p><%= t 'oauth.oauthorize.allow_to' %></p>
+  <p><%= t '.allow_to' %></p>
   <ul>
   <% @token.client_application.permissions.each do |perm| %>
   <ul>
   <% @token.client_application.permissions.each do |perm| %>
-    <li><%= check_box_tag perm.to_s, "yes", @token.read_attribute(perm) %><%= t "oauth.oauthorize.#{perm}" %></li>
+    <li><%= check_box_tag perm.to_s, "yes", @token.read_attribute(perm) %><%= t ".#{perm}" %></li>
   <% end %>
   </ul>
   <% end %>
   </ul>
-  <p><%= submit_tag t("oauth.oauthorize.grant_access") %></p>
+  <p><%= submit_tag t(".grant_access") %></p>
 <% end %>
 <% end %>
index 4afba70e306c685a268286e4823f7fdd80243422..7142a71a0c49387dfd62d286cd1a696bc5f8dc90 100644 (file)
@@ -1,5 +1,5 @@
 <% content_for :heading do %>
 <% content_for :heading do %>
-  <h1><%= t "oauth.oauthorize_failure.title" %></h1>
+  <h1><%= t ".title" %></h1>
 <% end %>
 
 <p><%= @message %></p>
 <% end %>
 
 <p><%= @message %></p>
index c8f56af3345a538da083acba1a2db13fca297269..9c817372fd50f262c0e604c741f63fb2a81452ca 100644 (file)
@@ -1,9 +1,9 @@
 <% content_for :heading do %>
 <% content_for :heading do %>
-  <h1><%= t "oauth.oauthorize_success.title" %></h1>
+  <h1><%= t ".title" %></h1>
 <% end %>
 
 <% end %>
 
-<p><%= raw t("oauth.oauthorize_success.allowed", :app_name => link_to(@token.client_application.name, @token.client_application.url)) %></p>
+<p><%= raw t(".allowed", :app_name => link_to(@token.client_application.name, @token.client_application.url)) %></p>
 
 <% if @token.oob? and not @token.oauth10? %>
 
 <% if @token.oob? and not @token.oauth10? %>
-<p><%= t "oauth.oauthorize_success.verification", :code => @token.verifier %></p>
+<p><%= t ".verification", :code => @token.verifier %></p>
 <% end %>
 <% end %>
index b31ce4d5d6918fe1f05823039139095fa972e009..a42c589d464988a86f611e1627e4e8b9451c0c12 100644 (file)
@@ -1690,7 +1690,7 @@ en:
       blocked: "Your access to the API has been blocked. Please log-in to the web interface to find out more."
       need_to_see_terms: "Your access to the API is temporarily suspended. Please log-in to the web interface to view the Contributor Terms. You do not need to agree, but you must view them."
   oauth:
       blocked: "Your access to the API has been blocked. Please log-in to the web interface to find out more."
       need_to_see_terms: "Your access to the API is temporarily suspended. Please log-in to the web interface to view the Contributor Terms. You do not need to agree, but you must view them."
   oauth:
-    oauthorize:
+    authorize:
       title: "Authorize access to your account"
       request_access: "The application %{app_name} is requesting access to your account, %{user}. Please check whether you would like the application to have the following capabilities. You may choose as many or as few as you like."
       allow_to: "Allow the client application to:"
       title: "Authorize access to your account"
       request_access: "The application %{app_name} is requesting access to your account, %{user}. Please check whether you would like the application to have the following capabilities. You may choose as many or as few as you like."
       allow_to: "Allow the client application to:"
@@ -1702,11 +1702,11 @@ en:
       allow_write_gpx:   "upload GPS traces."
       allow_write_notes: "modify notes."
       grant_access: "Grant Access"
       allow_write_gpx:   "upload GPS traces."
       allow_write_notes: "modify notes."
       grant_access: "Grant Access"
-    oauthorize_success:
+    authorize_success:
       title: "Authorization request allowed"
       allowed: "You have granted application %{app_name} access to your account."
       verification: "The verification code is %{code}."
       title: "Authorization request allowed"
       allowed: "You have granted application %{app_name} access to your account."
       verification: "The verification code is %{code}."
-    oauthorize_failure:
+    authorize_failure:
       title: "Authorization request failed"
       denied: "You have denied application %{app_name} access to your account."
       invalid: "The authorization token is not valid."
       title: "Authorization request failed"
       denied: "You have denied application %{app_name} access to your account."
       invalid: "The authorization token is not valid."