- <%= Spree.t(:no_resource, resource: Spree::Variant.model_name.human(count: :other)) %>
+ <%= Spree.t(:no_resource, resource: plural_resource_name(Spree::Variant)) %>
<% if can? :create, Spree::Variant %>
<%= link_to Spree.t(:create_one), new_object_url, remote: true %>
<% end %>
diff --git a/backend/app/views/spree/admin/zones/_country_members.html.erb b/backend/app/views/spree/admin/zones/_country_members.html.erb
index 3077c735524..fb953fa84d8 100644
--- a/backend/app/views/spree/admin/zones/_country_members.html.erb
+++ b/backend/app/views/spree/admin/zones/_country_members.html.erb
@@ -1,9 +1,9 @@
diff --git a/backend/app/views/spree/admin/zones/_state_members.html.erb b/backend/app/views/spree/admin/zones/_state_members.html.erb
index 35635802ab3..cc16b6c5f1d 100644
--- a/backend/app/views/spree/admin/zones/_state_members.html.erb
+++ b/backend/app/views/spree/admin/zones/_state_members.html.erb
@@ -1,9 +1,9 @@
diff --git a/backend/app/views/spree/admin/zones/index.html.erb b/backend/app/views/spree/admin/zones/index.html.erb
index 07a5dac52f8..8b26106e5b7 100644
--- a/backend/app/views/spree/admin/zones/index.html.erb
+++ b/backend/app/views/spree/admin/zones/index.html.erb
@@ -1,7 +1,7 @@
<%= render 'spree/admin/shared/areas_tabs' %>
<% content_for :page_title do %>
- <%= Spree::Zone.model_name.human(count: :other) %>
+ <%= plural_resource_name(Spree::Zone) %>
<% end %>
<% content_for :page_actions do %>
diff --git a/core/app/helpers/spree/base_helper.rb b/core/app/helpers/spree/base_helper.rb
index 24c44b0f2f0..a5cd6d197ec 100644
--- a/core/app/helpers/spree/base_helper.rb
+++ b/core/app/helpers/spree/base_helper.rb
@@ -153,6 +153,10 @@ def link_to_tracking(shipment, options = {})
end
end
+ def plural_resource_name(resource_class)
+ resource_class.model_name.human(count: Spree::I18N_GENERIC_PLURAL)
+ end
+
private
# Returns style of image or nil
diff --git a/core/lib/spree/i18n.rb b/core/lib/spree/i18n.rb
index 2a623b0d133..e3d83410748 100644
--- a/core/lib/spree/i18n.rb
+++ b/core/lib/spree/i18n.rb
@@ -6,9 +6,16 @@ class TranslationHelperWrapper # :nodoc:
include ActionView::Helpers::TranslationHelper
end
+ # This value is used as a count for the pluralization helpers related to I18n
+ # ex: Spree::Order.model_name.human(count: Spree::I18N_GENERIC_PLURAL)
+ # Related to Solidus issue #1164, this is needed to avoid problems with
+ # some pluralization calculators
+ I18N_GENERIC_PLURAL = 2.1
+
class << self
# Add spree namespace and delegate to Rails TranslationHelper for some nice
# extra functionality. e.g return reasonable strings for missing translations
+
def translate(key, options = {})
options[:scope] = [:spree, *options[:scope]]
TranslationHelperWrapper.new.translate(key, options)
diff --git a/core/spec/helpers/base_helper_spec.rb b/core/spec/helpers/base_helper_spec.rb
index 0315c5bb13f..066e069d40d 100644
--- a/core/spec/helpers/base_helper_spec.rb
+++ b/core/spec/helpers/base_helper_spec.rb
@@ -167,4 +167,20 @@ def link_to_tracking_html(options = {})
expect(pretty_time(DateTime.new(2012, 5, 6, 13, 33))).to eq "May 06, 2012 1:33 PM"
end
end
+
+ context "plural_resource_name" do
+ let(:plural_config) { Spree::I18N_GENERIC_PLURAL }
+ let(:base_class) { Spree::Product }
+
+ subject { plural_resource_name(base_class) }
+
+ it "should use ActiveModel::Naming module to pluralize model names" do
+ expect(subject).to eq base_class.model_name.human(count: plural_config)
+ end
+
+ it "should use the Spree::I18N_GENERIC_PLURAL constant" do
+ expect(base_class.model_name).to receive(:human).with(hash_including(count: plural_config))
+ subject
+ end
+ end
end
diff --git a/core/spec/lib/i18n_spec.rb b/core/spec/lib/i18n_spec.rb
index 4827ef058ed..eb0a0161c15 100644
--- a/core/spec/lib/i18n_spec.rb
+++ b/core/spec/lib/i18n_spec.rb
@@ -40,6 +40,10 @@
expect(Spree.t(:missing_entry)).to include("