-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add translations to DataTable and DataFilters #2107
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
import { RadioGroup } from "../RadioGroup"; | ||
import { Radio } from "../Radio"; | ||
import { MRT_ColumnDef, MRT_RowData } from "material-react-table"; | ||
import { Trans, useTranslation } from "react-i18next"; | ||
|
||
export type DataFilterValue = string | string[] | undefined; | ||
|
||
|
@@ -126,6 +127,8 @@ | |
additionalActions, | ||
filters: filtersProp = [], | ||
}: DataFiltersProps) => { | ||
const { t } = useTranslation(); | ||
|
||
const [filters, setFilters] = useState<DataFilter[]>(filtersProp); | ||
|
||
const initialInputValues = useMemo(() => { | ||
|
@@ -253,7 +256,7 @@ | |
aria-controls={isFiltersMenuOpen ? "filters-menu" : undefined} | ||
aria-expanded={isFiltersMenuOpen ? "true" : undefined} | ||
aria-haspopup="true" | ||
ariaLabel="Filters" | ||
ariaLabel={t("filters.filters.arialabel")} | ||
endIcon={<FilterIcon />} | ||
onClick={(event) => { | ||
setFiltersMenuAnchorElement(event.currentTarget); | ||
|
@@ -305,11 +308,24 @@ | |
<Subordinate component="div"> | ||
{!latestFilterValue || | ||
(Array.isArray(latestFilterValue) && | ||
latestFilterValue.length === 0) | ||
? `Any ${filter.label.toLowerCase()}` | ||
: Array.isArray(latestFilterValue) | ||
? `${latestFilterValue.length} selected` | ||
: latestFilterValue} | ||
latestFilterValue.length === 0) ? ( | ||
<Trans | ||
i18nKey="filters.menuitem.any" | ||
values={{ | ||
label: filter.label.toLowerCase(), | ||
}} | ||
/> | ||
) : Array.isArray(latestFilterValue) ? ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To my point earlier, can |
||
<Trans | ||
count={latestFilterValue.length} | ||
i18nKey="filters.menuitem.selected" | ||
values={{ | ||
selected: latestFilterValue.length, | ||
}} | ||
/> | ||
) : ( | ||
latestFilterValue | ||
)} | ||
</Subordinate> | ||
</Box> | ||
<ChevronRightIcon /> | ||
|
@@ -320,7 +336,7 @@ | |
</MuiMenu> | ||
</> | ||
), | ||
[isFiltersMenuOpen, filtersMenuAnchorElement, filtersProp, filters] | ||
); | ||
|
||
return ( | ||
|
@@ -419,7 +435,7 @@ | |
inputValues[filterPopoverCurrentFilter.id] && ( | ||
<MuiIconButton | ||
size="small" | ||
aria-label="Clear filter" | ||
aria-label={t("filters.filter.clear")} | ||
onClick={() => { | ||
handleInputChange( | ||
filterPopoverCurrentFilter.id, | ||
|
@@ -489,7 +505,7 @@ | |
} | ||
> | ||
<Radio | ||
label="Any" | ||
label={t("filters.filter.any")} | ||
value={""} | ||
isChecked={ | ||
!inputValues[filterPopoverCurrentFilter.id] | ||
|
@@ -533,7 +549,7 @@ | |
<Box sx={{ display: "flex", gap: 2, width: "100%" }}> | ||
<SearchField | ||
value={searchValue} | ||
label="Search" | ||
label={t("filters.search.label")} | ||
onClear={() => { | ||
setSearchValue(""); | ||
onChangeSearch(""); | ||
|
@@ -544,7 +560,7 @@ | |
<Box> | ||
<Button | ||
variant="primary" | ||
label="Search" | ||
label={t("filters.search.label")} | ||
onClick={() => onChangeSearch(searchValue)} | ||
/> | ||
</Box> | ||
|
@@ -560,7 +576,7 @@ | |
<Box> | ||
<Button | ||
variant="secondary" | ||
label="Clear filters" | ||
label={t("filters.clear.label")} | ||
onClick={() => clearAllFilters()} | ||
/> | ||
</Box> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,22 @@ table.fetchedrows.text = Byl na\u010Dten {{totalRows}} \u0159\u00E1dek | |
table.fetchedrows.text_plural = Celkem na\u010Dteno \u0159\u00E1dk\u016F: {{totalRows}} | ||
table.rows.text = {{totalRows}} \u0159\u00E1dek | ||
table.rows.text_plural = Po\u010Det \u0159\u00E1dk\u016F: {{totalRows}} | ||
table.actions = [[odyssey:odyssey-react-mui: table.actions]] | ||
table.draghandle.tooltip = [[odyssey:odyssey-react-mui: table.draghandle.tooltip]] | ||
table.draghandle.arialabel = [[odyssey:odyssey-react-mui: table.draghandle.arialabel]] | ||
table.reorder.tofront = [[odyssey:odyssey-react-mui: table.reorder.tofront]] | ||
table.reorder.forward = [[odyssey:odyssey-react-mui: table.reorder.forward]] | ||
table.reorder.backward = [[odyssey:odyssey-react-mui: table.reorder.backward]] | ||
table.reorder.toback = [[odyssey:odyssey-react-mui: table.reorder.toback]] | ||
table.density.arialabel = [[odyssey:odyssey-react-mui: table.density.arialabel]] | ||
table.columnvisibility.arialabel = [[odyssey:odyssey-react-mui: table.columnvisibility.arialabel]] | ||
table.moreactions.arialabel = [[odyssey:odyssey-react-mui: table.moreactions.arialabel]] | ||
filters.filters.arialabel = [[odyssey:odyssey-react-mui: filters.filters.arialabel]] | ||
filters.filter.any = [[odyssey:odyssey-react-mui: filters.filter.any]] | ||
filters.filter.clear = [[odyssey:odyssey-react-mui: filters.filter.clear]] | ||
filters.menuitem.selected = [[odyssey:odyssey-react-mui: filters.menuitem.selected]] | ||
filters.menuitem.any = [[odyssey:odyssey-react-mui: filters.menuitem.any]] | ||
filters.clear.label = [[odyssey:odyssey-react-mui: filters.clear.label]] | ||
filters.search.label = [[odyssey:odyssey-react-mui: filters.search.label]] | ||
Comment on lines
+17
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming these values and the ones like it in other properties files will get replaced with translations eventually? Sorry for the question about this if it's common knowledge... I just haven't seen this before. |
||
toast.close.text = zav\u0159\u00EDt | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is a bug or not, so please tell me if I got this wrong.
latestFilterValue
is set with the following code:Unless I'm mistaken, the type for
latestFilterValue
is either astring
(I'm assumingvalue
is of typestring
) orundefined
.I'm suspecting in this code,
latestFilterValue
is being treated as anArray
?The
string
type has alength
property on it's prototype, but it's when I seeArray.isArray(latestFilterValue)
above and below this point that I'm a bit confused?Can you clarify this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latestFilterValue
may be one of three things:undefined
, for a filter that doesn't have a value set (which usually translates to something like "Any status" or "Any age"