Support » Plugin: Site Reviews » The best way for singular & plural translations for site_reviews_summary ‘text’

  • Resolved Adam Faryna

    (@jarfar)


    What is the best way to achieve singular & plural translations for site_reviews_summary shortcode attribute ‘text’?

    So far I do it this way: (but it’s a bit dirty)

    
        $args = [
          'assigned_to' => get_the_ID()
        ];
        $reviews = glsr_get_reviews($args);
        $reviews_count = count($reviews);
        $text = $reviews_count == 0 || $reviews_count > 1 ? __('%s customer reviews', 'storefront-child') : __('%s customer review', 'storefront-child');
        $text = sprintf($text, $reviews_count);
        echo do_shortcode(sprintf('[site_reviews_summary assigned_to="post_id" text="%s" hide="bars,if_empty,rating" class="rating-short"]', $text));
    

    FYI I don’t want to override default “{rating} out of {max} stars (based on {num} reviews)” translation, I need to have it in single place only.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.