From bb52042b46a1f0e426198098bc51464e00f23328 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Sun, 27 Sep 2015 21:36:57 +0200 Subject: [PATCH] FIX: Add missing pluralization keys to poll plugin locale --- plugins/poll/config/locales/client.en.yml | 12 +++++++++--- plugins/poll/config/locales/server.en.yml | 8 ++++++-- plugins/poll/plugin.rb | 4 ++-- .../poll/spec/controllers/posts_controller_spec.rb | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/plugins/poll/config/locales/client.en.yml b/plugins/poll/config/locales/client.en.yml index 586a8dfaf59..59b508c8853 100644 --- a/plugins/poll/config/locales/client.en.yml +++ b/plugins/poll/config/locales/client.en.yml @@ -29,9 +29,15 @@ en: multiple: help: - at_least_min_options: "You must choose at least %{count} options." - up_to_max_options: "You may choose up to %{count} options." - x_options: "You must choose %{count} options." + at_least_min_options: + one: "You must choose at least 1 option." + other: "You must choose at least %{count} options." + up_to_max_options: + one: "You may choose up to 1 option." + other: "You may choose up to %{count} options." + x_options: + one: "You must choose 1 option." + other: "You must choose %{count} options." between_min_and_max_options: "You may choose between %{min} and %{max} options." cast-votes: diff --git a/plugins/poll/config/locales/server.en.yml b/plugins/poll/config/locales/server.en.yml index dd1e4a5da9f..9417c9ba089 100644 --- a/plugins/poll/config/locales/server.en.yml +++ b/plugins/poll/config/locales/server.en.yml @@ -26,8 +26,12 @@ en: default_poll_must_have_at_least_2_options: "Poll must have at least 2 options." named_poll_must_have_at_least_2_options: "Poll named %{name} must have at least 2 options." - default_poll_must_have_less_options: "Poll must have less than %{max} options." - named_poll_must_have_less_options: "Poll named %{name} must have less than %{max} options." + default_poll_must_have_less_options: + one: "Poll must have less than 1 option." + other: "Poll must have less than %{count} options." + named_poll_must_have_less_options: + one: "Poll named %{name} must have less than 1 option." + other: "Poll named %{name} must have less than %{count} options." default_poll_must_have_different_options: "Poll must have different options." named_poll_must_have_different_options: "Poll named %{name} must have different options." diff --git a/plugins/poll/plugin.rb b/plugins/poll/plugin.rb index c53ef167bf8..a8589f2666d 100644 --- a/plugins/poll/plugin.rb +++ b/plugins/poll/plugin.rb @@ -257,8 +257,8 @@ after_initialize do # maximum # of options if poll["options"].size > SiteSetting.poll_maximum_options poll["name"] == DEFAULT_POLL_NAME ? - self.errors.add(:base, I18n.t("poll.default_poll_must_have_less_options", max: SiteSetting.poll_maximum_options)) : - self.errors.add(:base, I18n.t("poll.named_poll_must_have_less_options", name: poll["name"], max: SiteSetting.poll_maximum_options)) + self.errors.add(:base, I18n.t("poll.default_poll_must_have_less_options", count: SiteSetting.poll_maximum_options)) : + self.errors.add(:base, I18n.t("poll.named_poll_must_have_less_options", name: poll["name"], count: SiteSetting.poll_maximum_options)) return end diff --git a/plugins/poll/spec/controllers/posts_controller_spec.rb b/plugins/poll/spec/controllers/posts_controller_spec.rb index 00e68e842bb..944225b60c7 100644 --- a/plugins/poll/spec/controllers/posts_controller_spec.rb +++ b/plugins/poll/spec/controllers/posts_controller_spec.rb @@ -50,7 +50,7 @@ describe PostsController do expect(response).not_to be_success json = ::JSON.parse(response.body) - expect(json["errors"][0]).to eq(I18n.t("poll.default_poll_must_have_less_options", max: SiteSetting.poll_maximum_options)) + expect(json["errors"][0]).to eq(I18n.t("poll.default_poll_must_have_less_options", count: SiteSetting.poll_maximum_options)) end it "should have valid parameters" do