Skip to content

Fix "translation missing" errors by setting default value #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/active_admin/xls/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>, Array<Symbol>]
Expand All @@ -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

Expand Down