lib/admin_it/resource.rb in admin_it-1.0.8 vs lib/admin_it/resource.rb in admin_it-1.0.9
- old
+ new
@@ -124,11 +124,11 @@
def contexts_names
@contexts.map(&:context_name)
end
def display_name
- @display_name ||= plural.split('_').map { |s| s.capitalize }.join(' ')
+ @display_name ||= i18n_display_name || default_display_name
end
def collection_path
AdminIt::Engine.routes.url_helpers.send("#{plural}_path")
end
@@ -207,9 +207,25 @@
end
end
def default_filters
[]
+ end
+
+ def default_display_name
+ plural.split('_').map { |s| s.capitalize }.join(' ')
+ end
+
+ def i18n_display_name
+ begin
+ I18n
+ .t!("admin_it.resources.#{name}.display_name.plural")
+ .split(' ')
+ .map { |s| s.mb_chars.capitalize }
+ .join(' ')
+ rescue I18n::MissingTranslationData
+ nil
+ end
end
private
def import_data_module