Skip to content
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

Sort order label translations are not being applied #215

Closed
cessda-bitbucket-importer opened this issue Sep 3, 2020 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@cessda-bitbucket-importer

Original report on BitBucket by John Shepherdson (GitHub: john-shepherdson).


Instead the keys are being displayed.

relevance: 'Relevance',
    titleAscending: 'Title (A - Z)',
    titleDescending: 'Title (Z - A)',
    dateAscending: 'Date of collection (oldest)',
    dateDescending: 'Date of collection (newest)'

@cessda-bitbucket-importer
Copy link
Author

Original comment by Matthew Morris (GitHub: matthew-morris-cessda).


This was caused by translations not being set up properly.

Translations were originally applied in SortingSelector.jsx using an override that modified the internals of SearchkitSortingSelector directly. The internals were changed in an update, necessitating changing how translations were applied.

export class SortingSelector extends SearchkitSortingSelector<Props> {
  render(): Node {
    _.map(this.accessor.options.options, (option: Object): Object => {
      option.label = counterpart.translate(option.translation);
      return option;
    });
  }
}

Translations are now applied in TopBar.jsx by applying the change to the label field when the components are being declared.

<SortingSelector className="level-item" options={[{
  label: counterpart.translate('sorting.relevance'),
  key: 'relevance',
  field: '_score',
  order: 'desc',
  defaultOption: true
}, {
  label: counterpart.translate('sorting.titleAscending'),
  key: 'title-ascending',
  field: 'titleStudy.raw',
  order: 'asc',
  defaultOption: false
}, {
  label: counterpart.translate('sorting.titleDescending'),
  key: 'title-descending',
  field: 'titleStudy.raw',
  order: 'desc',
  defaultOption: false
}, {
  label: counterpart.translate('sorting.dateAscending'),
  key: 'date-ascending',
  field: 'dataCollectionPeriodStartdate',
  order: 'asc',
  defaultOption: false
}, {
  label: counterpart.translate('sorting.dateDescending'),
  key: 'date-descending',
  field: 'dataCollectionPeriodStartdate',
  order: 'desc',
  defaultOption: false
}]}/>

@cessda-bitbucket-importer
Copy link
Author

Original comment by John Shepherdson (GitHub: john-shepherdson).


Translations restored in DEV and STAGING

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants