Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #434044

    Hello again,

    I am rather a detail-oriented person and during the translation of whole page into Polish I have found something which doesn’t make me happy :)
    The problem concerns Polish language (maybe some other Slavic languages as well) and our different plural forms of the noun.
    In English it’s simple:
    1 comment, review,
    0 and 2-∞ comments, reviews.

    But Polish language does not coddle us too much, so we have different word endings depending on the number. I know that what I am asking for is rather strange, but as I said I am a detail-oriented person so … is there any chance to extend the PHP code allowing to use a better translation. In my opinion if we succeed it might be also something profitable for you in the future!

    A colleague of mine has prepared a logical base of such change I do hope it will be somehow helpful, but the only problem is where to put it on :)

    Here comes that code:

                                    // Rules for first 19 numbers
                                    
                                    if ($comments_count <= 19) {
                                        
                                        if ($comments_count > 4 || $comments_count === 0) { // set of numbers 5 to 19
                                            $comments_text = __('% comments', 'textdomain'); // in Polish komentarzy
                                        } elseif (in_array($comments_count, array(2, 3, 4))) { // set of numbers 2, 3, 4
                                            $comments_text = __('% comments', 'textdomain'); // in Polish komentarze
                                        } else { // the rest, which is for 1 (for singular form)
                                            $comments_text = __('% comment', 'textdomain'); // in Polish komentarz
                                        }
                                    } else { // rules for numbers bigger than 20
                                        $last_char = substr((string) $comments_count, -1, 1); // it gives last digit of string
    
                                        if (in_array((int) $last_char, array(0, 1, 5, 6, 7, 8, 9))) { // end digit 0, 1, 5, 6, 7, 8, 9
                                            $comments_text = __('% comments', 'textdomain'); // in Polish komentarzy
                                        } elseif (in_array((int) $last_char, array(2, 3, 4))) { // end digit 2, 3, 4
                                            $comments_text = __('% comments', 'textdomain'); // in Polish komentarze
                                        }
                                    }
    

    I know that further translation into Polish would require a lot of tries, but this I think I can easily manage myself.

    Thank you for considering my request.

    Best regards,
    Leszek

    #434943

    Hi leszek!

    Thank you for using Enfold.

    Where exactly do you want this modification to go? Please give us a link to the actual page. Try to edit comments.php or includes > loop-comment.php.

    Cheers!
    Ismael

    #435099

    Hi Ismael,

    thanks for your reply. Here comes temporary links to my webpage:
    EN: http://wp.lumifall.com
    PL: http://wp.lumifall.pl

    I would like to translate the inscriptions review/reviews, comment/comments and reply/replies which are displayed on following pages:
    – review(s) tab on products (woocommerce) | example: http://wp.lumifall.com/products/led-surface-mounted-luminaires/cilindroled-ii/
    – reply/replies on news (posts) and project (portfolio) page | example: http://wp.lumifall.com/happy-easter-2015/ & http://wp.lumifall.com/projects/single-family-house/
    – comment/comments displayed on the bottom of page in Post Slider, next to the date of post | example: http://wp.lumifall.com/santoled-175-multi/

    Could you please advise whether the code is valid? I think it will need some modifications for each specific subject listed above.

    Thanks and all the best.
    Leszek

    #435809

    Hey!

    1.) For the single product page, please contact the woocommerce support.

    2.) For post and portfolio pages, you can edit comments.php, look for this code:

    <?php 
    	        			$ccount = (int) get_comments_number();
    	        			$rep	= __( 'replies', 'avia_framework' );
    	        			if($ccount === 1) $rep	= __( 'reply', 'avia_framework' );
    	        			?>
    	        			
    	        			<span class='comment-count'><?php echo $ccount; ?></span>

    As I’m not familiar with the language, I’m not sure if I can properly test the logic of the code above. Please contact your friend or the script author.

    Best regards,
    Ismael

    #448355

    Hi Ismail,

    Sorry it took so long, but I was focused on filling the site with content and new images. So only today I managed to find some time to check it again.

    I have made all the changes in the copy of comments.php file, which I have placed in child directory, but it seems the ‘page’ is still using original file located in enfold folder not the one from enfold-child.

    Do I need to edit the original file?

    Thanks and regads,
    Leszek

    #448587

    Hi Leszek!

    Try editing the original file and check if the changes come in effect first.

    Cheers!
    Josue

    #449499

    Hello Josue,

    after swapping the comments.php file it worked … with some buts. If I wanted only Polish version it would be easy to achieve using my custom php code. But the problem appears with English version and translation via WPML string translations. It finds only first encountered string ‘replies’ so I can’t use different translations of it depending on the value.

    The best would be to have two different comments.php files, one for each language – is it possible to redirect it somehow?

    Thanks and regards,
    Leszek

    #449772

    Hey!
    WPML has a PHP constant called ICL_LANGUAGE_CODE you can use to run certain code depending on the current language being displayed:
    https://wpml.org/forums/topic-tag/icl_language_code/

    Regards,
    Josue

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.