CSV export with localised column headers and inhibiting from import
When exporting data via CSV from the active_admin admin and your environment locale is set to something other than English, like this in an initializer:
I18n.default_locale = :es
The column headers of the exported CSV are in the localised language. When you then try to import that CSV with active_admin_import you'll get an error because it cannot match the headers with the column names which are in English.
I am on master (95fdfe1)
@kennym, for now there is no automatic resolving of column names from different locales, but there is workaround. You can change header names from files with header_rewrites option, pls take a look on spec https://github.com/activeadmin-plugins/active_admin_import/blob/master/spec/import_spec.rb#L103
and
https://github.com/activeadmin-plugins/active_admin_import/blob/master/spec/import_spec.rb#L350
however it can be possible to detect I18n.default_locale and find native column names, do you have ideas how to implement this?
This is an old topic, but here goes. Say we’re importing an Author model:
header_rewrites = Author.column_names.map { |a| [Author.human_attribute_name(a), a] }.to_h
active_admin_import header_rewrites: header_rewrites