Skip to content
Snippets Groups Projects
Commit 4bbc5f45 authored by pabois's avatar pabois
Browse files

facto ugly method

parent 38b09fde
No related branches found
No related tags found
No related merge requests found
......@@ -49,4 +49,9 @@ module ApplicationHelper
def masked_phone(string)
string.gsub(/(?<=.{3}).+(?=.{2})/, '*******')
end
def language_name(iso_code)
I18nData.languages(I18n.locale)[iso_code.to_s.upcase].titleize
end
end
......@@ -7,7 +7,7 @@
<ol class="list-unstyled">
<% about.available_languages.each do |language| %>
<%
label = I18nData.languages(I18n.locale)[language.iso_code.to_s.upcase].titleize
label = language_name(language.iso_code)
current = language.id == about.language_id
%>
<li><%= link_to_unless current, label, [*route_args, lang: language.iso_code] %></li>
......
......@@ -8,7 +8,7 @@
<%= f.input :name %>
<%= f.input :url %>
<%= render 'admin/communication/abouts', f: f, i18n_key: 'activerecord.attributes.communication/website.about_' %>
<%= f.association :languages, as: :check_boxes, required: true, wrapper_html: { class: "js-languages" }, label_method: lambda { |l| I18nData.languages(I18n.locale)[l.iso_code.to_s.upcase].titleize } %>
<%= f.association :languages, as: :check_boxes, required: true, wrapper_html: { class: "js-languages" }, label_method: lambda { |l| language_name(l.iso_code) } %>
<%= f.association :default_language, include_blank: t('simple_form.include_blanks.defaults.language'), input_html: (@website.persisted? ? { disabled: true } : { class: "js-default-language" }) %>
<%= f.input :in_production %>
<% end %>
......
......@@ -53,7 +53,7 @@
<select class="form-control form-select mt-5" onchange="if (this.value) window.location.href=this.value">
<% @website.languages.each do |language| %>
<%
label = I18nData.languages(I18n.locale)[language.iso_code.to_s.upcase].titleize
label = language_name(language.iso_code)
path = url_for request.params.merge(lang: language.iso_code)
selected = current_website_language == language
%>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment