#60668 closed enhancement (fixed)
Missing translation in login_header() first parameter
Reported by: | juliobox | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 6.6 | Priority: | normal |
Severity: | minor | Version: | 2.1 |
Component: | Login and Registration | Keywords: | good-first-bug has-patch commit |
Focuses: | Cc: |
Description
Hey there
Actuel code from WP (wp-login.php):
<?php function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
The $title
here will be print as is, in any language. WordPress uses it the right way by always passing a translatable string as first param, but since there is a default value, some plugins can use it without it (and they do it, i've check wpdirectory, more than 1M install, 7 plugins are doing it).
So we cannot remove the default value or we will break the world in half, we have to choose between this:
<?php function login_header( $title = 'Log In', $message = '', $wp_error = null ) { if ( 'Log In' === $title ) { $title = __( 'Log In' ); }
or
<?php function login_header( $title = null, $message = '', $wp_error = null ) { if ( is_null( $title ) ) { $title = __( 'Log In' ); }
We can also use a ternary test to do it, as you want, the point is, what is the default value now?
In both cases and same as now you can still pass ""
to print nothing and it's OK.
By using null as default and passing "Log In"
as param you will print a non translated string "Log In"
(in any language).
By using "Log In"
as default and passing "Log In"
as param you will print a correctly translated string "Se connecter"
(here in french).
Thanks
Attachments (2)
Change History (14)
#1
@
8 months ago
- Component changed from I18N to Login and Registration
- Keywords good-first-bug added
- Milestone changed from Awaiting Review to Future Release
- Version set to 2.1
This ticket was mentioned in PR #6209 on WordPress/wordpress-develop by @mainetenance.
8 months ago
#2
- Keywords has-patch added; needs-patch removed
#3
@
8 months ago
- Milestone changed from Future Release to 6.6
- Owner set to audrasjb
- Status changed from new to accepted
The proposed PR looks good to me. Thank you @mainetenance and congrats for your first patch.
Moving to milestone 6.6.
This ticket was mentioned in Slack in #core by nhrrob. View the logs.
6 months ago
#5
@
6 months ago
I was wondering if the null check should be defined at the start of the function before "global...", or if will it even make any difference.
#6
@
6 months ago
- Keywords commit added
It wouldn't make any difference :)
Let's ship this one as proposed.
@audrasjb commented on PR #6209:
6 months ago
#7
committed in https://core.trac.wordpress.org/changeset/58209
#8
@
6 months ago
- Resolution set to fixed
- Status changed from accepted to closed
Committed in [58209].
A null check looks reasonable to me.