From c3b6fac988607fe2ff6441555527744060802438 Mon Sep 17 00:00:00 2001 From: Alexander Midteide Date: Mon, 16 Dec 2024 12:51:49 +0100 Subject: [PATCH] fix: Search autocomplete translations --- .../Search/useSearchAutocompleteDialogs.tsx | 22 +++++++++++-------- packages/frontend/src/i18n/resources/en.json | 5 +++++ packages/frontend/src/i18n/resources/nb.json | 5 +++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/packages/frontend/src/components/PageLayout/Search/useSearchAutocompleteDialogs.tsx b/packages/frontend/src/components/PageLayout/Search/useSearchAutocompleteDialogs.tsx index bf68711e..6de32857 100644 --- a/packages/frontend/src/components/PageLayout/Search/useSearchAutocompleteDialogs.tsx +++ b/packages/frontend/src/components/PageLayout/Search/useSearchAutocompleteDialogs.tsx @@ -2,6 +2,7 @@ import type { AutocompleteProps } from '@altinn/altinn-components'; import type { AutocompleteItemProps } from '@altinn/altinn-components/dist/components/Autocomplete/AutocompleteItem'; import { useQuery } from '@tanstack/react-query'; import type { DialogStatus, GetSearchAutocompleteDialogsQuery, PartyFieldsFragment } from 'bff-types-generated'; +import { t } from 'i18next'; import { useMemo } from 'react'; import { Link } from 'react-router-dom'; import { useDebounce } from 'use-debounce'; @@ -72,14 +73,17 @@ const createAutocomplete = ( if (isLoading) { return { - items: [getScopeItem('Alt i innboks'), ...getSkeletonItems(skeletonSize)], - groups: { searching: { title: `Søker etter «${searchValue}»...` } }, + items: [ + getScopeItem(`${t('word.everything')} ${t('search.autocomplete.inInbox')}`), + ...getSkeletonItems(skeletonSize), + ], + groups: { searching: { title: `${t('search.searchFor')} «${searchValue}»...` } }, } as AutocompleteProps; } if (!isSearchable) { return { - items: [getScopeItem('Alt i innboks')], + items: [getScopeItem(`${t('word.everything')} ${t('search.autocomplete.inInbox')}`)], } as AutocompleteProps; } @@ -90,12 +94,12 @@ const createAutocomplete = ( items: [ getScopeItem( - {searchValue} i innboks + {searchValue} {t('search.autocomplete.inInbox')} , - 'Ingen treff', + t('search.noHits'), ), ], - groups: { noHits: { title: 'Ingen treff' } }, + groups: { noHits: { title: t('search.noHits') } }, } as AutocompleteProps; } @@ -103,13 +107,13 @@ const createAutocomplete = ( items: [ getScopeItem( - {searchValue} i innboks + {searchValue} {t('search.autocomplete.inInbox')} , - `${searchResults.length} treff`, + `${searchResults.length} ${t('word.hits', { count: searchResults.length })}`, ), ...searchHits, ], - groups: { searchResults: { title: 'Anbefalte treff' } }, + groups: { searchResults: { title: t('search.autocomplete.recommendedHits') } }, } as AutocompleteProps; }; diff --git a/packages/frontend/src/i18n/resources/en.json b/packages/frontend/src/i18n/resources/en.json index efbbba6c..52a83b78 100644 --- a/packages/frontend/src/i18n/resources/en.json +++ b/packages/frontend/src/i18n/resources/en.json @@ -127,8 +127,12 @@ "savedSearches.saved_success": "Search saved", "savedSearches.title": "{count, plural, =0 {You have no saved searches} one {# saved search} other {# saved searches}}", "savedSearches.update_success": "Search updated", + "search.noHits": "No hits", + "search.searchFor": "Search for", "search.search.results": "Your search returned {count, plural, one {# hit} other {# hits}}", "search.title.in_inbox": "in inbox", + "search.autocomplete.inInbox": "in inbox", + "search.autocomplete.recommendedHits": "Recommended hits", "sidebar.archived": "Archive", "sidebar.archived.label": "Press here to go to Archive", "sidebar.deleted": "Trash", @@ -182,5 +186,6 @@ "word.status": "Status", "word.to": "to", "word.transmissions": "Transmissions", + "word.hits": "{count, plural, one {# hit} other {# hits}}", "word.you": "you" } diff --git a/packages/frontend/src/i18n/resources/nb.json b/packages/frontend/src/i18n/resources/nb.json index 71abd252..5e33e252 100644 --- a/packages/frontend/src/i18n/resources/nb.json +++ b/packages/frontend/src/i18n/resources/nb.json @@ -127,8 +127,12 @@ "savedSearches.saved_success": "Søk lagret", "savedSearches.title": "{count, plural, =0 {Du har ingen lagrede søk} one {# lagret søk} other {# lagrede søk}}", "savedSearches.update_success": "Søk oppdatert", + "search.noHits": "Ingen treff", + "search.searchFor": "Søker etter", "search.search.results": "Ditt søk ga {count, plural, one {# treff} other {# treff}}", "search.title.in_inbox": "i innboks", + "search.autocomplete.inInbox": "i innboks", + "search.autocomplete.recommendedHits": "Anbefalte treff", "sidebar.archived": "Arkiv", "sidebar.archived.label": "Trykk her for å gå til Arkiv", "sidebar.deleted": "Papirkurv", @@ -182,5 +186,6 @@ "word.status": "Status", "word.to": "til", "word.transmissions": "Transmissions", + "word.hits": "{count, plural, one {# treff} other {# treff}}", "word.you": "deg" }