Comment on post

Hello Alaa,

i sent you FTP credentials in secure note.
My website is not working anymore,

Regards,

Hi Tarek,

Thanks for sharing the FTP information.

  • I translated “% Comment, % Comments” by adding this snippet to functions.php file in (pro-child-with-lang) theme:
function x_integrity_entry_meta() {

    //
    // Author.
    //

    $author = sprintf( '<span><i class="x-icon-pencil" data-x-icon="&#xf040;"></i> %s</span>',
      get_the_author()
    );


    //
    // Date.
    //

    $date = sprintf( '<span><time class="entry-date" datetime="%1$s"><i class="x-icon-calendar" data-x-icon="&#xf073;"></i> %2$s</time></span>',
      esc_attr( get_the_date( 'c' ) ),
      esc_html( get_the_date() )
    );


    //
    // Categories.
    //

    if ( get_post_type() == 'x-portfolio' ) {
      if ( has_term( '', 'portfolio-category', NULL ) ) {
        $categories        = get_the_terms( get_the_ID(), 'portfolio-category' );
        $separator         = ', ';
        $categories_output = '';
        foreach ( $categories as $category ) {
          $categories_output .= '<a href="'
                              . get_term_link( $category->slug, 'portfolio-category' )
                              . '" title="'
                              . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                              . '"><i class="x-icon-bookmark" data-x-icon="&#xf02e;"></i> '
                              . $category->name
                              . '</a>'
                              . $separator;
        }

        $categories_list = sprintf( '<span>%s</span>',
          trim( $categories_output, $separator )
        );
      } else {
        $categories_list = '';
      }
    } else {
      $categories        = get_the_category();
      $separator         = ', ';
      $categories_output = '';
      foreach ( $categories as $category ) {
        $categories_output .= '<a href="'
                            . get_category_link( $category->term_id )
                            . '" title="'
                            . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                            . '"><i class="x-icon-bookmark" data-x-icon="&#xf02e;"></i> '
                            . $category->name
                            . '</a>'
                            . $separator;
      }

      $categories_list = sprintf( '<span>%s</span>',
        trim( $categories_output, $separator )
      );
    }


    //
    // Comments link.
    //

    if ( comments_open() ) {

      $title  = apply_filters( 'x_entry_meta_comments_title', get_the_title() );
      $link   = apply_filters( 'x_entry_meta_comments_link', get_comments_link() );
      $number = apply_filters( 'x_entry_meta_comments_number', get_comments_number() );

      $text = ( 0 == $number ) ? __( 'Leave a Comment', '__x__' ) : sprintf( _n( '%s تعليق', '%s تعليقات', $number, '__x__' ), $number );

$comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments" data-x-icon="&#xf086;"></i> %3$s</a></span>',
        esc_url( $link ),
        esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
        $text
      );

    } else {

      $comments = '';

    }


    //
    // Output.
    //

    if ( x_does_not_need_entry_meta() ) {
      return;
    } else {
      printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>',
        $author,
        $date,
        $categories_list,
        $comments
      );
    }

  }
  • I translated “Save my name, email, and website in this browser for the next time I comment.” string by adding this extra case in functions.php file as well:
case 'Save my name, email, and website in this browser for the next time I comment.' :

          $translated_text = __( 'احفظ الاسم، الايميل والموقع في المتصفح حتى المرة القادمة عند التعليق' );
          break;
  • Regarding the user name, since you have only one user for both the English and Arabic site, this will be very hard to achieve, I recommend creating a new username and give it access only to the English site, let’s say you will give it the name “Tarek”, then you should be able to choose it right there:

Thanks.

Hello,

Now everything is OK as i want.
The last thing remaining is to translate the string your comment is waiting for moderation as per the attached PRNTSCREEN.

Another issue is the appearance of the comments on the mobile. it needs some adjustment to align with the post’s content. Plz check the screen-shot.

And the last issue is the Plugin Sassy social share. I have on hoover two words in English appear on hoover “More” and “Share”. I tried to translate them but i failed. Plz check the screen shot.

Thx in advance

Hi there,

You can translate it the same way as this,

case 'Save my name, email, and website in this browser for the next time I comment.' :

          $translated_text = __( 'احفظ الاسم، الايميل والموقع في المتصفح حتى المرة القادمة عند التعليق' );
          break;

Just make sure to edit the correct child theme ( pro-child-with-lang ). You can add your other texts, just make sure the texts are exactly as is (capitalization, spaces, and so on).

As for the sharing icons, you should contact the plugin author. We’re not sure if they are translatable or if it has language files.

Thanks!

1 Like

OK I translated the “comment waiting for moderation”.
Another issue is the appearance of the comments on the mobile. it needs some adjustment to align with the post’s content. Plz check the screen-shot above.

Hi there,

Please change this existing CSS

[lang="ar"] .x-comments-area {
    padding: 0 60px;
    direction: rtl;
}

to this

@media ( min-width: 980px ) {
[lang="ar"] .x-comments-area {
    padding: 0 60px;
    direction: rtl;
}
}

Thanks!

1 Like

thx
It works. I used min-width:900px

Hi,

How can i translate the message shown in the attached screenshot? If i press submit while the comments’ fields are empty, i have an error. I want to replace by a message in arabic
خطأ: يرجى ملء الحقول المطلوبة (الاسم، البريد الإلكتروني).

Instead of back i want: الرجوع
Any idea?

Hey @tarekr,

That is part of WordPress. Also, this getting into custom development which is outside the scope of our support. Regretfully, you will need to hire a developer to help you with this.

Thank you for understanding.

Hire a developer to translate a string!!
I will not do that

Hi @tarekr,

We did help you with translations, but we can’t cover all translations given that we already provided the ways for translating strings. Moving forward, you should consult it to a developer for further issues with translation, there will be more :slight_smile: especially it’s a multi-site (site per language) instead of actual translations on single site. And you’re going to maintain all those translations manually.

But this is the hint, this one needs translation :slight_smile:

<strong>ERROR</strong>: please fill the required fields (name, email).

It’s from this code of this file \wp-includes\comment.php

	if ( get_option( 'require_name_email' ) && ! $user->exists() ) {
		if ( 6 > strlen( $comment_author_email ) || '' == $comment_author ) {
			return new WP_Error( 'require_name_email', __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), 200 );
		} elseif ( ! is_email( $comment_author_email ) ) {
			return new WP_Error( 'require_valid_email', __( '<strong>ERROR</strong>: please enter a valid email address.' ), 200 );
		}
	}

	if ( isset( $comment_author ) && $max_lengths['comment_author'] < mb_strlen( $comment_author, '8bit' ) ) {
		return new WP_Error( 'comment_author_column_length', __( '<strong>ERROR</strong>: your name is too long.' ), 200 );
	}

	if ( isset( $comment_author_email ) && $max_lengths['comment_author_email'] < strlen( $comment_author_email ) ) {
		return new WP_Error( 'comment_author_email_column_length', __( '<strong>ERROR</strong>: your email address is too long.' ), 200 );
	}

	if ( isset( $comment_author_url ) && $max_lengths['comment_author_url'] < strlen( $comment_author_url ) ) {
		return new WP_Error( 'comment_author_url_column_length', __( '<strong>ERROR</strong>: your url is too long.' ), 200 );
	}

	if ( '' == $comment_content ) {
		return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 );
	} elseif ( $max_lengths['comment_content'] < mb_strlen( $comment_content, '8bit' ) ) {
		return new WP_Error( 'comment_content_column_length', __( '<strong>ERROR</strong>: your comment is too long.' ), 200 );
	}

And they are too many.

Thanks!

1 Like

thx for your help.
This code i added to functions.php and it works
add_action( 'pre_comment_on_post', function ( $comment_post_ID ) { $go_back = sprintf( __( '<br><a href="javascript:history.go(-1)">Back to "%s" Article</a>' ), get_the_title( $comment_post_ID ) ); // Part-copied from "wp-comments-post.php", with $go_back tagged onto error strings. $comment_author = ( isset($_POST['author']) ) ? trim(strip_tags($_POST['author'])) : null; $comment_author_email = ( isset($_POST['email']) ) ? trim($_POST['email']) : null; $comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null; $user = wp_get_current_user(); if ( get_option('require_name_email') && !$user->exists() ) { if ( 6 > strlen( $comment_author_email ) || '' == $comment_author ) { wp_die( __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ) . $go_back, 200 ); } elseif ( ! is_email( $comment_author_email ) ) { wp_die( __( '<strong>خطأ</strong>: الرجاء ادخال بريد الكتروني صحيح.' ) . $go_back, 200 ); } } if ( '' == $comment_content ) { wp_die( __( '<strong>ERROR</strong>: please type a comment.' ) . $go_back, 200 ); } } );

You are most welcome. :slight_smile:

1 Like

Hello,

Plz this is the last thing i need to translate. Translating strings are not easy at all. I tried to translate this “Please fill out this field” but i didn’t succeed. This sentence appears on clicking the submit button when the fields are empty.
Would you please help in this last issue?

Thx in advance.

Hi There,

We’re glad other translations are working now. Yes I can see the issue. But this is not related to theme or wordpress. That specific error message come from browser, the language of these messages depends on your browser installation language so people will see correct language if they use browser with own language. Change your browser language:


There might be cases that you will not see correct translation: See explanations here:
https://support.mozilla.org/en-US/questions/1018512

Hope this helps.

Hi.
Not this what i meant. I need to custom the message. to change the “please fill out this form”>
Also, there is the arrow provided by the theme (X-angle-up) i want to replace the word back to top by another sentence in Arabic.
Any idea?

thx

Hi,

As my colleague have stated this text "please fill out this form" is being added by your browser.

https://www.google.com.ph/search?rlz=1C1CHBD_enPH772PH772&ei=zEcCW-i7I8T-0gT78oTQAg&q=chrome+please+fill+out+this+field+html&oq=chrome+please+fill+out+this+field+html&gs_l=psy-ab.3...2027.2800.0.3036.7.7.0.0.0.0.230.554.0j2j1.3.0....0...1c.1.64.psy-ab..5.2.322...0i13k1j0i8i7i30k1j0i8i13i30k1.0.ewx3uvIaAYI

With regards to Back to top text, you can add the code below in your child theme’s functions.php file

 function x_scroll_top_anchor() {
    if ( x_get_option( 'x_footer_scroll_top_display' ) == '1' ) : ?>

      <a class="x-scroll-top <?php echo x_get_option( 'x_footer_scroll_top_position' ); ?> fade" title="<?php esc_attr_e( 'Back to Top', '__x__' ); ?>">
        <i class="x-icon-angle-up" data-x-icon="&#xf106;"></i>
      </a>

      <script>
      jQuery(document).ready(function($) {
        var windowObj            = $(window);
        var body                 = $('body');
        var bodyOffsetBottom     = windowObj.scrollBottom();             // 1
        var bodyHeightAdjustment = body.height() - bodyOffsetBottom;     // 2
        var bodyHeightAdjusted   = body.height() - bodyHeightAdjustment; // 3
        var scrollTopAnchor      = $('.x-scroll-top');
        function sizingUpdate(){
          var bodyOffsetTop = windowObj.scrollTop();
          if ( bodyOffsetTop > ( bodyHeightAdjusted * <?php echo x_get_option( 'x_footer_scroll_top_display_unit' ) / 100; ?> ) ) {
            scrollTopAnchor.addClass('in');
          } else {
            scrollTopAnchor.removeClass('in');
          }
        }
        windowObj.bind('scroll', sizingUpdate).resize(sizingUpdate);
        sizingUpdate();
        scrollTopAnchor.click(function(){
          $('html, body').animate({ scrollTop: 0 }, 850, 'xEaseInOutExpo');
          return false;
        });
      });
      </script>

    <?php endif;
  }

Change Back to Top to any text you like.

Hope that helps

Hi,
I added the code to the child theme’s with lang functions.php.
The scroll top anchor disappeared completely. Just to clarify an issue: I want back to top as it is for the tarekrabaa.com/en/ (English Website) and to replace back to top to Arabic translation for the arabic website.

thx

Hi there,

Please update the previous translation code:

to

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

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

    if ( is_singular() ) {

        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;
}

Please supply the translation in:

          case 'Back to Top' :

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

Hope this helps.

1 Like

It works.
Thx