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 options are not translated #525

Open
mesemus opened this issue Oct 18, 2023 · 0 comments
Open

Sort options are not translated #525

mesemus opened this issue Oct 18, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@mesemus
Copy link
Contributor

mesemus commented Oct 18, 2023

Package version (if known): all

Describe the bug

Inside SearchOptions class the sort_options are a static member. As such they are evaluated the first time the module is loaded.

Translations of the title there use from invenio_i18n import gettext as _ which is applied at the load time, and translates the string using the initial locale.

When this member is accessed during the request under a different locale, no translation is performed and English text
is always used regardless of user's locale.

Steps to Reproduce

Spin up a repository and go to its search page. Switch locale to a different language and the sort options will
keep in English, will not change the translation.

Expected behavior

sort_options.title should be lazy translated, i.e. just replacing import from invenio_i18n import gettext as _ with from invenio_i18n import lazy_gettext as _ gets it working.

@mesemus mesemus added the bug Something isn't working label Oct 18, 2023
@mesemus mesemus changed the title Sort options are not translated as they are static and do not use lazy translations Sort options are not translated as they do not use lazy translations Oct 18, 2023
@mesemus mesemus changed the title Sort options are not translated as they do not use lazy translations Sort options are not translated Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant