More lazy translation lookups for traces

This commit is contained in:
Andy Allan 2018-05-09 12:08:39 +08:00
parent 52f0ba78ea
commit a1853204fa
4 changed files with 40 additions and 43 deletions

View file

@ -31,14 +31,14 @@ class TraceController < ApplicationController
# set title # set title
@title = if target_user.nil? @title = if target_user.nil?
t "trace.list.public_traces" t ".public_traces"
elsif current_user && current_user == target_user elsif current_user && current_user == target_user
t "trace.list.my_traces" t ".my_traces"
else else
t "trace.list.public_traces_from", :user => target_user.display_name t ".public_traces_from", :user => target_user.display_name
end 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: # four main cases:
# 1 - all traces, logged in = all public traces + all user's (i.e + all mine) # 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? && if @trace && @trace.visible? &&
(@trace.public? || @trace.user == current_user) (@trace.public? || @trace.user == current_user)
@title = t "trace.view.title", :name => @trace.name @title = t ".title", :name => @trace.name
else else
flash[:error] = t "trace.view.trace_not_found" flash[:error] = t ".trace_not_found"
redirect_to :action => "list" redirect_to :action => "list"
end end
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
flash[:error] = t "trace.view.trace_not_found" flash[:error] = t ".trace_not_found"
redirect_to :action => "list" redirect_to :action => "list"
end end
@ -117,9 +117,8 @@ class TraceController < ApplicationController
end end
if @trace.id if @trace.id
flash[:notice] = t "trace.create.trace_uploaded" 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
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
redirect_to :action => :list, :display_name => current_user.display_name redirect_to :action => :list, :display_name => current_user.display_name
end end
@ -137,7 +136,7 @@ class TraceController < ApplicationController
@trace = Trace.new(:visibility => default_visibility) @trace = Trace.new(:visibility => default_visibility)
end end
@title = t "trace.create.upload_trace" @title = t ".upload_trace"
end end
def data def data
@ -191,7 +190,7 @@ class TraceController < ApplicationController
else else
trace.visible = false trace.visible = false
trace.save 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 redirect_to :action => :list, :display_name => trace.user.display_name
end end
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound

View file

@ -8,26 +8,26 @@
<div class="standard-form"> <div class="standard-form">
<fieldset> <fieldset>
<div class='form-row'> <div class='form-row'>
<label for="trace_gpx_file" class="standard-label"><%= t'trace.trace_form.upload_gpx' %></label> <label for="trace_gpx_file" class="standard-label"><%= t '.upload_gpx' %></label>
<%= f.file_field :gpx_file %> <%= f.file_field :gpx_file %>
</div> </div>
<div class='form-row'> <div class='form-row'>
<label class="standard-label"><%= t'trace.trace_form.description' %></label> <label class="standard-label"><%= t '.description' %></label>
<%= f.text_field :description %> <%= f.text_field :description %>
</div> </div>
<div class='form-row'> <div class='form-row'>
<label class="standard-label"><%= t'trace.trace_form.tags' %></label> <label class="standard-label"><%= t '.tags' %></label>
<%= f.text_field :tagstring %> <%= f.text_field :tagstring %>
<span class="form-help deemphasize">(<%= t'trace.trace_form.tags_help' %>)</span> <span class="form-help deemphasize">(<%= t '.tags_help' %>)</span>
</div> </div>
<div class='form-row'> <div class='form-row'>
<label class="standard-label"><%= t'trace.trace_form.visibility' %></label> <label class="standard-label"><%= t '.visibility' %></label>
<%= f.select :visibility, [[t('trace.visibility.private'),"private"],[t('trace.visibility.public'),"public"],[t('trace.visibility.trackable'),"trackable"],[t('trace.visibility.identifiable'),"identifiable"]] %> <%= f.select :visibility, [[t('trace.visibility.private'),"private"],[t('trace.visibility.public'),"public"],[t('trace.visibility.trackable'),"trackable"],[t('trace.visibility.identifiable'),"identifiable"]] %>
<span class="form-help deemphasize">(<a href="<%= t'trace.trace_form.visibility_help_url' %>"><%= t'trace.trace_form.visibility_help' %></a>)</span> <span class="form-help deemphasize">(<a href="<%= t '.visibility_help_url' %>"><%= t '.visibility_help' %></a>)</span>
</div> </div>
</fieldset> </fieldset>
<%= submit_tag t('trace.trace_form.upload_button') %> <%= submit_tag t('.upload_button') %>
<span class="form-help deemphasize"><a href="<%= t'trace.trace_form.help_url' %>"><%= t'trace.trace_form.help' %></a></span> <span class="form-help deemphasize"><a href="<%= t '.help_url' %>"><%= t '.help' %></a></span>
</div> </div>
<% end %> <% end %>

View file

@ -3,16 +3,16 @@
<ul class='secondary-actions clearfix'> <ul class='secondary-actions clearfix'>
<li><%= t('.description') %></li> <li><%= t('.description') %></li>
<li><%= rss_link_to :action => 'georss', :display_name => @display_name, :tag => @tag %></li> <li><%= rss_link_to :action => 'georss', :display_name => @display_name, :tag => @tag %></li>
<li><%= link_to t('trace.trace_header.upload_trace'), :action => 'create' %></li> <li><%= link_to t('.upload_trace'), :action => 'create' %></li>
<% if @tag %> <% if @tag %>
<li><%= link_to t('trace.trace_header.see_all_traces'), :controller => 'trace', :action => 'list', :display_name => nil, :tag => nil, :page => nil %></li> <li><%= link_to t('.see_all_traces'), :controller => 'trace', :action => 'list', :display_name => nil, :tag => nil, :page => nil %></li>
<li><%= link_to t('trace.trace_header.see_my_traces'), :action => 'mine', :tag => nil, :page => nil %></li> <li><%= link_to t('.see_my_traces'), :action => 'mine', :tag => nil, :page => nil %></li>
<% else %> <% else %>
<% if @display_name %> <% if @display_name %>
<li><%= link_to t('trace.trace_header.see_all_traces'), :controller => 'trace', :action => 'list', :display_name => nil, :tag => nil, :page => nil %></li> <li><%= link_to t('.see_all_traces'), :controller => 'trace', :action => 'list', :display_name => nil, :tag => nil, :page => nil %></li>
<% end %> <% end %>
<%= unless_user(@target_user, :li) do %> <%= unless_user(@target_user, :li) do %>
<%= link_to t('trace.trace_header.see_my_traces'), :action => 'mine', :tag => nil, :page => nil %> <%= link_to t('.see_my_traces'), :action => 'mine', :tag => nil, :page => nil %>
<% end %> <% end %>
<% end %> <% end %>
</ul> </ul>

View file

@ -1578,6 +1578,19 @@ en:
create: create:
upload_trace: "Upload GPS Trace" 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." 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: edit:
title: "Editing trace %{name}" title: "Editing trace %{name}"
heading: "Editing trace %{name}" heading: "Editing trace %{name}"
@ -1596,24 +1609,6 @@ en:
visibility: "Visibility:" visibility: "Visibility:"
visibility_help: "what does this mean?" visibility_help: "what does this mean?"
visibility_help_url: "https://wiki.openstreetmap.org/wiki/Visibility_of_GPS_traces" 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: trace_optionals:
tags: "Tags" tags: "Tags"
view: view:
@ -1663,6 +1658,9 @@ en:
description: "Browse recent GPS trace uploads" description: "Browse recent GPS trace uploads"
tagged_with: " tagged with %{tags}" tagged_with: " tagged with %{tags}"
empty_html: "Nothing here yet. <a href='%{upload_link}'>Upload a new trace</a> or learn more about GPS tracing on the <a href='https://wiki.openstreetmap.org/wiki/Beginners_Guide_1.2'>wiki page</a>." empty_html: "Nothing here yet. <a href='%{upload_link}'>Upload a new trace</a> or learn more about GPS tracing on the <a href='https://wiki.openstreetmap.org/wiki/Beginners_Guide_1.2'>wiki page</a>."
upload_trace: "Upload a trace"
see_all_traces: "See all traces"
see_my_traces: "See my traces"
delete: delete:
scheduled_for_deletion: "Trace scheduled for deletion" scheduled_for_deletion: "Trace scheduled for deletion"
make_public: make_public: