nicolasgs
Forum Replies Created
-
Forum: Plugins
In reply to: [Polylang] Problem translating site header and subheader with Hueman themeI managed to resolve the issue. The answer is here:
https://wordpress.org/support/topic/cant-translate-the-blog-heading-and-sub-heading-in-multilaguage-site?replies=7#post-8374893The topic is marked as resolved.
OK, I managed to resolve the issue.
It wasn’t that bad, after all. I received no answer at Polylang forum, but bdbrown’s code for functions.php was a great help.So, I added his code to functions.php:
function hu_blog_title() { $heading = __('All about mobile gadgets', 'hueman'); $heading = $heading ? $heading : get_bloginfo('name'); $subheading = __('Text and video reviews, news, coupons, discounts and more', 'hueman'); $subheading = $subheading ? $subheading : __('Blog', 'hueman'); return sprintf('%1$s <span class="hu-blog-subheading">%2$s</span>', $heading, $subheading ); }Where “All about mobile gadgets” is header and “Text and video reviews, news, coupons, discounts and more” is subheader.
Then I registered 2 strings for Polylang in functions.php again, for Header and Sub-header:
pll_register_string('hu_blog_title', 'All about mobile gadgets', 'hueman'); pll_register_string('hu-blog-subheading', 'Text and video reviews, news, coupons, discounts and more', 'hueman');After doing this, I was able to translate the header and sub-header in admin console -> Settings -> Languages -> Strings translations
No changes on site till I did the following with the code above in functions.php of my child theme:function hu_blog_title() { $heading = pll__('All about mobile gadgets', 'hueman'); $heading = $heading ? $heading : get_bloginfo('name'); $subheading = pll__('Text and video reviews, news, coupons, discounts and more', 'hueman'); $subheading = $subheading ? $subheading : __('Blog', 'hueman'); return sprintf('%1$s <span class="hu-blog-subheading">%2$s</span>', $heading, $subheading ); }I just added “pll” before the code of header and sub-header, and it worked. You may check the result at http://androidtablets.com.ua
bdbrown, thanks again for help.
The topic is marked as resolved.
Hi bdbrown. Thank you again for your help.
Your method works in terms of Hueman takes Header and Sub-header text directly from functions.php of child theme. Xili language now detects these stings and allows to translate them, but the translation on site will possible work only if using Xili language plugin for multilingual site, while I’m using Polylang. The other plugins still can’t see the header and sub-header.
I’ve found this topic about adding the custom strings to Polylang:
https://wordpress.org/support/topic/add-any-strings-to-strings-translation-tab?replies=6
I’ve managed to manually add my header and sub-header texts, and I can translate them in Polylang now, but I can’t get how to implement this function correctly and if it is possible at all. The text just appears at the top of page, translated for each language.
Maybe I should ask the Polylang community to help me.
Thank you again.Hi bdbrown. Thank you for answer.
I’ve set the heading of the blog in Customize > Content > Blog Design > Blog Heading, and it is displayed correctly. The problem is, this text is not stored as a string anywhere, so it can’t be translated with any multilingual plugin. It is also not stored in *.po language files. init-front.php only includes function to call for Blog Heading, but not the text itself.
So the question was, is there any way to find and translate the Heading to different languages on multilingual site, or I should wait for a theme update?
Thanks again.