Skip to content

Commit

Permalink
Correctly pluralize "version(s) since" on versions index page (#4466)
Browse files Browse the repository at this point in the history
From #4460 (comment)

Added a test to verify this string is being pluralized properly.

Co-authored-by: Albert Chae <[email protected]>
  • Loading branch information
albertchae and albertchae authored Feb 19, 2024
1 parent b9fe2d7 commit 6a3c35c
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 9 deletions.
4 changes: 3 additions & 1 deletion config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,9 @@ de:
index:
not_hosted_notice: Dieses Gem wird nicht gerade von RubyGems.org gehostet.
title: Alle Versionen von %{name}
versions_since: "%{count} Versionen seit %{since}"
versions_since:
other: "%{count} Versionen seit %{since}"
one: "%{count} Version seit %{since}"
imported_gem_version_notice:
version:
yanked:
Expand Down
4 changes: 3 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,9 @@ en:
index:
not_hosted_notice: This gem is not currently hosted on RubyGems.org.
title: All versions of %{name}
versions_since: "%{count} versions since %{since}"
versions_since:
other: "%{count} versions since %{since}"
one: "1 version since %{since}"
imported_gem_version_notice: "This gem version was imported to RubyGems.org on %{import_date}. The date displayed was specified by the author in the gemspec."
version:
yanked: yanked
Expand Down
4 changes: 3 additions & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,9 @@ es:
index:
not_hosted_notice: Esta gema no está alojada actualmente en RubyGems.org.
title: Todas las versiones de %{name}
versions_since: "%{count} versiones desde %{since}"
versions_since:
other: "%{count} versiones desde %{since}"
one: "%{count} versión desde %{since}"
imported_gem_version_notice: Esta versión de la gema se importó a RubyGems.org
el %{import_date}. La fecha que se muestra fue especificada por el autor en
el archivo gemspec.
Expand Down
4 changes: 3 additions & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,9 @@ fr:
index:
not_hosted_notice: Gem non hébergé sur Rubygems.
title: Toutes les versions de %{name}
versions_since: "%{count} versions depuis %{since}"
versions_since:
other: "%{count} versions depuis %{since}"
one: "%{count} version depuis %{since}"
imported_gem_version_notice:
version:
yanked: retiré
Expand Down
4 changes: 3 additions & 1 deletion config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,9 @@ ja:
index:
not_hosted_notice: このgemは現在RubyGems.org上ではホストされていません。
title: "%{name}の全バージョン履歴"
versions_since: "%{since}からの%{count}件"
versions_since:
other: "%{since}からの%{count}件"
one: "%{since}からの%{count}件"
imported_gem_version_notice: このgemのバージョンは%{import_date}にRubyGems.orgにインポートされました。表示されている日付は作者によってgemspec中で指定されました。
version:
yanked: ヤンク済み
Expand Down
4 changes: 3 additions & 1 deletion config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,9 @@ nl:
index:
not_hosted_notice: Deze gem wordt momenteel niet gehost op rubygems.org
title: Alle versies van %{name}
versions_since: "%{count} versies sinds %{since}"
versions_since:
other: "%{count} versies sinds %{since}"
one: "%{count} versie sinds %{since}"
imported_gem_version_notice:
version:
yanked: verwijderd
Expand Down
4 changes: 3 additions & 1 deletion config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,9 @@ pt-BR:
index:
not_hosted_notice: Esta gem não está hospdada no Gemcutter.
title: Todas as versões para %{name}
versions_since: "%{count} versões desde %{since}"
versions_since:
other: "%{count} versões desde %{since}"
one: "%{count} versão desde %{since}"
imported_gem_version_notice:
version:
yanked: removida
Expand Down
4 changes: 3 additions & 1 deletion config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,9 @@ zh-CN:
index:
not_hosted_notice: 此 Gem 目前没有托管在 RubyGems.org 中。
title: "%{name} 的所有版本"
versions_since: 自 %{since} 以来有 %{count} 个版本
versions_since:
other: 自 %{since} 以来有 %{count} 个版本
one: 自 %{since} 以来有 %{count} 个版本
imported_gem_version_notice: 此版本的 Gem 已在 %{import_date} 导入到 RubyGems.org 中。显示的日期由作者在
gemspec 中指定。
version:
Expand Down
4 changes: 3 additions & 1 deletion config/locales/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,9 @@ zh-TW:
index:
not_hosted_notice: 這個 Gem 目前沒有在 Gemcutter 上
title: "%{name} 的所有版本"
versions_since: 自從 %{since} 以來,有 %{count} 個版本
versions_since:
other: 自從 %{since} 以來,有 %{count} 個版本
one: 自從 %{since} 以來,有 %{count} 個版本
imported_gem_version_notice:
version:
yanked: 已被移除
Expand Down
27 changes: 27 additions & 0 deletions test/functional/versions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,33 @@ class VersionsControllerTest < ActionController::TestCase
end
end

context "on GET to index - pluralization" do
context "with one version" do
setup do
rubygem = create(:rubygem)
create(:version, number: "1.1.2", rubygem: rubygem)
get :index, params: { rubygem_id: rubygem.name }
end

should "use the singular version" do
assert_select ".t-list__heading", text: /1 version\b/, count: 1
end
end

context "with two versions" do
setup do
rubygem = create(:rubygem)
create(:version, number: "1.1.2", rubygem: rubygem)
create(:version, number: "1.1.3", rubygem: rubygem)
get :index, params: { rubygem_id: rubygem.name }
end

should "use the plural version" do
assert_select ".t-list__heading", text: /2 versions\b/, count: 1
end
end
end

context "on GET to index with imported versions" do
setup do
@built_at = Date.parse("2000-01-01")
Expand Down

0 comments on commit 6a3c35c

Please sign in to comment.