diff --git a/app/models/language.rb b/app/models/language.rb index 047a01e1ac38ade22b87e265ec4989127079d4ca..36cf5338a0bc6d3f337c79dcac2fdaacb195158f 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -20,7 +20,7 @@ class Language < ApplicationRecord validates_presence_of :iso_code validates_uniqueness_of :iso_code - default_scope { order(name: :asc) } + scope :ordered, -> { order(name: :asc) } def to_s "#{name}" diff --git a/app/views/admin/application/i18n/_widget.html.erb b/app/views/admin/application/i18n/_widget.html.erb index d5e86d411146897c189abac35a77b2d24789f50e..16c17ca2fc23f9017c6c6aae314f59ef24e9e87d 100644 --- a/app/views/admin/application/i18n/_widget.html.erb +++ b/app/views/admin/application/i18n/_widget.html.erb @@ -1,25 +1,21 @@ <% if about.respond_to?(:website) - languages = about.website.languages + languages = about.website.languages.ordered route_args = [:admin, about.becomes(about.class.base_class)] else - languages = Language.all + languages = Language.all.ordered route_args = [:admin, about.becomes(about.class.base_class), :translation] end %> <%= osuny_panel t('internationalization.label') do %> - <p><%= t('internationalization.text_html', lang: t("languages.#{about.language.iso_code}")) %></p> - <h3 class="h5 mt-4"><%= t('internationalization.translations_title') %></h3> <ol class="list-unstyled"> <% languages.each do |language| %> - <% next if language.id == about.language_id %> + <% + label = t(language.iso_code, scope: :languages) + current = language.id == about.language_id + %> <li> - <% if about.original_with_translations.detect { |translation| translation.language_id == language.id }.present? %> - <i class="fas fa-edit float-end"></i> - <% else %> - <i class="fas fa-add float-end"></i> - <% end %> - <%= link_to t(language.iso_code, scope: :languages), [*route_args, lang: language.iso_code] %> + <%= link_to_unless current, label, [*route_args, lang: language.iso_code] %> </li> <% end %> </ol> diff --git a/config/locales/en.yml b/config/locales/en.yml index b854fba2e2d030e56eb19eddf95c5dd007b733d1..879f9c7eceb75483c1007e8d02d2cece586d8948 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -210,8 +210,6 @@ en: inactivity_alert: "It seems you have been away a little bit too long. Could you please retry?" internationalization: label: Internationalization - text_html: This page is in <b>%{lang}</b> - translations_title: 'Translations' languages: en: English fr: French diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 89217a20f45690e1b0200aa435c5559604ff8934..d36184e903da04a1c36ff32de7392afd59208990 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -210,8 +210,6 @@ fr: inactivity_alert: "Il semble que vous soyez resté sur la page un peu trop longtemps. Pouvez-vous ré-essayer ?" internationalization: label: Internationalisation - text_html: Cette page est en <b>%{lang}</b> - translations_title: 'Traductions' languages: en: Anglais fr: Français