Translations are not working

Hi plese can you help me I´m trying to translate some words from English to Spanish I followed your guide:

I am using pro

for now I need to translate:

Read more: Leer más

Search: Buscar

Steps that I already did.

  1. Download and Install Poedit software.

  2. Connect to FTP to the following directory: /public_html/wp-content/themes/pro/framework/lang

  3. Open the x.po file translate the two words mentioned before “search” “read more”

  4. create the es_ES.po file.

  5. compile the es_ES file to create the es_ES.mo

  6. Create the lang folder on the child theme: /public_html/wp-content/themes/pro-child/lang

  7. Copy es_ES.po and es_ES.po file to the lang folder

  8. Added the following lines on child function.php:

add_action( ‘after_setup_theme’, ‘load_child_language’ );
function load_child_language() {
load_child_theme_textdomain( ‘x’, get_stylesheet_directory() . ‘/languages’ );
}

9.setup my site language to spanish.

nothing worked also I copied the es_ES.po and es_ES.po to the:

/public_html/wp-content/languages/themes

nothing worked.

Anyone can help???

Hello There,

Thanks for writing in! The issue occurres because you have a wrong translation filenames.
Please rename it to:
__x__-es_ES.po
__x__-es_ES.mo

And upload it to:
/public_html/wp-content/languages/themes

Hope this helps. Please let us know how it goes.

Hi, It didn´t work with mi child theme, please can you check what I´m doing wrong.

Hello There,

If you are going to upload the file in the child theme, it should be in this location:
/wp-content/themes/pro-child/framework/lang/

For best results, please follow my suggestion. The files should be in /public_html/wp-content/languages/themes

Please let us know how it goes.

Hi it didn´t work with the Child theme I need to make it work because I don´t wanna lose my translations on theme updates as you mentioned on you documentation.

Uploading your Translation
Now you’ve got your translation files ready to go (both .po and .mo files). You can upload those to /wp-content/themes/x/framework/lang

Important! Uploading your translation files to the parent theme, will mean they’ll be overwritten on a theme update and lost. We’d highly recommend the following two methods below instead.

Uploading your Translation in a Child Theme
This section presumes you already have a child theme setup and does not cover setting up a child theme, if you don’t have a child theme setup, you can download one from the members area here

Create a “languages” folder in your child theme, for example /wp-content/themes/x-child/languages and upload your translations to that file.

But now we need to tell WordPress to load the translation, open up your child themes functions.php and add the following code

add_action( ‘after_setup_theme’, ‘load_child_language’ );
function load_child_language() {
load_child_theme_textdomain( ‘x’, get_stylesheet_directory() . ‘/languages’ );
}
This tells WordPress to find the translation in the child theme languages directory.

Hello There,

I have added a custom function in your child theme’s functions.php file. I used this code:

add_action( 'after_setup_theme', 'load_child_language' );
function load_child_language() {
	load_child_theme_textdomain( '__x__', get_stylesheet_directory_uri() . '/languages' );
}

Please check your site now.

Didn´t work.

I tried to find why the translation is not working and I discovered that in your .po file, the Read More text has a … in the end while that is not present in x.pot. I tried generating a .mo again but it’s still not working. I can’t go deeper as you have third party plugins and caching setup and I could not disable that as well as other settings you have in your site. Would you mind trying a clean install in a staging server. For now, I’ve added this alternative way/code in your functions.php to change the Read More and Search texts.

// Alternate Text

function alternate_text( $translated_text, $text, $domain ) {
  switch ( $translated_text ) {
    case 'Read More' :
      $translated_text = __( 'Leer más', '__x__' );
      break;
    case 'Search' :
      $translated_text = __( 'Buscar', '__x__' );
      break;
  }
  return $translated_text;
}
add_filter( 'gettext', 'alternate_text', 20, 3 );

Thanks.

Hello that is a complicated solution and a temporary I can disable the caching plugin there is no problem with that I need the way with the child theme not a workaround, please help me.

The given staging credentials doesn’t work. Please check. Thanks.

Hi there,

Would you mind providing a video recording on how you’re connecting? I tried all possible setup, plain FTP, SFTP (22 and 2222, and other ports), FTP over TLS, and so on. But I’m unable to get in with this error

Response: 530 Login authentication failed

Maybe there is a firewall? Maybe we’re connecting to a different staging host? I tried http://hwstechc.wwwls29.a2hosted.com as a host but still wrong.

Thanks!

@Rad please try again youtube video attached.

Hi there,

I did as how you did it on the video, and still the same. Perhaps there is a security or firewall blocking access to your site?

Instead, please provide your hosting panel’s login credentials, maybe there is an available file manager we can use instead of FTP.

Thanks!

Please come on are you really trying??? I´m showing you on “video” tested with the info on the secure note there is no firewall in between, check carefully, it seems that you don´t wanna help, if you don´t know how to fix the problem please find someone else who can this is taking too much time.

Hi there,

Yes, I said I did it like how you did it on the video, but I still can’t connect.

Plus, I prefer working with FTP as it’s just much faster than using a file manager, but I don’t have a choice since I can’t get in.

Your translation is okay now, your translation files are incorrect. You added it like this,

pro-es_ES.mo pro-es_ES.po

which should be like this

__x__-es_ES.mo __x__-es_ES.po

The __x__ is the textdomain and not pro. The theme is just named pro, but the textdomain is still __x__

They are under, public_html/staging/wp-content/languages/themes

Thanks!

Hi, I need to make ir work with child theme not parent theme I don not Wanna lose my translations on a theme Update, please help.

Hi there,

It will not be overwritten and it will stay there after the update. This public_html/staging/wp-content/languages/themes is not part of
parent theme.

public_html/staging/wp-content/languages/ this is a language folder
public_html/staging/wp-content/themes/ this is theme folder

And they are both different.

Thanks!

@Rad

So why do offer the Child theme option on function.php related on this page if it is not going to work, update or remove that page because it made lose a lot of time.

Hi there,

There are many ways to do it, and you did some of them. The one that I fixed is the last step that you did under /public_html/wp-content/languages/themes/. And since you just don’t want it to be overwritten, I just said that it’s okay under /public_html/wp-content/languages/themes/ since it’s not connected to updates.

If you really wish to do it in your child theme, then please remove those translation files that are added outside your child theme (eg. /public_html/wp-content/languages/). This way, I can test it and see if it’s really working or not, because if you don’t remove them then Wordpress will still pick the translation files from that folder. Hence, troubleshooting the child theme is no use at all. I don’t want to remove them myself and please backup your site.

Plus, the child theme code should be like this

load_child_theme_textdomain( '__x__', get_stylesheet_directory() . '/lang' );

Thanks!