Opened 9 years ago

Last modified 7 years ago

#2416 new defect

Make amf_controller.rb error messages translatable

Reported by: avarab@… Owned by: rails-dev@…
Priority: major Milestone:
Component: website Version:
Keywords: api_errors Cc:

Description

amf_controller.rb includes a lot of error messages which may be served to the user. These need to be made translatable.

Here's a partial patch:

Index: app/controllers/amf_controller.rb
===================================================================
--- app/controllers/amf_controller.rb	(revision 18452)
+++ app/controllers/amf_controller.rb	(working copy)
@@ -161,11 +161,11 @@
   rescue OSM::APIUserChangesetMismatchError => ex
     return [-2, ex.to_s]
   rescue OSM::APIBadBoundingBox => ex
-    return [-2, "Sorry - I can't get the map for that area. The server said: #{ex.to_s}"]
+    return [-2, t('potlatch.error.amf.api_bad_boundingbox', :server_error => ex.to_s)]
   rescue OSM::APIError => ex
     return [-1, ex.to_s]
   rescue Exception => ex
-    return [-2, "An unusual error happened (in #{call}). The server said: #{ex.to_s}"]
+    return [-2, t('potlatch.error.amf.api_bad_boundingbox', :call => call, :server_error => ex.to_s)]
   end
 
   def amf_handle_error_with_timeout(call,rootobj,rootid)
@@ -182,7 +182,7 @@
   def startchangeset(usertoken, cstags, closeid, closecomment, opennew)
     amf_handle_error("'startchangeset'",nil,nil) do
       user = getuser(usertoken)
-      if !user then return -1,"You are not logged in, so Potlatch can't write any changes to the database." end
+      if !user then return -1,t('potlatch.error.start_changeset') end
       unless user.active_blocks.empty? then return -1,t('application.setup_user_auth.blocked') end
 
       # close previous changeset and add comment
Index: config/locales/en.yml
===================================================================
--- config/locales/en.yml	(revision 18452)
+++ config/locales/en.yml	(working copy)
@@ -1157,3 +1157,7 @@
     site:
       edit_zoom_alert: You must zoom in to edit the map
       history_zoom_alert: You must zoom in to see the editing history
+  potlatch:
+    error:
+      amf:
+        api_bad_boundingbox: "Sorry - I can't get the map for that area. The server said: {{server_error}}"

Change History (2)

comment:1 Changed 7 years ago by TomH

  • Owner changed from tom@… to rails-dev@…

comment:2 Changed 7 years ago by stevens

  • Keywords api_errors added
Note: See TracTickets for help on using tickets.