Add preferred language to user and language to redirect from request

Created on 5 April 2023, over 1 year ago
Updated 11 May 2023, over 1 year ago

Problem/Motivation

If we have few languages it would be to set preferred language automatically from his request and redirect users to right language from his request not to default language.

Steps to reproduce

Add few languages and language switcher and try to login from different languages. You will go to the default and in user preferred language you will see default language

Proposed resolution

Add language manager to controller.
Add preferred lanaguge from the request.
Correct redirect with right language.

✨ Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine artemboiko Lviv

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @artemboiko
  • @artemboiko opened merge request.
  • πŸ‡§πŸ‡ͺBelgium matthijs

    Thanks for your MR! I like the idea, but I did some tests with the getLocale() method (since I didn't know that one) and for me it always returned "en" even though I was browsing the site in Dutch (nl).
    Wouldn't it be better to store the current language in the state, so we can rely on that instead of the request object?

  • πŸ‡ΊπŸ‡¦Ukraine artemboiko Lviv

    Hi @Matthijs yes, right getLocale not good here I changed it to LanguageManager, also I don't see any reason to use custom language negotiator in module so I removed. This is breaking all logic regarding localisation. With this patch user should add redirect_uri per language(and I guess need not to loose add this to documentation) like these:

    en/oidc/login-redirect
    de/oidc/login-redirect

    And if user want to use one redirect uri need to write custom language negotiator with special logic.

Production build 0.71.5 2024