From ffde7dfc670fca2a06f0a2f96f9fdcc365bf9e03 Mon Sep 17 00:00:00 2001 From: Alejandro Loaiza <51034242+aloaiza30@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:41:53 -0600 Subject: [PATCH] Fix "translation missing" errors by setting default value --- lib/active_admin/xls/builder.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/active_admin/xls/builder.rb b/lib/active_admin/xls/builder.rb index f7f3bb1..8817f1a 100644 --- a/lib/active_admin/xls/builder.rb +++ b/lib/active_admin/xls/builder.rb @@ -292,7 +292,10 @@ def initialize(name, block = nil) # value, or a block used to generate the value to display. attr_reader :data - # Returns a localized version of the column name if a scope is given. + # Returns a localized version of the column name if a scope is given + # or the default titleized column name if the localized version is not + # found. + # # Otherwise, it returns the titleized column name without translation. # # @param i18n_scope [String, Symbol, Array, Array] @@ -301,7 +304,7 @@ def initialize(name, block = nil) # @see I18n def localized_name(i18n_scope = nil) return name.to_s.titleize unless i18n_scope - I18n.t name, scope: i18n_scope + I18n.t name, scope: i18n_scope, default: name.to_s.titleize end end