[openstreetmap/openstreetmap-website] Add locale selector (PR #5201)

Anton Khorev notifications at github.com
Mon Jun 2 14:05:43 UTC 2025


@AntonKhorev commented on this pull request.



> +    <select role="button" class="p-0 position-absolute top-0 start-0 w-100 h-100 language-change-trigger text-transparent bg-transparent <%= classes %>">
+      <% Locale.available
+               .select { |locale| I18n.exists? "shared.language_selector.#{locale}" }
+               .sort_by { |locale| t(".#{locale}") }
+               .each do |locale| %>
+        <option class="form-select" value="<%= locale.to_s %>" <%= "selected" if I18n.locale.to_s == locale.to_s %>><%= t(".#{locale}") %></option>
+      <% end %>
+    </select>

After #6024 this can be replaced with 

```suggestion
    <%= select_tag "language",
                   options_for_select(AVAILABLE_LANGUAGES.map { |e| [e[:native_name], e[:code]] },
                                      I18n.locale),
                   :role => "button",
                   :class => "p-0 position-absolute top-0 start-0 w-100 h-100 language-change-trigger text-transparent bg-transparent #{classes}" %>
```

https://github.com/AntonKhorev/openstreetmap-website/tree/a/pull/5201

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5201#discussion_r2121255541
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5201/review/2888575486 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250602/6979bdc0/attachment.htm>


More information about the rails-dev mailing list