[openstreetmap/openstreetmap-website] Use with_locale instead of individual locale overrides (PR #3982)
Andy Allan
notifications at github.com
Wed Mar 22 10:33:06 UTC 2023
This PR changes the about and copyright pages to use `I18n.with_locale` blocks, instead of using `:locale` overrides on each translation.
This makes it slightly less verbose, and slightly easier to get right when adding additional translations to these sections. But more importantly, it makes it much less verbose when using interpolated translations, e.g.
```erb
<%= t ".foo_html", :locale => @locale,
:first_link => link_to(t(".bar", :locale => @locale), t(".bar_url", :locale => @locale)),
:second_link => link_to(t(".baz", :locale => @locale), t(".baz_url", :locale => @locale)),
... etc ...
```
vs
```erb
<% I18n.with_locale @locale do %>
<%= t ".foo_html", :first_link => link_to(t(".bar"), t(".bar_url")),
:second_link => link_to(t(".baz", t(".baz_url"))
... etc ...
```
The `with_locale` setting also applies to partials used within the block, so the override is no longer needed there. The indentation fix commit makes it a bit easier to understand the logic at the top of the copyright page, and is a historic whitespace issue.
You can view, comment on, or merge this pull request online at:
https://github.com/openstreetmap/openstreetmap-website/pull/3982
-- Commit Summary --
* Use .with_locale for about page
* Use with_locale for the copyright page
* Fix indentation
-- File Changes --
M app/views/site/_about_section.html.erb (2)
M app/views/site/about.html.erb (71)
M app/views/site/copyright.html.erb (90)
M test/controllers/site_controller_test.rb (5)
-- Patch Links --
https://github.com/openstreetmap/openstreetmap-website/pull/3982.patch
https://github.com/openstreetmap/openstreetmap-website/pull/3982.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/3982
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/3982 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20230322/d9689f2a/attachment.htm>
More information about the rails-dev
mailing list