Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor trace notifications to reduce lego translations #2970

Merged
merged 2 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,28 @@ def lost_password(user, token)

def gpx_success(trace, possible_points)
with_recipient_locale trace.user do
@to_user = trace.user.display_name
@trace_name = trace.name
@trace_points = trace.size
@trace_description = trace.description
@trace_tags = trace.tags
@possible_points = possible_points

mail :to => trace.user.email,
:subject => I18n.t("user_mailer.gpx_notification.success.subject")
:subject => I18n.t("user_mailer.gpx_success.subject")
end
end

def gpx_failure(trace, error)
with_recipient_locale trace.user do
@to_user = trace.user.display_name
@trace_name = trace.name
@trace_description = trace.description
@trace_tags = trace.tags
@error = error

mail :to => trace.user.email,
:subject => I18n.t("user_mailer.gpx_notification.failure.subject")
:subject => I18n.t("user_mailer.gpx_failure.subject")
end
end

Expand Down
16 changes: 6 additions & 10 deletions app/views/user_mailer/_gpx_description.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<%= t "user_mailer.gpx_notification.your_gpx_file" %>
<strong><%= @trace_name %></strong>
<%= t "user_mailer.gpx_notification.with_description" %>
<em><%= @trace_description %></em>
<% if @trace_tags.length>0 %>
<%= t "user_mailer.gpx_notification.and_the_tags" %>
<em><% @trace_tags.each do |tag| %>
<%= tag.tag.rstrip %>
<% end %></em>
<% trace_name = tag.strong(@trace_name) %>
<% trace_description = tag.em(@trace_description) %>
<% if @trace_tags.length > 0 %>
<% tags = @trace_tags.map { tag.tag.rstrip.join(" ") } %>
gravitystorm marked this conversation as resolved.
Show resolved Hide resolved
<%= t ".description_with_tags_html", :trace_name => trace_name, :trace_description => trace_description, :tags => tags %>
<% else %>
<%= t "user_mailer.gpx_notification.and_no_tags" %>
<%= t ".description_with_no_tags_html", :trace_name => trace_name, :trace_description => trace_description %>
<% end %>
8 changes: 3 additions & 5 deletions app/views/user_mailer/gpx_failure.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<p><%= t "user_mailer.gpx_notification.greeting" %></p>
<p><%= t ".hi", :to_user => @to_user %></p>

<p>
<%= render :partial => "gpx_description" %>
<%= t "user_mailer.gpx_notification.failure.failed_to_import" %>
<%= t ".failed_to_import" %>
</p>

<blockquote>
<%= @error %>
</blockquote>

<p>
<%= t "user_mailer.gpx_notification.failure.more_info_1" %>
<%= t "user_mailer.gpx_notification.failure.more_info_2" %>
<%= t "user_mailer.gpx_notification.failure.import_failures_url" %>
<%= t ".more_info_html", :url => link_to(t(".import_failures_url"), t(".import_failures_url")) %>
</p>
4 changes: 2 additions & 2 deletions app/views/user_mailer/gpx_success.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p><%= t "user_mailer.gpx_notification.greeting" %></p>
<p><%= t ".hi", :to_user => @to_user %></p>

<p>
<%= render :partial => "gpx_description" %>
<%= t("user_mailer.gpx_notification.success.loaded_successfully",
<%= t(".loaded_successfully",
:trace_points => @trace_points, :possible_points => @possible_points, :count => @possible_points) %>
</p>
32 changes: 15 additions & 17 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1426,23 +1426,21 @@ en:
had_added_you: "%{user} has added you as a friend on OpenStreetMap."
see_their_profile: "You can see their profile at %{userurl}."
befriend_them: "You can also add them as a friend at %{befriendurl}."
gpx_notification:
greeting: "Hi,"
your_gpx_file: "It looks like your GPX file"
with_description: "with the description"
and_the_tags: "and the following tags:"
and_no_tags: "and no tags."
failure:
subject: "[OpenStreetMap] GPX Import failure"
failed_to_import: "failed to import. Here is the error:"
more_info_1: "More information about GPX import failures and how to avoid"
more_info_2: "them can be found at:"
import_failures_url: "https://wiki.openstreetmap.org/wiki/GPX_Import_Failures"
success:
subject: "[OpenStreetMap] GPX Import success"
loaded_successfully:
one: loaded successfully with %{trace_points} out of a possible 1 point.
other: loaded successfully with %{trace_points} out of a possible %{possible_points} points.
gpx_description:
description_with_tags_html: "It looks like your GPX file %{trace_name} with the description %{trace_description} and the following tags: %{tags}"
description_with_no_tags_html: "It looks like your GPX file %{trace_name} with the description %{trace_description} and no tags"
gpx_failure:
hi: "Hi %{to_user},"
failed_to_import: "failed to import. Here is the error:"
more_info_html: "More information about GPX import failures and how to avoid them can be found at %{url}."
import_failures_url: "https://wiki.openstreetmap.org/wiki/GPX_Import_Failures"
subject: "[OpenStreetMap] GPX Import failure"
gpx_success:
hi: "Hi %{to_user},"
loaded_successfully:
one: loaded successfully with %{trace_points} out of a possible 1 point.
other: loaded successfully with %{trace_points} out of a possible %{possible_points} points.
subject: "[OpenStreetMap] GPX Import success"
signup_confirm:
subject: "[OpenStreetMap] Welcome to OpenStreetMap"
greeting: "Hi there!"
Expand Down