Locales helper improvement
Added a rescue block in `name_for_locale()` to ensure the application doesn't crash in case it receives an invalid locale.
This commit is contained in:
@@ -3,6 +3,8 @@ module LocalesHelper
|
||||
def name_for_locale(locale)
|
||||
default = I18n.t("locale", locale: locale)
|
||||
I18n.backend.translate(locale, "i18n.language.name", default: default)
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
@@ -28,7 +28,7 @@
|
||||
<td><%= I18n.l page.created_at, format: :short %></td>
|
||||
<td><%= I18n.l page.created_at, format: :short %></td>
|
||||
<td><%= t("admin.site_customization.pages.page.status_#{page.status}") %></td>
|
||||
<td><%= name_for_locale(page.locale) rescue nil %></td>
|
||||
<td><%= name_for_locale(page.locale) %></td>
|
||||
<td class="small">
|
||||
<span class="icon-eye"></span>
|
||||
<% if page.status == "published" %>
|
||||
|
||||
Reference in New Issue
Block a user