Polylang not translating certain static elements

Hello! I’m working on a wordpress site for my employers blog and we’re having some issues with the Sparkling theme / Polylang, it appears there are some (static) elements missing translations.

The live site can be viewed at the following address: http://chargehub.com/blog/

The problems are strings such as “Search”, “Read More” etc. We are unable to change these to the desired second language (french in this case), and were wondering if you can please provide some guidance and support on the matter.

I’ve remarked that we’re using the most recent version of the Theme (2.2.2) and the most recent version of PolyLang / Wordpress as well.

Thanks in advance, I eagerly await your response.

CCoffin

Hi @CCoffin,

I hope you are well today and thank you for your question.

Please try regenerating fresh version of language po file and then generate mo file using this new po file.

Find more information about this on the following page.

Best Regards,
Movin

Hello Movin! Thanks for the response, much appreciated.

I’m afraid I don’t know how to generate a fresh version of the language, and I don’t really understand the instructions in the blog post you referenced. Could you possibly give me a more hands-on explanation?

I’ve followed the blog post, and not only did it not work for me, but it broke the translation on the nav menu in the process…

Please advise.

Thanks

Hi @CCoffin,

See the information provided on the below pages to create fresh version of language po file and then generate mo file.

https://codex.wordpress.org/User:Skippy/Creating_POT_Files

http://betterwp.net/wordpress-tips/create-pot-file-using-poedit/

Alternatively you can try achieving this by using the attached small plugin specially developed for you that contains the following custom code .

function colorlib_change_translate_text( $translations, $text, $context, $domain ) {
	if (strpos($text,'Read More') !== false) {
            $text = str_replace("Read More","Lire la suite", $text);
        } else if (strpos($text,'Search') !== false) {
            $text = str_replace("Search","Chercher", $text);
        }

	return $text;
}
add_filter( 'gettext_with_context', 'colorlib_change_translate_text', 99, 4 );

function colorlib_change_translate_text2( $translated_text, $text, $domain ) {
	if (strpos($translated_text,'Read More') !== false) {
            $translated_text = str_replace("Read More","Lire la suite", $translated_text);
        } else if (strpos($translated_text,'Search') !== false) {
            $translated_text = str_replace("Search","Chercher", $translated_text);
        }

	return $translated_text;
}
add_filter( 'gettext', 'colorlib_change_translate_text2', 99, 4 );

You can just add more else if conditions in the above plugin code to translate more untranslated text.

Best Regards,
Movin

Hello Movin! Thanks again for the response. However, I do not see an option for “new catalog” in the file menu… Am I missing something ?

Also, the rest of the walkthrough is extremely confusing and rather vague, I can’t really make sense of it.

I will certainly try this plugin right now, but ideally, I’d like to have as few plugins as possible, and just get the translation working as it should on its own.

Hello Movin! Thanks again for the response. However, I do not see an option for “new catalog” in the file menu…. Am I missing something ?

It seems from your shared screenshot that you are using apple OS so the poedit options may be different for it. You should try clicking on New… option instead.

Thanks for the lightning fast response. :stuck_out_tongue:

Ok, but then it simply outputs this, which is still unlike it says in the guide!

OK, I used the 'new from POT / PO, and downloaded the Sparkling theme translation, translated everything to french, saved it as fr_FR.po (which generated a corresponding .mo file), I then replaced the ones in the theme, and it’s still not working as expected… This is becoming rather discouraging :frowning:

Any further support would be greatly appreciated.

translated everything to french, saved it as fr_FR.po (which generated a corresponding .mo file), I then replaced the ones in the theme, and it’s still not working as expected…. This is becoming rather discouraging

What are not working for you?

Only the strings like “Search”, “Read More or anymore?

Could you please share me the fr_FR.po and fr_FR.mo file that you are using?

For now you can also use the small plugin that i have shared previously. The plugin will not slow down your site as it contains small code and uses the WordPress default hooks that WordPress uses to translate strings.

Thanks for the follow-up Movin! Here are the translated and generated .mo and .po files, these ones break the existing translation on the (nav) menu, and widget sidebar!

Also the following is not translated:

“Your email address”
“Subscribe”

I don’t mind using the plugin, as you’re correct in saying it’s very lightweight! However I’m not super familiar with JS and cannot add other strings to translate, without breaking the other ones! If you could either help me figure out why the theme is missing some translations, or instruct me on how to add additional lines to the plugin (without breaking anything), it would be greatly appreciate!

Thanks in advance, Movin.

I appreciate your support greatly.

Cheers

CCoffin

Oh, I just noticed it would not let me upload the language files, so I’ll zip them and submit once more!

Thanks for sharing the files and it seems you have translated the “Search”, “Read More” strings correctly so it should be translated on your site. Please make your site to translate in french language so that i can test it.

Would you mind if i log in to your site and do some troubleshooting? If this is ok then could you please share me your site log in details privately by checking the option “Set as private reply” when replying to this topic?

Also the following is not translated: https://www.dropbox.com/s/k4o4tkm64948xna/Screenshot%202016-04-11%2009.54.27.png?dl=0 “Your email address” “Subscribe”

These strings are displayed by mailchimp-for-wp plugin and not by this theme so you have to translate that plugin to change these strings.

I don’t mind using the plugin, as you’re correct in saying it’s very lightweight! However I’m not super familiar with JS and cannot add other strings to translate, without breaking the other ones! If you could either help me figure out why the theme is missing some translations, or instruct me on how to add additional lines to the plugin (without breaking anything), it would be greatly appreciate!

Here’s the following updated code that contains additional strings :

function colorlib_change_translate_text( $translations, $text, $context, $domain ) {
	if (strpos($text,'Read More') !== false) {
            $text = str_replace("Read More","Lire la suite", $text);
        } else if (strpos($text,'Search') !== false) {
            $text = str_replace("Search","Chercher", $text);
        }else if (strpos($text,'Your email address') !== false) {
            $text = str_replace("Your email address","Votre adresse email", $text);
        }else if (strpos($text,'Subscribe') !== false) {
            $text = str_replace("Subscribe","Souscrire", $text);
        }

	return $text;
}
add_filter( 'gettext_with_context', 'colorlib_change_translate_text', 99, 4 );

function colorlib_change_translate_text2( $translated_text, $text, $domain ) {
	if (strpos($translated_text,'Read More') !== false) {
            $translated_text = str_replace("Read More","Lire la suite", $translated_text);
        } else if (strpos($translated_text,'Search') !== false) {
            $translated_text = str_replace("Search","Chercher", $translated_text);
        }else if (strpos($translated_text,'Your email address') !== false) {
            $translated_text = str_replace("Your email address","Votre adresse email", $translated_text);
        }else if (strpos($translated_text,'Subscribe') !== false) {
            $translated_text = str_replace("Subscribe","Souscrire", $translated_text);
        }

	return $translated_text;
}
add_filter( 'gettext', 'colorlib_change_translate_text2', 99, 4 );

Hey Movin! So I tried the additional code for the plugin, but it seems to not work so well… The text “Search” is stuck as “Chercher…” no matter what language, and the “Email address” and “Subscribe” stay english in both languages.

However, the text “read more” does translate properly! Which is nice :stuck_out_tongue:

Anyways, I would greatly appreciate some hands-on support with this, so here are the credentials for the admin login.

user: chargehubadmin
pass: 0ykD$ZR256Wc&KKmhI

Thanks in advance!