Skip to content

Sort options are not translated #525

Open
@mesemus

Description

@mesemus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions