Support » Theme: Zerif Lite » Polylang strings in front-page.php

  • Resolved coralepuccini

    (@coralepuccini)


    Hi, I’ve installed the plugin polylang and I was able to translate 90% of homepage strings. I don’t find the way to translate the main title of sections. I noticed that subtitle and content of section just are displayed on admin menรน polylang and they are able to be translated, but main title is not recognized.The code of main title section in fron-page.php is this:

    <?php $zerif_contactus_title = get_theme_mod(‘zerif_contactus_title’,’Get in touch’);
    if ( !empty($zerif_contactus_title) ):
    echo ‘<h2 class=”white-text”>’.$zerif_contactus_title.'</h2>’;
    endif;
    $zerif_contactus_subtitle = get_theme_mod(‘zerif_contactus_subtitle’);
    if(isset($zerif_contactus_subtitle) && $zerif_contactus_subtitle != “”):
    echo ‘<h6 class=”white-text”>’.$zerif_contactus_subtitle.'</h6>’;
    endif;
    ?>
    </div>

    I create a translation string with pll_register_string for zerif_contactus_title in functions.php of theme, but when I add pll_e to echo codex the $zerif_contactus_title seems doesn’t work.

    This is the function:

    pll_register_string(‘contacts’, ‘$zerif_contactus_title’, ‘zerif-lite’);

    Any ideas?

Viewing 15 replies - 1 through 15 (of 17 total)
  • Hardeep Asrani

    (@hardeepasrani)

    Support Team Volunteer

    Hi,

    You can change titles from Appearance > Customizer section, you don’t need to use a plugin for that part. ๐Ÿ™‚

    Regards,
    Hardeep

    Hi, thanks for your fast answer, but I use polylang and on customizer I can only add text in one language. For example Contact section is customizable and default language is Italian. How I can add translation in English language?

    Maybe I wrote the question in a bad way :).
    On customizer section I can change the text but I need to translate it in English language. I use plugin polylang that use string translation but I don’t find the way to translate, as I posted above, the $string “$zerif_contactus_title”. The others fields I was able to do but this one nothing

    I appreciate help.

    Thanks very much

    MariusG

    (@marius_codeinwp)

    ThemeIsle Support

    Hello,

    Are you having troubles with translating the Contact Us section only? Or are there any other sections as well?
    I have not worked with Polylang before, but I’ll look into it and be back with an answer ๐Ÿ™‚

    Kind regards,
    Marius

    Hi! We have the same problem: translations are defined but Main Titles remain in the original language (the first language in which the site has been created). The rest appears in the correct language.

    In addition, as the menu custom settings should link to the site sections via URLs set as http://sitename.com/#focus or #aboutus, #team, etc, how do we link the menus according to the languages? In our case we have 2 menus (English, Spanish): both menus link to the same section of one specific language (in our case: English) since the URL is the same. But are we able to change it to e.g. #focus1, #aboutus1 and do any specific change in any of the php files so that it links to the specific section in the correct language?

    Thanks!

    Hi, I resolved the problem: follow exactly the steps below:

    Open function.php in theme root and add at the end of lines these strings:

    // About us translation
    pll_register_string(‘About Us’,’zerif_aboutus_title’,’zerif-lite’);
    // Our focus translation
    pll_register_string(‘Our focus’,’zerif_ourfocus_title’,’zerif-lite’);
    // Contact us translation
    pll_register_string(‘zerif_contactus_title’,’Get in touch’,’zerif-lite’);
    // Latest news translation
    pll_register_string(‘Latest news’,’zerif_latestnews_title’,’zerif-lite’);
    // Testimonials translation
    pll_register_string(‘Testimonials’,’zerif_testimonials_title’,’zerif-lite’);
    // Our team translation
    pll_register_string(‘Our Team’,’zerif_ourteam_title’,’zerif-lite’);

    Go to Polylang main menรน and make the necessary translation you need.

    After open each php file section in the sections folder and replace the follow line with this:

    Old line
    if( !empty($zerif_aboutus_title) ):
    echo ‘<h2 class=”white-text”>’.__($zerif_aboutus_title,’zerif-lite’).'</h2>’;
    endif;
    ?>

    New line
    if( !empty($zerif_aboutus_title) ):
    echo ‘<h2 class=”white-text”>’.pll__(‘zerif_aboutus_title’,’zerif-lite’).'</h2>’;
    endif;
    ?>

    Follow the above steps to each php section page replacing the $variable after class text into correct name without $.

    On contact us open front page.php and replace this line:

    $zerif_contactus_title = get_theme_mod(‘zerif_contactus_title’,’Get in touch’);
    if ( !empty($zerif_contactus_title) ):
    echo ‘<h2 class=”white-text”>’.$zerif_contactus_title.'</h2>’;
    endif;

    with this:

    $zerif_contactus_title = get_theme_mod(‘zerif_contactus_title’,’Get in touch’);
    if ( !empty($zerif_contactus_title) ):
    echo ‘<h2 class=”white-text”>’.pll__(‘zerif_contactus_title’).'</h2>’;
    endif;

    IT WORKS ๐Ÿ™‚

    Look the site: http://www.mariojannitti.com ๐Ÿ™‚

    Hi,

    How could I get the subtitles to be translatable? I did this with the titles and it worked, but when I tried the same thing for subtitles or the red/green big title buttons, it doesn’t do anything.

    also all the links on the front page take me to the default language pages. How can I put different links into the buttons?

    Is there another way than the plugin polylang?

    I have the plugin qtranslate for english/french and it works on all my pages.
    But I also want to have 2 languages on the homepage (Big title, about us, contact us…)

    Can someone help me please?

    Alexandra

    (@alexandrastan001)

    ThemeIsle Support

    Hello.

    We have read your request and someone will answer your question as soon as possible.
    Thank you for your patience!

    Best regards,
    Alexandra

    MariusG

    (@marius_codeinwp)

    ThemeIsle Support

    Hello,

    Sorry for the late answer, I believe we managed to find the issue and we’re working on the fix.

    There were indeed some strings missing from wpml-config.xml
    If it helps, you can manually add strings to that file.

    Best regards,
    Marius

    the issue still exists, not all strings are picked up. and above solutions adding it to function.php actually breaks up installation with this message:

    Fatal error: Cannot redeclare zerif_setup() (previously declared in /home/***********/public_html/wp-content/themes/zerif-lite-child/functions.php:27) in /home/***********/public_html/wp-content/themes/zerif-lite/functions.php on line 151

    At moment no title and subtitle of sections is picked up for translation, widgets works as expected.

    any solution at it?

    MariusG

    (@marius_codeinwp)

    ThemeIsle Support

    Hello,

    Sorry for the inconvenience, I thought we managed to fix this. It seems not all missing elements have been fixed, we will further debug this.

    Unfortunately I don’t have a working solution at the moment.

    Best regards,
    Marius

    Hello!

    Did anybody succeed to resolve this translation issue?

    thanks!
    Kata

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Polylang strings in front-page.php’ is closed to new replies.