From 5f1453103baf72e68395f2937a0ab7cb212a8aa7 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Wed, 27 Jul 2022 23:13:36 +0200 Subject: [PATCH] Add pluralization to list member locale --- app/javascript/retrospring/features/lists/membership.ts | 2 +- app/views/modal/list/_item.haml | 2 +- config/locales/frontend.en.yml | 6 ++++++ config/locales/views.en.yml | 5 ++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/javascript/retrospring/features/lists/membership.ts b/app/javascript/retrospring/features/lists/membership.ts index 3da838d6..bcc19a9d 100644 --- a/app/javascript/retrospring/features/lists/membership.ts +++ b/app/javascript/retrospring/features/lists/membership.ts @@ -23,7 +23,7 @@ export function listMembershipHandler(event: Event): void { success: (data) => { if (data.success) { checkbox.checked = data.checked; - memberCountElement.innerHTML = memberCountElement.dataset.i18n.replace('%{count}', memberCount.toString()); + memberCountElement.innerHTML = I18n.t('frontend.list.item.members', { count: memberCount }); memberCountElement.dataset.count = memberCount.toString(); } diff --git a/app/views/modal/list/_item.haml b/app/views/modal/list/_item.haml index 0554a20e..4d62fb5e 100644 --- a/app/views/modal/list/_item.haml +++ b/app/views/modal/list/_item.haml @@ -10,7 +10,7 @@ .media-body .list-group-item-heading= list.display_name .list-group-item-text.text-muted - %span{ id: "#{list.name}-members", data: { count: list.members.count, i18n: t(".members") } }= t(".members", count: list.members.count) + %span{ id: "#{list.name}-members", data: { count: list.members.count } }= t(".members", count: list.members.count) ยท %a.text-danger#delete-list{ href: "#", data: { list: list.name } } %i.fa.fa-close diff --git a/config/locales/frontend.en.yml b/config/locales/frontend.en.yml index 5e526476..7cea9da1 100644 --- a/config/locales/frontend.en.yml +++ b/config/locales/frontend.en.yml @@ -45,3 +45,9 @@ en: title: "Really report this %{type}?" text: "A moderator will review your report and decide what happens.\nIf you'd like, you can also specify a reason." input: "Specify a reason..." + list: + item: + members: + zero: "0 members" + one: "1 member" + other: "%{count} members" diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index 32d15115..42baf573 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -169,7 +169,10 @@ en: action: "Create list" placeholder: "List name" item: - members: "%{count} members" + members: + zero: "0 members" + one: "1 member" + other: "%{count} members" privileges: title: "Manage roles for %{user}" role: