Skip to content

Add support for locale_behavior: "respect_accept_language" #591

@fenech

Description

@fenech

Preflight checklist

Ory Network Project

No response

Describe your problem

Currently, it seems like this mode is not supported, since there are no references to the "accept-language" header in the library.

In fact, it is not the key: project.default_locale which is used (as the name would perhaps suggest), but the intl.locale config key

locale={config.intl?.locale ?? "en"}
.

Describe your ideal solution

I would expect the behaviour of the default OryProvider to interpret the "accept-language" header in "respect_accept_language" mode, and use that as the default application language, unless otherwise overridden in the config object.

I imagine that this would entail adding another function to "utils" which parses the header and possibly cross-references it with the project.enabled_locales array from config. Once this approach is approved, I'd be happy to open a PR.

Workarounds or alternatives

I was looking at using window.navigator.language as an alternative but this would mean that the config object would need to be rendered client-side.

Version

main 795b1bd

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions