[wp-trac] [WordPress Trac] #44541: Text length should be localizable

WordPress Trac noreply at wordpress.org
Mon Jul 9 16:19:20 UTC 2018


#44541: Text length should be localizable
--------------------------------------+---------------------
 Reporter:  miyauchi                  |       Owner:  (none)
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  5.0
Component:  I18N                      |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+---------------------

Comment (by birgire):

 Replying to [comment:7 miyauchi]:
 > Hi @birgire
 >
 > Thanks! I fixed as you recommended. :)

 @miyauchi that's great, thanks, just two more suggestions I have for now
 :)

 1) Make sure the previous locale is restored in case of a test failure. So
 instead of:

 {{{
 /**
  * @ticket 44541
  */
 function test_trims_to_20_counted_by_chars() {
         switch_to_locale( 'ja_JP' );
         $expected = substr( $this->long_text, 0, 20 ) . '…';
         $this->assertEquals( $expected, wp_trim_words( $this->long_text,
 20 ) );
         restore_previous_locale();
 }

 }}}

 we could consider moving {{{restore_previous_locale()}}} above the
 assertion:

 {{{
 /**
  * @ticket 44541
  */
 function test_trims_to_20_counted_by_chars() {
         switch_to_locale( 'ja_JP' );
         $expected = substr( $this->long_text, 0, 20 ) . '…';
         restore_previous_locale();
         $actual = wp_trim_words( $this->long_text, 20 );
         $this->assertEquals( $expected, $actual );
 }

 }}}

 Similar in these methods:

 -
 {{{Tests_Formatting_WPTrimWords::test_trims_to_20_counted_by_chars_with_double_width_chars()}}}
 -
 {{{Tests_L10n::test_length_of_comment_excerpt_should_be_counted_by_words()}}}
 -
 {{{Tests_L10n::test_length_of_comment_excerpt_should_be_counted_by_chars()}}}
 -
 {{{Tests_L10n::test_length_of_comment_excerpt_should_be_counted_by_chars_in_Japanese()}}}

 2) In {{{tests/phpunit/data/languages/ja_JP.po}}} I noticed the {{{src/}}}
 reference:


 {{{
 #. translators: This sets the text length for the comment excerpt.
 #: src/wp-includes/comment-template.ph:599
 msgctxt "comment_excerpt_length"
 msgid "20"
 msgstr "40"

 #. translators: This sets the text length for the comment excerpt.
 #: src/wp-admin/includes/dashboard.php:591
 msgctxt "draft_length"
 msgid "10"
 msgstr "40"

 }}}

 The other cases seems to skip it, e.g.:

 {{{
 #. translators: This sets the text length for the excerpt.
 #: wp-includes/formatting.php:3640
 msgctxt "excerpt_length"
 msgid "55"
 msgstr "110"

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44541#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list