From 299a05345d9ed11a067cc00ff83e7cb6833c80f1 Mon Sep 17 00:00:00 2001 From: Jakub Krzus Date: Thu, 8 Apr 2021 18:45:53 +0100 Subject: [PATCH] add conditional to accesibility.rb generator preventing exceptions when row in translation files is nul --- db/pages/accessibility.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/db/pages/accessibility.rb b/db/pages/accessibility.rb index 663196505..661a82412 100644 --- a/db/pages/accessibility.rb +++ b/db/pages/accessibility.rb @@ -28,10 +28,12 @@ def generate_content(page) " I18n.t("pages.accessibility.keyboard_shortcuts.navigation_table.rows").each do |row| - content << " + if row.present? + content << " #{row[:key_column]} #{row[:page_column]} " + end end content << " @@ -52,10 +54,12 @@ def generate_content(page) " I18n.t("pages.accessibility.keyboard_shortcuts.browser_table.rows").each do |row| - content << " + if row.present? + content << " #{row[:browser_column]} #{row[:key_column]} " + end end content << " @@ -74,17 +78,21 @@ def generate_content(page) " I18n.t("pages.accessibility.textsize.browser_settings_table.rows").each do |row| - content << " + if row.present? + content << " #{row[:browser_column]} #{row[:action_column]} " + end end content << " " content << "

#{I18n.t("pages.accessibility.textsize.browser_shortcuts_table.description")}

#{I18n.t("pages.accessibility.compatibility.title")}

@@ -98,9 +106,8 @@ if SiteCustomization::Page.find_by(slug: "accessibility").nil? page = SiteCustomization::Page.new(slug: "accessibility", status: "published") generate_content(page) I18n.available_locales.each do |locale| - I18n.locale = locale + I18n.locale = locale translation = page.translations.build(locale: locale) - # Not generating content for :fa, :id and it translations, as they are causing error in line 32 - generate_content(translation) unless locale == :fa or locale == :id or locale == :it + generate_content(translation) end end