• Resolved Oleg Burca

    (@olegburca)


    Hello,

    Thank you for a great plugin!

    I want to display the number of views, but just the number, without the word “views”.
    This is needed because my site is in Romanian and I just want to add the Romanian word instead.

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    I see that you’ve already contributed some translations here:
    https://translate.www.ads-software.com/projects/wp-plugins/post-views-for-jetpack/stable/ro/default/

    First of all, thank you! That is indeed the right way to go. I would recommend submitting more translations; as soon as 95% of the strings of any plugin are translated into a language, those translations are then sent to all WordPress sites that use that plugin in this language.

    Until the translations you’ll submit are validated and land on your site, you can use a functionality plugin to customize the output of the plugin, like so:

    /**
     * customize the output of the Views shortcode.
     *
     * @param string $view    Phrase outputting the number of views.
     * @param array  $views   Number of views.
     * @param string $post_id Post ID.
     */
    function jeherve_ro_views( $view, $views, $post_id ) {
    	if ( isset( $views ) && ! empty( $views ) ) {
    		$view = sprintf(
    			esc_html(
    				_n(
    					'%s vizualiz?ri',
    					'%s de vizualiz?ri',
    					$views['total'],
    					'default'
    				)
    			),
    			number_format_i18n( $views['total'] )
    		);
    	} else {
    		$view = esc_html__( 'Nicio vizualizare', 'default' );
    	}
    
    	return $view;
    }
    add_filter( 'jp_post_views_output', 'jeherve_ro_views', 10, 3 );
    Thread Starter Oleg Burca

    (@olegburca)

    Thank you, @jeherve!
    Completed the translation.

    Regards,
    Oleg.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to display just the number of views without “views” word?’ is closed to new replies.