• Всех приветствую.

    Остались финишные штрихи и как всегда с ними очередная засада. Как вы помните, я немного ковыряюсь тему modernize. Практически переименовал все что нужно. А вот с комментариями до конца дожать не получилось.

    У меня получилось слово «комментарии» на «мысль» только в самих записях, а вот на остальных общих страницах осталось слово «комментарий» осталось. Каких переименовать вообще не могу понять.

    Да, понимаю, можно было пользоваться плагинами переводчиками, так так получилось. Мне осталось допилить только это слово.

    Привожу код файла comments.php темы

    <?php
    /**
     * The template for displaying comments.
     *
     * This is the template that displays the area of the page that contains both the current comments
     * and the comment form.
     *
     * @package modernize
     * @author Takuma Misumi
     * @link http://blog.mismithportfolio.com/
     * @license GPLv2 or later
     */
    
    /*
     * If the current post is protected by a password and
     * the visitor has not yet entered the password we will
     * return early without loading the comments.
     */
    if ( post_password_required() ) {
      return;
    }
    ?>
    
    <div id="comments" class="comments">
    
      <?php
      // You can start editing here -- including this comment!
      if ( have_comments() ) : ?>
        <h2 class="comments__title">
          <?php
            printf( // WPCS: XSS OK.
              esc_html( _nx( 'мысль &ldquo;%2$s&rdquo;', '%1$s мыслей &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'modernize' ) ),
              number_format_i18n( get_comments_number() ),
              '<span>' . get_the_title() . '</span>'
            );
          ?>
        </h2>
    
        <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
        <nav id="comment-nav-above" class="navigation comment__navigation" role="navigation">
          <h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'modernize' ); ?></h2>
          <div class="nav-links">
    
            <div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'modernize' ) ); ?></div>
            <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'modernize' ) ); ?></div>
    
          </div><!-- .nav-links -->
        </nav><!-- #comment-nav-above -->
        <?php endif; // Check for comment navigation. ?>
    
        <ol class="comments__list">
          <?php
            wp_list_comments( array(
              'style'      => 'ol',
              'short_ping' => true,
           'avatar_size'    => 48
            ) );
          ?>
        </ol><!-- .comments__list -->
    
        <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
        <nav id="comment-nav-below" class="navigation comment__navigation" role="navigation">
          <h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'modernize' ); ?></h2>
          <div class="nav-links">
    
            <div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'modernize' ) ); ?></div>
            <div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'modernize' ) ); ?></div>
    
          </div><!-- .nav-links -->
        </nav><!-- #comment-nav-below -->
        <?php
        endif; // Check for comment navigation.
    
      endif; // Check for have_comments().
    
      // If comments are closed and there are comments, let's leave a little note, shall we?
      if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
    
        <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'modernize' ); ?></p>
      <?php
      endif;
    
      comment_form();
      ?>
    
    </div><!-- #comments -->
    

    А также файла template-tags.php, где также лежали ответственные коды

    <?php
    /**
     * Custom template tags for this theme.
     *
     * Eventually, some of the functionality here could be replaced by core features.
     *
     * @package modernize
     * @author Takuma Misumi
     * @link http://blog.mismithportfolio.com/
     * @license GPLv2 or later
     */
    
    if ( ! function_exists( 'modernize_posted_on' ) ) :
    /**
     * Prints HTML with meta information for the current post-date/time and author.
     */
    function modernize_posted_on() {
      $time_string = '<span class="publised-label">Опубликовано<time class="entry-date published" datetime="%1$s">%2$s</time></span>';
    
      $entry = get_the_date( 'Ymd' );
      $modified = get_the_modified_date( 'Ymd' );
    
      if ( $entry !== $modified && !is_home() && !is_archive() && !is_search() ) {
        $time_string = '
        <span class="publised-label">Опубликовано<span>%2$s</span></span>
        <span class="update-label">Обновлено<time class="updated" datetime="%3$s">%4$s</time></span>
        ';
      }
    
      $time_string = sprintf( $time_string,
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() ),
        esc_attr( get_the_modified_date( 'c' ) ),
        esc_html( get_the_modified_date() )
      );
    
      $posted_on = sprintf( $time_string );
    
      $byline = sprintf(
        esc_html_x( '', '', 'modernize' ),
        ''
      );
    
      echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.
    
    }
    endif;
    
    if ( ! function_exists( 'modernize_entry_footer' ) ) :
    /**
     * Prints HTML with meta information for the categories, tags and comments.
     */
    function modernize_entry_footer() {
      // Hide category and tag text for pages.
      if ( 'post' === get_post_type() ) {
        /* translators: used between list items, there is a space after the comma */
        $categories_list = get_the_category_list( esc_html__( '', 'modernize' ) );
        if ( $categories_list && modernize_categorized_blog() ) {
          printf( '<span class="cat-links">' . esc_html__( 'Category : %1$s', 'modernize' ) . '</span>', $categories_list ); // WPCS: XSS OK.
        }
    
        /* translators: used between list items, there is a space after the comma */
        $tags_list = get_the_tag_list( '', esc_html__( '', 'modernize' ) );
        if ( $tags_list ) {
          printf( '<span class="tags-links">' . esc_html__( 'Tag : %1$s', 'modernize' ) . '</span>', $tags_list ); // WPCS: XSS OK.
        }
      }
    
      if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
        echo '<span class="comments-link">';
        /* translators: %s: post title */
        comments_popup_link( sprintf( wp_kses( __( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', 'modernize' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) );
        echo '</span>';
      }
    
      edit_post_link(
        sprintf(
          /* translators: %s: Name of current post */
          esc_html__( 'Edit %s', 'modernize' ),
          the_title( '<span class="screen-reader-text">"', '"</span>', false )
        ),
        '<span class="edit-link">',
        '</span>'
      );
    }
    endif;
    
    /**
     * Returns true if a blog has more than 1 category.
     *
     * @return bool
     */
    function modernize_categorized_blog() {
      if ( false === ( $all_the_cool_cats = get_transient( 'modernize_categories' ) ) ) {
        // Create an array of all the categories that are attached to posts.
        $all_the_cool_cats = get_categories( array(
          'fields'     => 'ids',
          'hide_empty' => 1,
          // We only need to know if there is more than one category.
          'number'     => 2,
        ) );
    
        // Count the number of categories that are attached to the posts.
        $all_the_cool_cats = count( $all_the_cool_cats );
    
        set_transient( 'modernize_categories', $all_the_cool_cats );
      }
    
      if ( $all_the_cool_cats > 1 ) {
        // This blog has more than 1 category so modernize_categorized_blog should return true.
        return true;
      } else {
        // This blog has only 1 category so modernize_categorized_blog should return false.
        return false;
      }
    }
    
    /**
     * Flush out the transients used in modernize_categorized_blog.
     */
    function modernize_category_transient_flusher() {
      if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
        return;
      }
      // Like, beat it. Dig?
      delete_transient( 'modernize_categories' );
    }
    add_action( 'edit_category', 'modernize_category_transient_flusher' );
    add_action( 'save_post',     'modernize_category_transient_flusher' );
    

    Буду рад помощи!

Просмотр 7 ответов — с 1 по 7 (всего 7)
  • Уважаемые друзья.
    Последние мучения оказали, за решение проблемы отвечает нижеприведенный кусок кода. В него надо что-то добавить, чтобы он изменил слово «комментарий» на «мысль».
    Дело в том, что когда у поста нет комментария, он пишет строку «Leave a Commen», которая успешно переименовывается. Но когда комментарий оставляется, то тема modernize снова пишет «комментарий».
    Видимо она откуда-то его берет «по умолчанию» и надо это умолчание как-то увенчать 🙂

     if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
        echo '<span class="comments-link">';
        /* translators: %s: post title */
        comments_popup_link( sprintf( wp_kses( __( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', 'modernize' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) );
        echo '</span>';
      }

    Последние мучения оказали, за решение проблемы отвечает нижеприведенный кусок кода.

    Точно так же как за бананы в ближайшем супермаркете солнце Конго.
    В этом топике Вам же уже всё рассказали. Показали 3 варианта.

    SeVlad в данном случае речь идет о переименовании слово «комментарии» не странице топика, а вообще в блоге в превью постов.
    Кстати, даже локо переводчик не может найти исходные данные!

    Попробуйте перечитать тот топик. Поверьте, там всё есть.

    SeVlad, Я вам прекрасно верю, но к сожалению не могу найти. Если бы вы указали конкретно, я был бы рад.

    Если бы вы указали конкретно, я был бы рад.

    См ответы Yui, Сергея и мой.

    Yui не получилось через плагин. Код Сергей заменяет лишь форму. Увы.

Просмотр 7 ответов — с 1 по 7 (всего 7)
  • Тема «Переименовать «комментарии» на «мысли» — бесценно!» закрыта для новых ответов.