Skip to content

Commit

Permalink
Don't try to translate datasets and flows in filters
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinvanschoren committed Jan 25, 2024
1 parent d68456a commit 161be72
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/public/locales/en/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ filters:
Weka: "Weka {{version}}"
mlr: "MLR {{version}}"
Moa: "Moa {{version}}"
dataset: "Dataset"
flow: "Flow"
button:
Croissant: "Croissant"
XML: "XML"
Expand Down
15 changes: 12 additions & 3 deletions app/src/components/search/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const FilterChip = styled(Chip)`
`;

// Handles special cases in the filter options
const processOption = (option) => {
const processOption = (option, translate = true) => {
// Homogenize notation for library reporting and versioning
const libraries = [
"sklearn",
Expand Down Expand Up @@ -45,20 +45,29 @@ const processOption = (option) => {
} else {
return [`filters.${lib}`];
}
} else {
} else if (translate) {
// If comma or newline separated, return the first
const segments = option.split(/,|\n/);
return [`filters.${segments[0]}`];
} else {
return option;
}
};

const Filter = ({ label, options, values, onRemove, onSelect }) => {
// Don't invoke translation for flows or datasets
const translate = !["flow", "dataset"].includes(label.split(".").pop());
return (
<React.Fragment>
{options.map((option) => (
<FilterChip
label={
i18n.t(...processOption(option.value)) + " (" + option.count + ")"
(translate
? i18n.t(...processOption(option.value, translate))
: option.value) +
" (" +
option.count +
")"
}
key={option.value}
clickable
Expand Down
2 changes: 2 additions & 0 deletions app/src/pages/r/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const search_facets = [
{
label: "filters.dataset",
field: "run_task.source_data.name.keyword",
translate: false,
},
{
label: "filters.tasktype",
Expand All @@ -59,6 +60,7 @@ const search_facets = [
{
label: "filters.flow",
field: "run_flow.name",
translate: false,
},
];

Expand Down

0 comments on commit 161be72

Please sign in to comment.