• Resolved 1RONMAN_C

    (@1ronman_c)


    Hi everyone!
    I really-really need your help.
    I am using wordpress theme called Avenue, this theme is from web2feel.
    It’s a real estate theme and it has listing in it. I want to translate this listing. But Polylang don’t see the strings that I need to translate. Therefore I need to add them manually but I can’t understand how I should do it. There is a file listhome.php, which contain all of them. Looks like this:

    <div class="propmeta">
    	<div class="proplist"><span>Price</span> <span class="propval"> <?php $price=get_post_meta($post->ID, 'wtf_price', true); echo $price; ?></span></div>
    	<div class="proplist"><span>Bedrooms</span> <span class="propval"> <?php echo get_the_term_list( $post->ID, 'bedrooms', '', ' ', '' ); ?></span></div>
    	<div class="proplist"><span>View</span> <span class="propval"><?php echo get_the_term_list( $post->ID, 'property', '', ' ', '' ); ?></span></div>
    	<div class="proplist"><span>Area</span> <span class="propval"> <?php echo get_the_term_list( $post->ID, 'area', '', ' ', '' ); ?></span></div>
    	</div>

    I need to be able to translate the words “Price”, “Bedrooms”, “View” and “Area”.
    Please explain me, how can I add them to make it possible to translate them with a help of Polylang?
    Thanks in advance and sorry if my english is too bad.

Viewing 15 replies - 1 through 15 (of 17 total)
  • Thread Starter 1RONMAN_C

    (@1ronman_c)

    Thank you for your reply! Well, I don’t know if theme is translation ready or not, but i can translate all other things (e.g. Widget titles, Menu items, etc.) except this strings, that I showed here in code. So to add them I must do something with theme before that?

    Thread Starter 1RONMAN_C

    (@1ronman_c)

    Well, I followed the link and read everything there, but I still don’t understand..:(
    Can you please show me an example for one of the strings that I have below in the code?

    Thread Starter 1RONMAN_C

    (@1ronman_c)

    And also I almost forgot to say that all the taxonomy that I can add for this listing (e.g. Variants of Area, Views, etc.) translated perfectly. The only thing that I can’t translate is this titles. I just can’t understand how it should look in code, how I should add or what I should do with them before to make them translatable.. I’m just stuck for now.:(
    I already translated the search form which uses them , just added php code to the templates and made two separate pages and everything works, but when I search something I get results with this titles which are not translated.:(
    Please, somebody, help me!:(

    If you followed the links you should have read code examples.

    Thread Starter 1RONMAN_C

    (@1ronman_c)

    Yes, but I don’t understand how it should look in my case. For example this line of code:
    <div class="proplist"><span>Price</span> <span class="propval"> <?php $price=get_post_meta($post->ID, 'wtf_price', true); echo $price; ?></span></div>
    How it should look?
    Something like:
    <div class="proplist"><span><?php _e('Price','my-text-domain'); ?></span> <span class="propval"> <?php $price=get_post_meta($post->ID, 'wtf_price', true); echo $price; ?></span></div>
    Am I right? If not, where is my mistake?

    Thread Starter 1RONMAN_C

    (@1ronman_c)

    And one more question: ‘my-text-domain’ should be just main website address, or exact page?

    Thread Starter 1RONMAN_C

    (@1ronman_c)

    I was wrong about my-text-domain. I wasn’t read everything. So, as I understand, I should add it to the plugin header, but what I should do if it’s not a plugin?

    Thread Starter 1RONMAN_C

    (@1ronman_c)

    Should I just add something like:
    /*
    * Text Domain: whatever
    */
    At the top of the file where I got my strings?

    Thread Starter 1RONMAN_C

    (@1ronman_c)

    I’ve tried to add the Text Domain to this file (listhome.php).
    But nothing happened. I don’t see any new strings in polylang. What else should I do to make it happen?
    Please help me to resolve this issue.

    [Moderator Note: No bumping. If it’s that urgent, consider hiring someone.]

    Thread Starter 1RONMAN_C

    (@1ronman_c)

    Looks like it is just too hard for me. And nobody is going to explain. But nobody have to, It’s just my own problem, I know.
    So, let’s pretend that it’s resolved though. I’ll try some other way.

    <div class="proplist"><span><?php _e('Price','my-text-domain'); ?></span> <span class="propval"> <?php $price=get_post_meta($post->ID, 'wtf_price', true); echo $price; ?></span></div>

    That’s correct.

    And one more question: ‘my-text-domain’ should be just main website address, or exact page?

    It’s whatever you want, but generally we use the same name as the theme or the plugin directory

    Should I just add something like:
    /*
    * Text Domain: whatever
    */

    That’s not the important part. the most important part is to declare the text domain with the function load_theme_textdomain as described in the this part of the codex.
    And finally you will have to create your po/mo files to translate the string (the plugin Codestyling localization is great help for doing this).

    And nobody is going to explain.

    That’s free help on a forum. You need to be patient. Sometimes you don’t even get help because there’s so much questions that volunteers just cannot answer to everybody.

    Thread Starter 1RONMAN_C

    (@1ronman_c)

    Chouby, you are the man!:) You are great!) Thank you very much! I know that that there are so many questions, but I just thought that my questions are too stupid or something like so.. ??

    But main thing that I wasn’t said and wasn’t asked and wanted to know is how to make this strings available in Polylang, how to use pll_register_string.. I need an example, because I’ve read everything and didn’t understand how to use it properly in my case. ??
    Because I have many languages on the website and all I wanted to do is to make this strings availiable just to make it possible to show them differently in many languages, everything else is already translated with polylang.. All taxonomy, even custom taxonomy from listing, etc.
    So I just wanted to add this 4 words and then translate them in Polylang..
    I made another post with this question, because I thought that it will be better for everyone who will need to know it later. It has no replies yet. If it’s possible – can you, please, give me an example there, in my other topic?
    Here’s the link to it: link

    If you want to do this with the Polylang string translation feature, that’s a bit different. The doc is here.
    use

    pll_e('Price');

    instead of

    _e('Price','my-text-domain')

    to do the translation on frontend

    And to put the strings in the translation table on admin, write that somewhere in your functions.php:

    pll_register_string('just a name for my string', 'Price');

    However, that code breaks wehn Polylang is de-activated (so for example during the upgrade). So it is better to write:

    if (function_exists('pll_register_string')) {
      pll_register_string('just a name for my string', 'Price');
    }

    and

    if (function_exists('pll_e')) {
      pll_e('Price');
    else {
     echo 'Price';
    }

    Thread Starter 1RONMAN_C

    (@1ronman_c)

    Chouby, I’m so happy that there are people like you on this website! Thank you so much! You are awesome person!

    Now it’s all clear, I finally understood how to do it! Thank you for explaining about better code which works when Polylang deactivated and thank you for spending your time to help me!
    I really appreciate that!

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Polylang&Avenue theme from web2feel – Listing translation’ is closed to new replies.