[wp-trac] [WordPress Trac] #60668: Missing translation in login_header() first parameter
WordPress Trac
noreply at wordpress.org
Fri Mar 1 10:22:14 UTC 2024
#60668: Missing translation in login_header() first parameter
-------------------------+-----------------------------
Reporter: juliobox | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: I18N | Version:
Severity: minor | Keywords: needs-patch
Focuses: |
-------------------------+-----------------------------
Hey there
Actuel code from WP (wp-login.php):
{{{#!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
<?php
function login_header( $title = 'Log In', $message = '', $wp_error = null
) {
if ( 'Log In' === $title ) {
$title = __( 'Log In' );
}
}}}
or
{{{#!php
<?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
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60668>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list