Skip to content

Commit

Permalink
feat: add locales
Browse files Browse the repository at this point in the history
  • Loading branch information
g-saracca committed Dec 11, 2024
1 parent 0bc201e commit 452c68d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
4 changes: 3 additions & 1 deletion public/locales/en/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@
"question": "Are you sure you want to publish your collection? Once you do so it must remain published.",
"error": "There was an error publishing your collection."
},
"publishedAlert": "Your collection is now public."
"publishedAlert": "Your collection is now public.",
"addFacetFilter": "Add {{labelName}} facet filter",
"removeSelectedFacet": "Remove {{labelName}} facet filter"
}
2 changes: 2 additions & 0 deletions public/locales/en/shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"add": "Add",
"cancel": "Cancel",
"continue": "Continue",
"more": "More...",
"less": "Less...",
"pageNumberNotFound": {
"heading": "Page Number Not Found",
"message": "The page number you requested does not exist. Please try a different page number."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ interface CollectionItemsPanelProps {
* Every time a load of items is triggered, the pagination info is updated and the URL is updated with the new query params so it can be shared and the user can navigate back and forward in the browser.
*/

// TODO:ME - margin top scroll
// TODO:ME - Add locales

export const CollectionItemsPanel = ({
collectionId,
collectionRepository,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Button, Col, Row } from '@iqss/dataverse-design-system'
import { X as CloseIcon } from 'react-bootstrap-icons'
import { CollectionItemsFacet } from '@/collection/domain/models/CollectionItemSubset'
Expand All @@ -25,6 +26,9 @@ export const FacetFilterGroup = ({
onFacetChange,
isLoadingCollectionItems
}: FacetFilterGroupProps) => {
const { t } = useTranslation('collection')
const { t: tShared } = useTranslation('shared')

const [visibleCount, setVisibleCount] = useState(FACETS_PER_VIEW)

const handleShowMore = () => {
Expand Down Expand Up @@ -63,7 +67,9 @@ export const FacetFilterGroup = ({
role="option"
aria-selected={isFacetLabelSelected}
aria-label={
isFacetLabelSelected ? `Remove ${label.name} filter` : `Add ${label.name} filter`
isFacetLabelSelected
? t('removeSelectedFacet', { labelName: label.name })
: t('addFacetFilter', { labelName: label.name })
}
disabled={isLoadingCollectionItems}
variant="link"
Expand All @@ -85,7 +91,7 @@ export const FacetFilterGroup = ({
size="sm"
onClick={handleShowLess}
disabled={isLoadingCollectionItems}>
Less...
{tShared('less')}
</Button>
)}
</Col>
Expand All @@ -96,7 +102,7 @@ export const FacetFilterGroup = ({
size="sm"
onClick={handleShowMore}
disabled={isLoadingCollectionItems}>
More...
{tShared('more')}
</Button>
)}
</Col>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useTranslation } from 'react-i18next'
import { Button } from '@iqss/dataverse-design-system'
import { X as CloseIcon } from 'react-bootstrap-icons'
import { FilterQuery } from '@/collection/domain/models/GetCollectionItemsQueryParams'
Expand All @@ -14,6 +15,8 @@ export const SelectedFacets = ({
onRemoveFacet,
isLoadingCollectionItems
}: SelectedFacetsProps) => {
const { t } = useTranslation('collection')

return (
<div className={styles['selected-facets-container']}>
{selectedFilterQueries.map((filterQuery) => {
Expand All @@ -25,7 +28,7 @@ export const SelectedFacets = ({
className={styles['selected-facet-btn']}
onClick={() => onRemoveFacet(filterQuery)}
disabled={isLoadingCollectionItems}
aria-label={`Remove ${labelName} query filter`}
aria-label={t('removeSelectedFacet', { labelName })}
key={filterQuery}>
{labelName} <CloseIcon size={22} />
</Button>
Expand Down

0 comments on commit 452c68d

Please sign in to comment.