Skip to content

Commit 81b1980

Browse files
committed
Merge pull request activeadmin#169 from fabiokr/master
Adds more I18n
2 parents 8b89436 + 6ec6cf3 commit 81b1980

File tree

8 files changed

+37
-16
lines changed

8 files changed

+37
-16
lines changed

activeadmin.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Gem::Specification.new do |s|
110110
"lib/active_admin/iconic/icons.rb",
111111
"lib/active_admin/locales/en.yml",
112112
"lib/active_admin/locales/pt.yml",
113+
"lib/active_admin/locales/es.yml",
113114
"lib/active_admin/menu.rb",
114115
"lib/active_admin/menu_item.rb",
115116
"lib/active_admin/namespace.rb",

features/sidebar_sections.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,3 @@ Feature: Sidebar Sections
125125
When I am on the index page for posts
126126
Then I should see "Hello World from a partial" within ".sidebar_section"
127127

128-

lib/active_admin/locales/en.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,11 @@ en:
2424
less_than: "Less Than"
2525
main_content: "Please implement %{model}#main_content to display content."
2626
logout: "Logout"
27+
sidebars:
28+
filters: "Filters"
29+
pagination:
30+
empty: "No %{model} found"
31+
one: "Displaying <b>1</b> %{model}"
32+
one_page: "Displaying <b>all %{n}</b> %{model}"
33+
multiple: "Displaying %{model} <b>%{from}&nbsp;-&nbsp;%{to}</b> of <b>%{total}</b> in total"
2734

lib/active_admin/locales/pt.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,11 @@ pt:
2424
less_than: "Menor Que"
2525
main_content: "Por favor implemente %{model}#main_content para exibir conteúdo."
2626
logout: "Sair"
27+
sidebars:
28+
filters: "Filtros"
29+
pagination:
30+
empty: "Nenhum(a) %{model} encontrado(a)"
31+
one: "Exibindo <b>1</b> %{model}"
32+
one_page: "Exibindo <b>todos os(a) %{n}</b> %{model}"
33+
multiple: "Exibindo %{model} <b>%{from}&nbsp;-&nbsp;%{to}</b> de um total de <b>%{total}</b>"
2734

lib/active_admin/resource.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ def default_scope
168168
@default_scope
169169
end
170170

171-
# Create a new scope object for this resource
171+
# Create a new scope object for this resource.
172+
# If you want to internationalize the scope name, you can add
173+
# to your i18n files a key like "active_admin.scopes.scope_method".
172174
def scope(*args, &block)
173175
options = args.extract_options!
174176
@scopes << ActiveAdmin::Scope.new(*args, &block)

lib/active_admin/sidebar.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Sidebar
33

44
class Section
55
include ActiveAdmin::OptionalDisplay
6-
6+
77
attr_accessor :name, :options, :block
88

99
def initialize(name, options = {}, &block)
@@ -26,7 +26,11 @@ def icon
2626

2727
# The title gets displayed within the section in the view
2828
def title
29-
name.to_s.titlecase
29+
begin
30+
I18n.t!("active_admin.sidebars.#{name.to_s}")
31+
rescue I18n::MissingTranslationData
32+
name.to_s.titlecase
33+
end
3034
end
3135

3236
# If a block is not passed in, the name of the partial to render

lib/active_admin/views/components/paginated_collection.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,17 @@ def page_entries_info(options = {})
7676

7777
if collection.num_pages < 2
7878
case collection.size
79-
when 0; "No #{entry_name.pluralize} found"
80-
when 1; "Displaying <b>1</b> #{entry_name}"
81-
else; "Displaying <b>all #{collection.size}</b> #{entry_name.pluralize}"
79+
when 0; I18n.t('active_admin.pagination.empty', :model => entry_name.pluralize)
80+
when 1; I18n.t('active_admin.pagination.one', :model => entry_name)
81+
else; I18n.t('active_admin.pagination.one_page', :model => entry_name.pluralize, :n => collection.size)
8282
end
8383
else
8484
offset = collection.current_page * ActiveAdmin.default_per_page
8585
total = collection.total_count
86-
%{Displaying #{entry_name.pluralize} <b>%d&nbsp;-&nbsp;%d</b> of <b>%d</b> in total} % [
87-
offset - ActiveAdmin.default_per_page + 1,
88-
offset > total ? total : offset,
89-
total
90-
]
86+
I18n.t('active_admin.pagination.multiple', :model => entry_name.pluralize, :from => (offset - ActiveAdmin.default_per_page + 1), :to => offset > total ? total : offset, :total => total)
9187
end
9288
end
9389

9490
end
9591
end
9692
end
97-

lib/active_admin/views/components/scopes.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ def build(scopes)
1616

1717
def build_scope(scope)
1818
span :class => classes_for_scope(scope) do
19-
if current_scope?(scope)
20-
em(scope.name)
19+
begin
20+
scope_name = I18n.t!("active_admin.scopes.#{scope.scope_method}")
21+
rescue I18n::MissingTranslationData
22+
scope_name = scope.name
23+
end
24+
25+
if current_scope?(scope)
26+
em(scope_name)
2127
else
22-
a(scope.name, :href => url_for(params.merge(:scope => scope.id, :page => 1)))
28+
a(scope_name, :href => url_for(params.merge(:scope => scope.id, :page => 1)))
2329
end
2430
text_node(" ")
2531
scope_count(scope)

0 commit comments

Comments
 (0)