-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
I ran into a limitation with the way localising column names is implemented in the gem, as you can only decide to use, or dismiss localisation for the whole DSL block. My use case is mixed, requiring localising regular model attributes, and using key/value pairs that have been saved to the db directly for custom columns (skipping localisation for the key columns).
I did a quick patch that works for my needs, opting to only localise the columns if passed as a symbol, and when a scope exists. Strings are always titleized.
module ActiveAdmin
module Xls
class Builder
class Column
def localized_name(i18n_scope = nil)
return name.to_s.titleize unless i18n_scope && (name.is_a? Symbol)
I18n.t name, scope: i18n_scope
end
end
end
end
endHesitating to do a PR for this though, as it is in essence a breaking change to the way column localisation is handled. Perhaps a passable option for the column helper would be a better approach?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels