Make WordPress Core

Opened 2 years ago

Last modified 5 weeks ago

#43700 reviewing enhancement

Language switcher on the login screen

Reported by: johnbillion Owned by: johnbillion
Milestone: 5.6 Priority: normal
Severity: normal Version: 4.7
Component: I18N Keywords: needs-patch
Focuses: accessibility Cc:

Description (last modified by johnbillion)

Since [41692] it's possible to control the language of the login screen using the wp_lang query variable (eg. wp-login.php?wp_lang=it_IT). This is a hidden feature that's only used by the interim login modal.

A language switcher should be introduced on the login screen that makes use of this so users can use the login screen, the password reset screens, and the registration screen in their own language. The behaviour would be the same as the language choosers that are used elsewhere in core, for example on the General Settings screen and on the Multisite registration screens.

One thing that needs to be considered is how the language persists between screens, how to persist POSTed values such as redirect_to, and whether it should persist in user meta once the user successfully logs in. Suggestions welcome.

Attachments (4)

43700.1.diff (3.1 KB) - added by Nikschavan 2 years ago.
43700.diff (6.2 KB) - added by johnbillion 15 months ago.
43700.2.diff (7.1 KB) - added by Nikschavan 12 months ago.
43700.png (16.4 KB) - added by afercia 6 weeks ago.
Focus style cut-off

Download all attachments as: .zip

Change History (20)

#1 @johnbillion
2 years ago

  • Description modified (diff)

#2 follow-up: @swissspidy
2 years ago

How has this been implemented on WordPress.org?

#3 in reply to: ↑ 2 @netweb
2 years ago

Replying to swissspidy:

How has this been implemented on WordPress.org?

I've not looked at it personally but the code is here: https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login

#4 @Nikschavan
2 years ago

Seems this was the main commit for adding this to WordPress.org - https://meta.trac.wordpress.org/changeset/6677

2 years ago

#5 @Nikschavan
2 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

Patch 43700.1.diff is the first pass at adding the language switcher to the login window.

One thing that needs to be considered is how the language persists between screens, how to persist POSTed values such as redirect_to, and whether it should persist in user meta once the user successfully logs in. Suggestions welcome.

This attached patch adds the $_GET parameters to hidden variables so that they are retained after the page is reloaded.
Currently three $_GET parameters are handled interim-login, redirect_to, action.

15 months ago

#6 follow-up: @johnbillion
15 months ago

43700.diff is a work in progress patch that continues the work of @Nikschavan. Changes:

  • Ensure the language switcher only appears when there are language choices available
  • Store the selected language in a cookie so it persists between all of the possible login screens and actions
  • Take the cookie into account when determining the user's locale
  • Allow the user to switch to en_US when it's not the site's default language

#7 @swissspidy
14 months ago

  • Milestone changed from Awaiting Review to Future Release

12 months ago

#8 in reply to: ↑ 6 @Nikschavan
12 months ago

43700.2.diff Refreshes @johnbillion's patch with latest trunk and fixes 2 PHP notices.

  • Set default value of explicit_option_en_us as false in wp_dropdown_languages() to avoid PHP notice for undefined index on Line 1511 in src/wp-includes/l10n.php
  • Use esc_url_raw() instead of sanitize_url() to remove depracation warning in wp-login.php

@johnbillion, @swissspidy - Can this ticket be considered for the 5.3 release cycle?

#9 @Nikschavan
12 months ago

Another question would be - should the value of wp_lang be set to user locale after successful login, If user locale is currently empty?

#10 @johnbillion
5 months ago

  • Milestone changed from Future Release to 5.5
  • Owner set to johnbillion
  • Status changed from new to reviewing

This ticket was mentioned in PR #248 on WordPress/wordpress-develop by johnbillion.

3 months ago

Trac ticket: https://core.trac.wordpress.org/ticket/43700

This continues the work on the patches already uploaded to 43700. It introduces a language switcher to the login screen, which also affects its derivatives such as the password reset screens and user registration.

The following closely related functionality has also been implemented:

  • Add the language parameter to the login and password reset URLs in the email sent to a user when they are added to a site.
  • Ensure the password reset email is always sent to the user in their chosen language.
  • Add the language parameter to the URL in the password reset email.

Still to do:

  • Decide whether, upon login, the user's locale should be updated to the one they chose on the login screen. Probably yes.

This ticket was mentioned in Slack in #core by david.baumwald. View the logs.

6 weeks ago

#13 @davidbaumwald
6 weeks ago

@johnbillion IS this one still on your list to tackle before 5.5 Beta 1 in a few days time? Anything else needed here besides testing?

#14 @afercia
6 weeks ago

  • Focuses accessibility added
  • Keywords needs-patch added; has-patch removed

Testing 43700.2.diff there are a couple accessibility issues that need to be fixed:

  1. Using the change event on a select is a usability and accessibility issue and needs to be avoided. Users should be in control of triggering the language switch, thus there's the need of a button to submit the language form. See also #40925 and #25103.
  2. Minor CSS issue: the language form uses overflow: hidden thus the select focus style is slightly cut-off on the top and bottom edges. See attached screenshot.

6 weeks ago

Focus style cut-off

#15 follow-up: @johnbillion
6 weeks ago

  • Keywords needs-testing removed

This needs some more work, including further functional work that I haven't finalised yet, plus design work to improve the layout now that we have several links of different styles at the bottom of this screen, plus the a11y issues mentioned above. Punting to 5.6.

#16 in reply to: ↑ 15 @afercia
5 weeks ago

  • Milestone changed from 5.5 to 5.6

Replying to johnbillion:

Punting to 5.6.

Forgot to punt? :)

Note: See TracTickets for help on using tickets.