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

Anton Khorev notifications at github.com
Thu Oct 17 14:04:33 UTC 2024


@AntonKhorev commented on this pull request.



> +      <% Locale.available
+               .map { |locale| Language.find_by(:code => locale.to_s) }
+               .select { |locale| locale }
+               .sort_by { |locale| locale[:english_name] }
+               .each do |language| %>
+        <option class="form-select" value="<%= language.code %>" <%= "selected" if I18n.locale.to_s == language.code %>><%= language.name %></option>

Using Language table is probably a bad idea. I tried this:

```suggestion
      <% Locale.available
               .select { |locale| I18n.exists? "shared.language_selector.language", :locale => locale, :fallback => false }
               .sort_by { |locale| locale.to_s == "en" ? "English" : t(".language", :locale => locale) }
               .each do |locale| %>
        <option class="form-select" value="<%= locale.to_s %>" <%= "selected" if I18n.locale.to_s == locale.to_s %>><%= locale.to_s == "en" ? "English" : t(".language", :locale => locale) %></option>
```

with this in locale file:

```
  share:
    language_selector:
      language: THIS LANGUAGE NAME
```

Now translators have to add whatever is the appropriate representation of their language there, and then it will appear in the selector.

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

Message ID: <openstreetmap/openstreetmap-website/pull/5201/review/2375354012 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20241017/6c1317ce/attachment-0001.htm>


More information about the rails-dev mailing list