<p>This PR contains some translation-related refactoring for the user_mailer.</p>
<p>It took me two attempts to get this right, since there's some subtleties about how the <code>_html</code> translations interact with plain text mail templates, and so I had to revisit and refactor some (unsubmitted) work that was done last week when I realised what was going on. But I've added a test that would have caught my mistake earlier.</p>
<p>In short, <code>_html</code> translations take the translation options (e.g. something like <code>t(".foo", :username => "Jack & Jill")</code>, html_escapes the options, interpolates them into the translation, and returns the whole thing as a SafeBuffer to avoid further html_escaping in the template. Putting that straight into an html template is fine, since it a) is already a safebuffer and b) is already escaped. But for plain text templates, we don't want any html_escaping of the input options, so we have to avoid using <code>_html</code> translation keys. Hence the duplication between the <code>_html</code> and non-<code>_html</code> keys.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/openstreetmap/openstreetmap-website/pull/2993'>https://github.com/openstreetmap/openstreetmap-website/pull/2993</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Use rails t helper to allow relative translation keys in email subjects</li>
  <li>Rename subject translation key, for consistency</li>
  <li>Remove duplicate translation strings, and use short form translation lookups</li>
  <li>Avoid calling raw in plain text email templates</li>
  <li>Add a test for i18n interpolation into plain and html parts</li>
  <li>Avoid using raw in html mailer views</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-55254045ba774e4c360d7bbfde054665072d2ab49abc3f21add15a37bba65a1c">app/mailers/user_mailer.rb</a>
    (26)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-6938f68652d92caabffeaa47ad9bfcbf1ab01eaf1d92f3b155f637b2dce0fe83">app/views/user_mailer/changeset_comment_notification.html.erb</a>
    (10)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-ba01eab7ec4d4ae2d3d5014ea9a810e88ae1cae98205184baf156ce45dfa3521">app/views/user_mailer/diary_comment_notification.html.erb</a>
    (10)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-a36fd11c18a41c175d74002d6ee98f541bd6b40cae7949dafc8b3343c1692957">app/views/user_mailer/diary_comment_notification.text.erb</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-7663fd470f4d8220bf88d6d89b80d9e49e3338d7fb4de065ef3ac5e983b59555">app/views/user_mailer/email_confirm.html.erb</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-c6fc374e8759a295835afe6420b1acafc47c265c06601ce0d2654bb75088fee4">app/views/user_mailer/email_confirm.text.erb</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-b940a7e44ecc6cde170b788dd5ff4e6347f0cc1881153c3288720d4507255baf">app/views/user_mailer/friendship_notification.html.erb</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-598a69579d8b608ea94cb569602537ada1879c03d48c0dd2954558c5bc5fffa7">app/views/user_mailer/lost_password.html.erb</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-7fb5ed9141059fdee4378293109c370cfe1dc5869009db5e1e49811bc7e26e15">app/views/user_mailer/lost_password.text.erb</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-683aae56b100df7f09527d8fb9f216a704ceb459c63421b69775394b3ddbea8d">app/views/user_mailer/message_notification.html.erb</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-566ba4066647f8c1c9c5f5e3a520cdb6e7c36c3bd4512f755be047c3a4b0d3c2">app/views/user_mailer/message_notification.text.erb</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-ac5b6dcbdc71c7d5156a26edcedc6b5fa5b9ad41d97d212de595d45f7b778c6f">app/views/user_mailer/note_comment_notification.html.erb</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-44438ce218f5287c58d0017f965d888715635d94280669896f75841fbd7b4cd7">config/locales/en.yml</a>
    (30)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993/files#diff-3b2293412c91922d53358a642a2fb70e51ea4f4dce899f33a577fac2c662d91c">test/mailers/user_mailer_test.rb</a>
    (9)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/2993.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/2993.patch</a></li>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/2993.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/2993.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2993">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMXCORM5DMW4I3V65TSSZQYJANCNFSM4UKWHUUQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAK2OLNXRW5W5VPOBRNIZSDSSZQYJA5CNFSM4UKWHUU2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4LIGSOOQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/2993",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/2993",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>