Skip to content
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

Missing per-column localisation option. #15

Open
amlisirev opened this issue Jul 10, 2019 · 0 comments
Open

Missing per-column localisation option. #15

amlisirev opened this issue Jul 10, 2019 · 0 comments

Comments

@amlisirev
Copy link

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
end

Hesitating 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant