Skip to content

Commit

Permalink
improvement: properly handle single/plural messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinstadler committed Oct 28, 2024
1 parent 3d77707 commit 77a2613
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions components/instantsearch-stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ export function InstantSearchStats(): ReactNode {
const t = useTranslations("SearchPage");
const stats = useStats();
// https://www.algolia.com/doc/api-reference/widgets/stats/react/#hook
return (
<>
{stats.nbHits} {stats.nbHits === 1 ? t("result") : t("results")}
</>
);
return <>{t("result", { count: stats.nbHits })}</>;
}
4 changes: 2 additions & 2 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
"work": "works"
},
"query_placeholder": "search publications",
"result": "publication",
"results": "publications",
"result": "{count, plural, =1 {# publication} other {# publications}}",
"result_other": "publications",
"show_more": "show more results",
"sort_by": "sort by",
"sort": {
Expand Down

0 comments on commit 77a2613

Please sign in to comment.