Where do I translate the Listing Category Title?

I am translating the Directory (with poedit) and I am almost finished, but I can not find where to translate the heading of the page "Listing Category:" (for instance here http://www.cechmajstrov.sk/listings-category/autoservis-pneuservis-autoelektrika-diagnostika-klampiarske-prace/) and "1 response to" (here- http://www.cechmajstrov.sk/listing/villard-zdruzenie-pre-restaurovanie-a-obnovu-pamiatok-v-o-s/).

I have already checked all these files with no luck

/directory/languages/dr_text_domain.po

/directory/themes/default/languages/directory-default.po

/directory/core/custompress/languages/custompress.po

Could you help me ?

  • Adam Czajczyk

    Hey Monika,

    I hope you're having a great day and thank you for your question!

    The "Listing Category" string is located in "/directory/languages/dr_text_domain.po" file about the line number 433.

    The "1 response to" message issue seems to be theme related as it's produced by core WP comment system. On my test setup changing the theme to one that fully supports translation and changing WP language settings works for this one.

    I hope that helped!

    Cheers,
    Adam

  • Monika

    Hi Adam,
    thank you for a quick answer. As I wrote I checked the "/directory/languages/dr_text_domain.po" file and I had found the "Listing Category" string ( haven't had it on the line 433) , but although I had put translation there the title haven't changed on my page. I did it a few days ago, so it isn't the memory issue.

    And unfortunately a similar problem with the translation of ''1 response''. I have theme studio, went into wp-content/themes/studio/languages but couldn't find anything. Strange, everything else, which I needed I have translated.

  • Ash

    Hello @Monika

    I hope you are well today.

    It seems we are dealing with a weird bug here, I am letting the developer know. But for now, you can use the following code:

    add_filter( 'the_title', 'page_title_output', 99 , 2 );
    function page_title_output($title, $id = false) {
    	global $wp_query, $post;
    
                //filter out nav titles
                if (!is_object($post) || ($post->ID != $id))
                    return $title;
    
                //taxonomy pages
                $tax_key = (empty($wp_query->query_vars['taxonomy'])) ? '' : $wp_query->query_vars['taxonomy'];
    
                $taxonomies = get_object_taxonomies('directory_listing', 'objects');
                if (array_key_exists($tax_key, $taxonomies)) {
                    $term = get_term_by('slug', get_query_var($tax_key), $tax_key);
                    return "TRANSLATED VERSION OF LISTING CATEGORY" . ': ' . $term->name;
                }
    
                //title for listings page
                if (is_post_type_archive('directory_listing')) {
                    return post_type_archive_title('', false);
                }
                return $title;
    }

    You just need to replace TRANSLATED VERSION OF LISTING CATEGORY with your translated text.

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Monika

    Hi Ash,
    There has been an update today, so I hoped that it improved the translation, but nothing changed.
    With the code you sent me- I believe I did what you ask me- I went to /wp-content/ and found the folder with name 'mu-plugins'. created a file inside that, gave it the name preklad.php and pasted the code in there. But instead of translation I have seen this code on the website:
    add_filter( 'the_title', 'page_title_output', 99 , 2 ); function page_title_output($title, $id = false) { global $wp_query, $post; //filter out nav titles if (!is_object($post) || ($post->ID != $id)) return $title; //taxonomy pages $tax_key = (empty($wp_query->query_vars['taxonomy'])) ? '' : $wp_query->query_vars['taxonomy']; $taxonomies = get_object_taxonomies('directory_listing', 'objects'); if (array_key_exists($tax_key, $taxonomies)) { $term = get_term_by('slug', get_query_var($tax_key), $tax_key); return "preklad" . ': ' . $term->name; } //title for listings page if (is_post_type_archive('directory_listing')) { return post_type_archive_title('', false); } return $title; }
    Warning: Cannot modify header information - headers already sent by (output started at /home1/monika/public_html/cechmajstrov.sk/wp-content/mu-plugins/preklad.php:23) in /home1/monika/public_html/cechmajstrov.sk/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 62.

    Did I do something wrong?

  • Ash

    Hello @Monika

    I hope you are well today.

    I think you have missed php start tag. The code with start tag will be:

    <?php
    add_filter( 'the_title', 'page_title_output', 99 , 2 );
    function page_title_output($title, $id = false) {
    	global $wp_query, $post;
    
                //filter out nav titles
                if (!is_object($post) || ($post->ID != $id))
                    return $title;
    
                //taxonomy pages
                $tax_key = (empty($wp_query->query_vars['taxonomy'])) ? '' : $wp_query->query_vars['taxonomy'];
    
                $taxonomies = get_object_taxonomies('directory_listing', 'objects');
                if (array_key_exists($tax_key, $taxonomies)) {
                    $term = get_term_by('slug', get_query_var($tax_key), $tax_key);
                    return "TRANSLATED VERSION OF LISTING CATEGORY" . ': ' . $term->name;
                }
    
                //title for listings page
                if (is_post_type_archive('directory_listing')) {
                    return post_type_archive_title('', false);
                }
                return $title;
    }

    Let me know if that works as mu-plugins.

    Cheers
    Ash

  • Vinod Dalvi

    Hi @Monika,

    Could you please try using the following code the same way that you have used previously provided code.

    <?php
    add_filter( 'the_title', 'page_title_output', 99 , 2 );
    function page_title_output($title, $id = false) {
    	global $wp_query, $post;
    
                //filter out nav titles
                if (!is_object($post) || ($post->ID != $id)  || strpos($title,'Listing Category:') === false )
                    return $title;
    
                //taxonomy pages
                $tax_key = (empty($wp_query->query_vars['taxonomy'])) ? '' : $wp_query->query_vars['taxonomy'];
    
                $taxonomies = get_object_taxonomies('directory_listing', 'objects');
                if (array_key_exists($tax_key, $taxonomies)) {
                    $term = get_term_by('slug', get_query_var($tax_key), $tax_key);
                    return "TRANSLATED VERSION OF LISTING CATEGORY" . ': ' . $term->name;
                }
    
                //title for listings page
                if (is_post_type_archive('directory_listing')) {
                    return post_type_archive_title('', false);
                }
                return $title;
    }

    Best Regards,
    Vinod Dalvi

  • Ash

    Hello @Monika

    In that case, try the following:

    add_filter( 'the_title', 'page_title_output', 99 , 2 );
    function page_title_output($title, $id = false) {
    	global $wp_query, $post;
    
                //filter out nav titles
                if (!is_object($post) || ($post->ID != $id)  || strpos($title,'Listing Category:') === false )
                    return 'CUSTOM TITLE FOR LISTING PAGE';
    
                //taxonomy pages
                $tax_key = (empty($wp_query->query_vars['taxonomy'])) ? '' : $wp_query->query_vars['taxonomy'];
    
                $taxonomies = get_object_taxonomies('directory_listing', 'objects');
                if (array_key_exists($tax_key, $taxonomies)) {
                    $term = get_term_by('slug', get_query_var($tax_key), $tax_key);
                    return "TRANSLATED VERSION OF LISTING CATEGORY" . ': ' . $term->name;
                }
    
                //title for listings page
                if (is_post_type_archive('directory_listing')) {
                    return post_type_archive_title('', false);
                }
                return $title;
    }

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.