Make WordPress Core

Opened 4 years ago

Last modified 4 months ago

#50021 new feature request

Internationalization of excerpt function in "Latest Posts" block

Reported by: tmatsuur's profile tmatsuur Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.4
Component: I18N Keywords:
Focuses: Cc:


In "Latest Posts" block, when extracting excerpts from posted articles,
they are always separated by the specified number of words.

The Japanese text is not space-separated, so the excerpt displayed by
the "Latest posts" block is not shortened.

The wp_trim_words function is used to extract excerpts from "post".
This function determines whether to cut off by the number of words or
the number of characters by the following conditions.

if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 &&
    preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {

I think it is desirable to be able to extract the "latest posts" block
excerpt under the same conditions.

Change History (4)

#1 @sabernhardt
4 years ago

  • Component changed from Editor to I18N

#2 @sabernhardt
4 months ago

  • Keywords reporter-feedback added

@tmatsuur Is this still a problem for you? In my test with Japanese text, I had a truncated post excerpt.

Both the Latest Posts block and the wp_trim_words function have been updated in the past few years, and #56698 is related.

#3 @tmatsuur
4 months ago

Thanks @sabernhardt .

I feel that the situation here has not changed with version 6.4.3.

To confirm, we added a few lines of text and a "Latest Posts" block to the content of the first post in WordPress version 6.4.3.

When the site's language setting is Japanese and the user's language setting is Japanese:

In this situation, wp_trim_words() returns the following:

$post = get_post(1);
var_dump( wp_trim_words( $post->post_content ) );
string(151) "WordPress へようこそ。こちらは最初の投稿です。編集または削除し、コンテンツ作成を始めてください。 よ…"

When the user's language setting is English:

Also, wp_trim_words() returns:

string(402) "WordPress へようこそ。こちらは最初の投稿です。編集または削除し、コンテンツ作成を始めてください。 よりわかりやすくするために、数行追加しています。 これは"Latest Posts"ブロックにて抜粋表示のふるまいを確認するためのものです。 抜粋内容は編集中のユーザーの言語設定に依存しています。"

Changing the "MAX NUMBER OF WORDS(最大文字数)" in the "Latest Posts" block from 10 to 100 does not change what is displayed.

#4 @sabernhardt
4 months ago

  • Keywords reporter-feedback removed
Note: See TracTickets for help on using tickets.