Skip to content

Commit

Permalink
fix: Search autocomplete translations
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdigdir committed Dec 16, 2024
1 parent ec9e232 commit c3b6fac
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}

Expand All @@ -90,26 +94,26 @@ const createAutocomplete = (
items: [
getScopeItem(
<span>
<mark>{searchValue}</mark> i innboks
<mark>{searchValue}</mark> {t('search.autocomplete.inInbox')}
</span>,
'Ingen treff',
t('search.noHits'),
),
],
groups: { noHits: { title: 'Ingen treff' } },
groups: { noHits: { title: t('search.noHits') } },
} as AutocompleteProps;
}

return {
items: [
getScopeItem(
<span>
<mark>{searchValue}</mark> i innboks
<mark>{searchValue}</mark> {t('search.autocomplete.inInbox')}
</span>,
`${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;
};

Expand Down
5 changes: 5 additions & 0 deletions packages/frontend/src/i18n/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -182,5 +186,6 @@
"word.status": "Status",
"word.to": "to",
"word.transmissions": "Transmissions",
"word.hits": "{count, plural, one {# hit} other {# hits}}",
"word.you": "you"
}
5 changes: 5 additions & 0 deletions packages/frontend/src/i18n/resources/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -182,5 +186,6 @@
"word.status": "Status",
"word.to": "til",
"word.transmissions": "Transmissions",
"word.hits": "{count, plural, one {# treff} other {# treff}}",
"word.you": "deg"
}

0 comments on commit c3b6fac

Please sign in to comment.