WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] add string translation to vulcan theme (13 posts)

  1. Marshall1980
    Member
    Posted 2 years ago #

    Hey there,

    im getting really mad right now. Sorry for disturbing you with my (maybe) noob question:

    I´d purchased the vulcan theme for wordpress and im using polylang to switch in 3 languages. All the translation for navigation, category and article translation is fine!
    The handling: fine! Bascily that plugin reaaally does a great job!

    But im stuck in the translation on the 3 static elements (the 3 boxes under the slider)
    http://themeforest.net/item/vulcan-minimalist-business-wordpress-theme-4/111625

    I know, that is not really a part of the plugin.

    I´d read a lot of different articles about that "how to add additional strings" issues thing. Im not a programmer, but i can read code and replace it. im scared of broke the code...

    So, would you so nice and provide me the most shortest solution i´d ever read?

    You would save my day!

    thank you so much

    Marcel

    http://wordpress.org/extend/plugins/polylang/

  2. Marshall1980
    Member
    Posted 2 years ago #

    As other Feedback, i can confirm that polylang works great on the theme above. without any problems. navigation is easy and translation progress logic...

    The only problem ist to translate static elements.

    I found a frontpage.php and i think there are the strings i need

    <h4>"><?php echo ($homebox_title1) ? stripslashes($homebox_title1) : "Construct a Future";?></h4> is one of them.

    so please can you provide me how to translate these 3 with polylang?

    have a great day!

    thanks

    Marcel

  3. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    It's always hard to help with commercial themes, without beeing able to read the code. Mainly there are two actions to do:

    On the admin side, find the string in the code and register it with the function pll_register_string. Thus your string will appear in the string translations panel of Polylang and you will be able to enter translated strings.

    On the frontend side, it seems that you already found the code. You just have to replace it by:
    <h4>"><?php echo ($homebox_title1) ? stripslashes(pll__($homebox_title1)) : "Construct a Future";?></h4>
    This will replace the original string by the translated one.

  4. Marshall1980
    Member
    Posted 2 years ago #

    Thanks!

    That worked partly.

    Now i have one string i´d chosen in my polylang admin panel. Great!

    But if i press "save" nothing happened. After pressing save, all entrys in the fields are gone..

    on any language site is still the original language.

    But site and code seems ok.

    any ideas?

    thanks Marcel

    P.S.

    Can you provide me once again the exact name of the .php file, where to insert the pll register function? thanks again :)

  5. Marshall1980
    Member
    Posted 2 years ago #

    And is it possible, that polylang remove the "register pll" line after saving and includes it to code?

    because i cant find my register line anymore

    thanks!

  6. Marshall1980
    Member
    Posted 2 years ago #

    I can provide code if you need it!

  7. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    I don't know the file you have to modify since I don't know the theme. If your strings are stored as options, you may just have to filter the corresponding option.

    I just made an example with another theme without modifying the theme itself. It may help you.

    http://wordpress.org/support/topic/add-custom-string-translation-on-polylang-working-with-responsive-theme

  8. Marshall1980
    Member
    Posted 2 years ago #

    Hey Chouby,

    i wrote you an E-Mail. Pls check site and code there if this can help.

    thank you so much for your support

    Marcel

  9. Marshall1980
    Member
    Posted 2 years ago #

    Ok, im a step forward now.

    Add "pll_register_string('homebox_title1', $homebox_title1);" to the bottom of functions.php (in theme folder) did the registry of the string good! It appears now in Polylang string translation menue...Good!

    On the theme side, i think the code of the theme is the problem:

    <h4>"><?php echo pll__($homebox_title1) ? stripslashes ($homebox_title1): "Construct a Future";?></h4>

    I removed all between the <h4> tags and just tried: <?php echo pll__($homebox_title1);?>

    Important: Dont type any information in the boxes fields at the theme admin panel, that depends on this field!

    Next problem, as i said before:

    I typed my translations into the polylang string trans admin panel and pressed save.
    But nothing happened and the fields get blank again. Code and Site seems well.

    I think the problem must be in storage the register p__ attributes.

    Any ideas?

    Marcel

    P.S. After we will get this soluted, i will write a complete "how to" about this issue on the vulcan theme. maybe others can use it too

  10. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    You should not get blank fields, not even before translation. They should be initially filled with the original string.

    Did you enter some string in the admin of the theme ? Otherwise Polylang is unable to know what to translate. Seen as the code provided above, the default string, if you enter nothing, is hardcoded in the theme and so Polylang cannot know about it.

  11. Marshall1980
    Member
    Posted 2 years ago #

    yes, i tried both.

    the theme comes original with blank fields...than appears blind text

    if i enter text, my text appears

    but i think the problem is somewhere else.

    one the other hand it could be, that i made something wrong.

    should i provide you more infos or code?

  12. Marshall1980
    Member
    Posted 2 years ago #

    Problem solved by myself!

    Im shure it will work for other themes too. Maybe you´ll find a way to include it into next version such a (get_option)-function scanner to get all possible translateable strings :-)

    Short Manual (relating to my other posts above):

    1. Just search for strings in your theme-files you wanna have to translated.
    For me, i found most in frontbox.php

    <div id="front-box">
                	<?php
                	 $homebox_title1 = get_option('vulcan_homebox_title1');
                	 $homebox_desc1 = get_option('vulcan_homebox_desc1');
                	 $homebox_image1 = get_option('vulcan_homebox_image1');
                	 $homebox_desturl1 = get_option('vulcan_homebox_desturl1');
                	 $homebox_title2 = get_option('vulcan_homebox_title2');
                	 $homebox_desc2 = get_option('vulcan_homebox_desc2');
                	 $homebox_image2 = get_option('vulcan_homebox_image2');
                	 $homebox_desturl2 = get_option('vulcan_homebox_desturl2');
                	 $homebox_title3 = get_option('vulcan_homebox_title3');
                	 $homebox_desc3 = get_option('vulcan_homebox_desc3');
                	 $homebox_image3 = get_option('vulcan_homebox_image3');
                	 $homebox_desturl3 = get_option('vulcan_homebox_desturl3');
                	?>

    2. Register any string you want at the bottom of functions.php (NOT theme-functions.php) after this line

    add_action('admin_menu', 'optionsframework_add_admin');

    pll_register_string('homebox_descritption1_text', get_option('vulcan_homebox_title1'));

    Most important here is the

    get_option
    function.

    The code did the job well and gaves me a new field in the polylang admin panel.

    3. Now go to the line, where the string got an

    echo
    parameter. For my example its frontbox.php again

    As i said before, you can remove the whole bla bla stringslash bla bla line
    <h4>"><?php echo pll__($homebox_title1) ? stripslashes ($homebox_title1): "Construct a Future";?></h4>

    I just changed it into
    <h4><?php echo pll__(get_option('vulcan_homebox_title1'));?></h4>

    That works great!!!

    I think the "get_option" parameter is very important. Without, it will not work.

    Rgds
    Marcel

  13. Marshall1980
    Member
    Posted 2 years ago #

    resolved

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags