From a1853204faefd8270e3db4a988ef373ea1ab342d Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 9 May 2018 12:08:39 +0800 Subject: [PATCH] More lazy translation lookups for traces --- app/controllers/trace_controller.rb | 23 ++++++++++--------- app/views/trace/create.html.erb | 16 +++++++------- app/views/trace/list.html.erb | 10 ++++----- config/locales/en.yml | 34 ++++++++++++++--------------- 4 files changed, 40 insertions(+), 43 deletions(-) diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index f97e5ecd2..5eb9a0ff7 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -31,14 +31,14 @@ class TraceController < ApplicationController # set title @title = if target_user.nil? - t "trace.list.public_traces" + t ".public_traces" elsif current_user && current_user == target_user - t "trace.list.my_traces" + t ".my_traces" else - t "trace.list.public_traces_from", :user => target_user.display_name + t ".public_traces_from", :user => target_user.display_name end - @title += t "trace.list.tagged_with", :tags => params[:tag] if params[:tag] + @title += t ".tagged_with", :tags => params[:tag] if params[:tag] # four main cases: # 1 - all traces, logged in = all public traces + all user's (i.e + all mine) @@ -94,13 +94,13 @@ class TraceController < ApplicationController if @trace && @trace.visible? && (@trace.public? || @trace.user == current_user) - @title = t "trace.view.title", :name => @trace.name + @title = t ".title", :name => @trace.name else - flash[:error] = t "trace.view.trace_not_found" + flash[:error] = t ".trace_not_found" redirect_to :action => "list" end rescue ActiveRecord::RecordNotFound - flash[:error] = t "trace.view.trace_not_found" + flash[:error] = t ".trace_not_found" redirect_to :action => "list" end @@ -117,9 +117,8 @@ class TraceController < ApplicationController end if @trace.id - flash[:notice] = t "trace.create.trace_uploaded" - - flash[:warning] = t "trace.trace_header.traces_waiting", :count => current_user.traces.where(:inserted => false).count if current_user.traces.where(:inserted => false).count > 4 + flash[:notice] = t ".trace_uploaded" + flash[:warning] = t ".traces_waiting", :count => current_user.traces.where(:inserted => false).count if current_user.traces.where(:inserted => false).count > 4 redirect_to :action => :list, :display_name => current_user.display_name end @@ -137,7 +136,7 @@ class TraceController < ApplicationController @trace = Trace.new(:visibility => default_visibility) end - @title = t "trace.create.upload_trace" + @title = t ".upload_trace" end def data @@ -191,7 +190,7 @@ class TraceController < ApplicationController else trace.visible = false trace.save - flash[:notice] = t "trace.delete.scheduled_for_deletion" + flash[:notice] = t ".scheduled_for_deletion" redirect_to :action => :list, :display_name => trace.user.display_name end rescue ActiveRecord::RecordNotFound diff --git a/app/views/trace/create.html.erb b/app/views/trace/create.html.erb index 0bc1bcde1..7e1af7862 100644 --- a/app/views/trace/create.html.erb +++ b/app/views/trace/create.html.erb @@ -8,26 +8,26 @@
- + <%= f.file_field :gpx_file %>
- + <%= f.text_field :description %>
- + <%= f.text_field :tagstring %> - (<%= t'trace.trace_form.tags_help' %>) + (<%= t '.tags_help' %>)
- + <%= f.select :visibility, [[t('trace.visibility.private'),"private"],[t('trace.visibility.public'),"public"],[t('trace.visibility.trackable'),"trackable"],[t('trace.visibility.identifiable'),"identifiable"]] %> - (<%= t'trace.trace_form.visibility_help' %>) + (<%= t '.visibility_help' %>)
- <%= submit_tag t('trace.trace_form.upload_button') %> - <%= t'trace.trace_form.help' %> + <%= submit_tag t('.upload_button') %> + <%= t '.help' %>
<% end %> diff --git a/app/views/trace/list.html.erb b/app/views/trace/list.html.erb index 376fc5511..b560c2ad3 100644 --- a/app/views/trace/list.html.erb +++ b/app/views/trace/list.html.erb @@ -3,16 +3,16 @@ diff --git a/config/locales/en.yml b/config/locales/en.yml index 7cb67e0c8..1a1aa83b8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1578,6 +1578,19 @@ en: create: upload_trace: "Upload GPS Trace" trace_uploaded: "Your GPX file has been uploaded and is awaiting insertion in to the database. This will usually happen within half an hour, and an email will be sent to you on completion." + traces_waiting: + one: "You have %{count} trace waiting for upload. Please consider waiting for these to finish before uploading any more, so as not to block the queue for other users." + other: "You have %{count} traces waiting for upload. Please consider waiting for these to finish before uploading any more, so as not to block the queue for other users." + upload_gpx: "Upload GPX File:" + description: "Description:" + tags: "Tags:" + tags_help: "comma delimited" + visibility: "Visibility:" + visibility_help: "what does this mean?" + visibility_help_url: "https://wiki.openstreetmap.org/wiki/Visibility_of_GPS_traces" + upload_button: "Upload" + help: "Help" + help_url: "https://wiki.openstreetmap.org/wiki/Upload" edit: title: "Editing trace %{name}" heading: "Editing trace %{name}" @@ -1596,24 +1609,6 @@ en: visibility: "Visibility:" visibility_help: "what does this mean?" visibility_help_url: "https://wiki.openstreetmap.org/wiki/Visibility_of_GPS_traces" - trace_form: - upload_gpx: "Upload GPX File:" - description: "Description:" - tags: "Tags:" - tags_help: "comma delimited" - visibility: "Visibility:" - visibility_help: "what does this mean?" - visibility_help_url: "https://wiki.openstreetmap.org/wiki/Visibility_of_GPS_traces" - upload_button: "Upload" - help: "Help" - help_url: "https://wiki.openstreetmap.org/wiki/Upload" - trace_header: - upload_trace: "Upload a trace" - see_all_traces: "See all traces" - see_my_traces: "See my traces" - traces_waiting: - one: "You have %{count} trace waiting for upload. Please consider waiting for these to finish before uploading any more, so as not to block the queue for other users." - other: "You have %{count} traces waiting for upload. Please consider waiting for these to finish before uploading any more, so as not to block the queue for other users." trace_optionals: tags: "Tags" view: @@ -1663,6 +1658,9 @@ en: description: "Browse recent GPS trace uploads" tagged_with: " tagged with %{tags}" empty_html: "Nothing here yet. Upload a new trace or learn more about GPS tracing on the wiki page." + upload_trace: "Upload a trace" + see_all_traces: "See all traces" + see_my_traces: "See my traces" delete: scheduled_for_deletion: "Trace scheduled for deletion" make_public: -- 2.43.2