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

utils: implement "lazy" format_locale helper function #135

Open
slint opened this issue Aug 16, 2024 · 0 comments
Open

utils: implement "lazy" format_locale helper function #135

slint opened this issue Aug 16, 2024 · 0 comments

Comments

@slint
Copy link
Member

slint commented Aug 16, 2024

Since get_locale is actually relying on the request/session/application global state, it could be that we can inject it as a lazy-loaded value in places. We have a utility that injects the locale in format-style string, which for end usable would look like:

from invenio_i18n import format_locale as _l

class AffiliationsSearchOptions(SearchOptions):
    """Search options."""

    suggest_parser_cls = SuggestQueryParser.factory(
        fields=[
            "name^100", 
            _l("title.{locale}^20"),
        ],
    )

    ...

Originally posted by @slint in inveniosoftware/invenio-records-resources#594 (comment)

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

No branches or pull requests

1 participant