Comment on post

Hi. It didn’t work

Hello,

The translation of the string Leave a comment on: “%s” was successful in the theme fucntion.php

However, I failed to translate to the following strings:
Leave a Comment
%s Comment
%s Comments

I was not able to identify in which file they are.

I still need to translate two strings which I pointed in the attached file.

Many thx

Hey There,

You will have to update your code into this:

function change_comment_text( $texts ) { 

  $texts['comment_notes_before'] = '<p class="comment-notes" style="color: red;">Your email address will not be published. Required fields are marked <span>*</span></p>'; 
  
  return $texts; 

} 
add_filter('comment_form_defaults','change_comment_text');

And also, you can find Comment keyword in /wp-content/themes/pro/framework/views/ethos/wp-comments.php file. You will need to copy this file, add your translations and upload this file to your child theme’s folder /wp-content/themes/pro-child/framework/views/ethos/.

Hope this helps.

1 Like

Thx.
Just a clarification. I am using Integrity. I upload to integrity?
I have those"
public_html/wp-content/themes/PRO public_html/wp-content/themes/pro-child-with-lang (for Arabic)
public_html/wp-content/themes/pro-child for English

to which one i copy the file?

Another issue for my english site https://tarekrabaa.com/en/ the display username i selected for the Arabic site is appearing as طارق الربعة how can i chane it to appear in English on my English site?

Thx

Hey There,

Sorry for the confusion. I have mistaken your site to be using Ethos. In integrity, there is no such file. We will need this custom function code added in your child theme’s functions.php file instead;

function modify_comment_form_text_area($arg) {
    $arg['comment_field'] = '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment translation here', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="1" aria-required="true"></textarea></p>';
    return $arg;
}

add_filter('comment_form_defaults', 'modify_comment_form_text_area');

Please do not forget to add your translation.

1 Like

Thx it works for the translating the word comment.
Remaining 3 issues:
1, The COMMENT / COMMENTS in the meta i couldn’t translate
2. Down after the comment there is a sentence to save name…

  1. my English site https://tarekrabaa.com/en/ the display username i selected for the Arabic site is appearing as طارق الربعة how can i change it Tarek RABAA on my English site?

Thx for your suppport

Hi Tarek,

I was working on your website then I encountered a syntax error in functions.php preventing me from accessing your website, I apologize for that, I could fix it immediately but the FTP login details didn’t work for me, could you please provide me with working FTP login details so I can fix this issue immediately and continue working on the main issue?

If you want to get access to your website immediately, you can rename this file (/pro-child-with-lang/functions.php) to “_functions.php” then create a new “functions.php” file with only this as a content:

<?php

// =============================================================================
// FUNCTIONS.PHP
// -----------------------------------------------------------------------------
// Overwrite or add your own custom functions to Pro in this file.
// =============================================================================

// =============================================================================
// TABLE OF CONTENTS
// -----------------------------------------------------------------------------
//   01. Enqueue Parent Stylesheet
//   02. Additional Functions
// =============================================================================

// Enqueue Parent Stylesheet
// =============================================================================

add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );

// Additional Functions
// =============================================================================


add_action( 'after_setup_theme', 'load_child_language' );
    function load_child_language() {
        load_child_theme_textdomain( '__x__', get_stylesheet_directory() . '/languages' );
}

Thanks.

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