Translated Wordpress strings

Hello,
1- Please note that while checking the translated strings which work for me. There is still an issue in the meta translated in the category page which has not been translated. plz check those URL for comparison:
https://tarekrabaa.com/stances/طارق-الربعة-مناشدة-رئيس-الجمهورية/
https://tarekrabaa.com/stances/
In the last URL you can see the text “Leave a Comment” i need to translate it to Arabic plz.

the previous translation strings which works are here: https://theme.co/apex/forum/t/comment-on-post/31914/66

2- Another issue is the font size of the comment which is affected by the post editor if it is thru wordpress or PRO editor.
Please check those URL for comparison:
https://tarekrabaa.com/stances/طارق-الربعة-مناشدة-رئيس-الجمهورية/
https://tarekrabaa.com/events/شركة-هواوي-للإتصالات-تجربتي/ this sentence has a font of 24px (البريد الالكتروني لن ينشر. المعلومات المطلوبة عليها علامة *)
I want the font size to be the same as this URL https://tarekrabaa.com/stances/طارق-الربعة-مناشدة-رئيس-الجمهورية/

3- How can i change the date format in the comment to be separated by a | like in the post-meta?

Thx in advance

Hi,

  1. You can include archive pages in your conditional statement.

eg.

// Translate Strings
add_filter( 'gettext', 'translate_x_strings', 20, 3 );

function translate_x_strings( $translated_text, $text, $domain ) {

    if ( is_singular() || is_archive()) {

        switch ( $translated_text ) {

            case 'Leave a Comment' :

                $translated_text = __( 'اترك تعليقا', '__x__' );
                break;

            case 'Leave a Reply' :

                $translated_text = __( 'اترك رد', '__x__' );
                break;
           case 'Name' :
                $translated_text = __( 'اسم');
                break;
           case 'Email' :

                $translated_text = __( 'البريد الإلكتروني' );
                break;
          case 'Website' :

                $translated_text = __( 'موقع الكتروني' );
                break;
          case 'Back to Top' :

                $translated_text = __( 'YOUR TRANSLATION HERE' );
                break;
        }

    }

    return $translated_text;
}
  1. In stances page you have set font-size:22px;

While in event page you have set it to font-size:24px;

You need to edit your text element and change all 24px to 22px.

  1. You can add this in your child theme’s functions.php file
function filter_get_the_date( $the_date, $d, $post ) {	

	return date( 'Y | d | m', strtotime( $the_date ) );
}
add_action( 'get_the_date', 'filter_get_the_date', 10, 3 );

Hope that helps

Hi,

1- Thx for your real help. The #1 solution is working.

2- For the font size i changed it to 22 px. Still same problem in the comment sentence.
https://tarekrabaa.com/events/شركة-هواوي-للإتصالات-تجربتي/ this sentence has a font of 24px (البريد الالكتروني لن ينشر. المعلومات المطلوبة عليها علامة *)I want the font size to be 14 px and to be independent of the P selector.

Hi There,

Please try adding this custom CSS:

div#respond p {
    font-size: 14px !important;
}

Hope it helps :slight_smile:

1 Like

thx. It works

Glad it worked.

Cheers!

Hi,
This function for the date is changing the format in the meta of the post. What i need is to change the format in the date meta in the comment. I need to separate the date and the time by a separator “|”. I want to remove the word “at” beside the clock.
thx

Hi,

You can try this code instead.

add_filter( 'get_comment_date', 'wpsites_change_comment_date_format' );	
function wpsites_change_comment_date_format( $d ) {
    $d = date("Y | d | m");	
    return $d;
}	

Hope that helps

Thx. It works. I used this format.
add_filter( 'get_comment_date', 'wpsites_change_comment_date_format' ); function wpsites_change_comment_date_format( $d ) { $d = date("d - m - Y |"); return $d; }

But I still need to change the format for the time from this format AT 9:51 PM | 23 - 05 - 2018
to this format: 9:51 PM | 2018 - 05 - 23 

In other word, i want to remove the word “at” and to add the X-icon-calender on the right.

thx

Hey @tarekr,

You will need to override Integrity’s Comment function to remove the “at” word. The function is in framework\functions\integrity.php. Here’s the whole function with the “at” word removed. The code needs to be placed in functions.php

if ( ! function_exists( 'x_integrity_comment' ) ) :
  function x_integrity_comment( $comment, $args, $depth ) {

    $GLOBALS['comment'] = $comment;
    switch ( $comment->comment_type ) :
      case 'pingback' :  // 1
      case 'trackback' : // 1
    ?>
    <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
      <p><?php _e( 'Pingback:', '__x__' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', '__x__' ), '<span class="edit-link">', '</span>' ); ?></p>
    <?php
        break;
      default : // 2
      GLOBAL $post;
      if ( X_WOOCOMMERCE_IS_ACTIVE ) :
        $rating = esc_attr( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) );
      endif;
      $avatar_variation = ( x_is_product() ) ? ' x-img-thumbnail' : '';
    ?>
    <li id="li-comment-<?php comment_ID(); ?>" itemprop="review" itemscope itemtype="http://schema.org/Review" <?php comment_class(); ?>>
      <?php
      printf( '<div class="x-comment-img">%1$s %2$s</div>',
        '<span class="avatar-wrap cf' . $avatar_variation . '">' . get_avatar( $comment, 120 ) . '</span>',
        ( $comment->user_id === $post->post_author ) ? '<span class="bypostauthor">' . __( 'Post<br>Author', '__x__' ) . '</span>' : ''
      );
      ?>
      <article id="comment-<?php comment_ID(); ?>" class="comment">
        <header class="x-comment-header">
          <?php
          printf( '<cite class="x-comment-author" itemprop="author">%1$s</cite>',
            get_comment_author_link()
          );
          printf( '<div><a href="%1$s" class="x-comment-time"><time itemprop="datePublished" datetime="%2$s">%3$s</time></a></div>',
            esc_url( get_comment_link( $comment->comment_ID ) ),
            get_comment_time( 'c' ),
            sprintf( __( '%1$s %2$s', '__x__' ),
              get_comment_date(),
              get_comment_time()
            )
          );
          edit_comment_link( __( '<i class="x-icon-edit" data-x-icon="&#xf044;"></i> Edit', '__x__' ) );
          ?>
          <?php if ( x_is_product() && get_option('woocommerce_enable_review_rating') == 'yes' ) : ?>
            <div class="star-rating-container">
              <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="<?php echo sprintf( __( 'Rated %d out of 5', '__x__' ), $rating ) ?>">
                <span style="width:<?php echo ( intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ) / 5 ) * 100; ?>%"><strong itemprop="ratingValue"><?php echo intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ); ?></strong> <?php _e( 'out of 5', '__x__' ); ?></span>
              </div>
            </div>
          <?php endif; ?>
        </header>
        <?php if ( '0' == $comment->comment_approved ) : ?>
          <p class="x-comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', '__x__' ); ?></p>
        <?php endif; ?>
        <section class="x-comment-content" itemprop="description">
          <?php comment_text(); ?>
        </section>
        <?php if ( ! x_is_product() ) : ?>
        <div class="x-reply">
          <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span class="comment-reply-link-after"><i class="x-icon-reply" data-x-icon="&#xf112;"></i></span>', '__x__' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
        </div>
        <?php endif; ?>
      </article>
    <?php
        break;
    endswitch;

  }
endif;

Hope that helps.

1 Like

Thank you very much. It works.
Last question: How can i remove the URL from the time and date in the comment? because it is clickable.

Hello There,

To remove the url of the time and date in the comment, please have this block removed:

printf( '<div><a href="%1$s" class="x-comment-time"><time itemprop="datePublished" datetime="%2$s">%3$s</time></a></div>',
  esc_url( get_comment_link( $comment->comment_ID ) ),
  get_comment_time( 'c' ),
  sprintf( __( '%1$s %2$s', '__x__' ),
    get_comment_date(),
    get_comment_time()
  )
);

And replace it with this code instead:

printf( '<div><time itemprop="datePublished" datetime="%1$s">%2$s</time></div>',
  get_comment_time( 'c' ),
  sprintf( __( '%1$s %2$s', '__x__' ),
    get_comment_date(),
    get_comment_time()
  )
);

Hope this helps.

1 Like

Excellent. You are expert and professional.
Thank you very much indeed. I customized the comments as i want by your help and real support.
شكراً لكم

You’re welcome!
We’re glad we were able to help you out.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.