Login page translation

Hi, I would like to translate my login page:

http://pttraining.decorolux.com/login/

function my_custom_login_label( $translated_text, $text, $domain ) {
if (in_array( $GLOBALS[‘pagenow’], array( ‘wp-login.php’, ‘wp-register.php’ ) )) {
if ($translated_text === ‘Username or email’) $translated_text = ‘Felhasználónév vagy jelszó’;
if ($translated_text === ‘Password’) $translated_text = ‘Jelszó’;
if ($translated_text === ‘← Back to %s’) $translated_text = ‘← YOUR TEXT’;

return $translated_text;

}
}
add_filter( ‘gettext’, ‘my_custom_login_label’, 20, 3 );

I found this code, but it doesnt do the trick. Could you help?

Thanks!

Hi There,

I have tested the following code and it functioned properly.

//Translate WordPress Login
function my_custom_login_label( $translated_text, $text, $domain ) {
    if (in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) )) {
        if ($translated_text === 'Username or Email Address') $translated_text = 'YOUR TEXT';
        if ($translated_text === 'Password') $translated_text = 'YOUR TEXT';
        if ($translated_text === 'Remember Me') $translated_text = 'YOUR TEXT';
        if ($translated_text === 'Lost your password?') $translated_text = 'YOUR TEXT';

    return $translated_text;
  }
}
add_filter( 'gettext', 'my_custom_login_label', 20, 3 );

Try moving your code into the top of your functions.php file. Below the following liine

// Additional Functions

Also make sure that your child theme is activated and also purge your server cache before testing.

Hope that helps.
Thanks!

Hi,

Here’s what I get after I add the code:

Here, just to show that the code has been added:

Any ideas? It won’t even display the placeholder text, and the Username and Email label aren’t gone, so there are more things going on ^^

Thanks!

Hi There,

Could you please try updating your code to this:

//Translate WordPress Login
function my_custom_login_label( $translated_text, $text, $domain ) {
    if (in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) )) {
        if ($translated_text === 'Username Or Email') $translated_text = 'YOUR TEXT';
        if ($translated_text === 'Password') $translated_text = 'YOUR TEXT';
        if ($translated_text === 'Remember Me') $translated_text = 'YOUR TEXT';
        if ($translated_text === 'Forgot Your Password?') $translated_text = 'YOUR TEXT';

    return $translated_text;
  }
}
add_filter( 'gettext', 'my_custom_login_label', 20, 3 );
add_filter( 'ngettext', 'my_custom_login_label', 20, 3 );

If it still doesn’t work, would you mind providing us with login credentials(by clicking on the Secure Note button at the bottom) so we can take a closer look? To do this, you can make a post with the following info:

  • Link login to your site
  • WordPress Admin username / password

Thanks.

Hi,

Unfortunately, that did not fix the issue.
I’ll add the login in a moment!

Thanks!

HI THERE,

All the information my colleagues gave is for the normal case of the login page. But you have a specific page which is called Login that you used to add a login and redirected the actual login page of the WordPress to that.

That is not possible to translate those portions as you added in the page.

If you switch back to the normal login screen of the WordPress then you will see the changes.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.