[openstreetmap/openstreetmap-website] Avoid using html in translations (PR #3936)
Andy Allan
notifications at github.com
Wed Feb 22 10:22:53 UTC 2023
@gravitystorm commented on this pull request.
> @@ -0,0 +1,14 @@
+<hr class="mb-3" />
+<a name="public"></a>
+<h2><%= t ".heading" %></h2>
+<p>
+ <%= t ".currently_not_public" %>
+ <strong><%= t ".only_public_can_edit" %></strong>
+ <%= t ".find_out_why_html", :link => link_to(t(".find_out_why"),
+ t(".find_out_why_url")) %>
Lego translations are where we stick two translations together side-by-side, like `"string" + "string"` which prevents translators from rearranging the sentence to meet any grammatical needs. Interpolating is fine since they can still put the words in whichever order they like, e.g. moving words from after the link text to before the link text.
```erb
<%= t(".first_part") + link_to(foo) + t(".second_part") %> # lego translation
vs
<%= t(".whole_sentence"), :link => link_to(foo) %> # no problem
```
We already use the interpolation approach to links in numerous places.
There are two things we should consider with the interpolation approach:
* Don't be tempted to reuse the interpolated link text between different pages, since that text itself might depend on the rest of the sentence
* There's a risk that splitting the sentence into two keys makes it harder to translate, e.g. if you are looking at the link text, it could be harder to discover what context it's being used in. So we should keep the names of the keys similar (and keep them in the same naming hierarchy) so that it's more obvious to translators how the keys are related. I try to follow the convention of "blah blah %{foobar_link}", with the `foobar` key being the link text and `foobar_url` if the url is translateable.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/3936#discussion_r1114125355
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/3936/review/1308943329 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20230222/f2c47d60/attachment.htm>
More information about the rails-dev
mailing list