From 8bc6917cc3f37c9ff2d0f5098f21397fd0546875 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 23 Sep 2016 00:06:24 +0000 Subject: [PATCH] I18N: Add support for Serbian crossed D in `remove_accents()`. Props Krstarica for the report. Fixes #38078. git-svn-id: https://develop.svn.wordpress.org/trunk@38646 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/formatting.php | 11 ++++++++++ .../tests/formatting/RemoveAccents.php | 21 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 1cd0cf75c9..5869082c23 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -1490,8 +1490,16 @@ function utf8_uri_encode( $utf8_string, $length = 0 ) { * | -------- | ----- | ----------- | --------------------------------------- | * | U+00B7 | l·l | ll | Flown dot (between two Ls) | * + * Serbian (`sr_RS`) locale: + * + * | Code | Glyph | Replacement | Description | + * | -------- | ----- | ----------- | --------------------------------------- | + * | U+0110 | Đ | DJ | Latin capital letter D with stroke | + * | U+0111 | đ | dj | Latin small letter d with stroke | + * * @since 1.2.1 * @since 4.6.0 Added locale support for `de_CH`, `de_CH_informal`, and `ca`. + * @since 4.7.0 Added locale support for `sr_RS`. * * @param string $string Text that might have accent characters * @return string Filtered string with replaced "nice" characters. @@ -1697,6 +1705,9 @@ function remove_accents( $string ) { $chars[ 'å' ] = 'aa'; } elseif ( 'ca' === $locale ) { $chars[ 'l·l' ] = 'll'; + } elseif ( 'sr_RS' === $locale ) { + $chars[ 'Đ' ] = 'DJ'; + $chars[ 'đ' ] = 'dj'; } $string = strtr($string, $chars); diff --git a/tests/phpunit/tests/formatting/RemoveAccents.php b/tests/phpunit/tests/formatting/RemoveAccents.php index 65eebb5c4d..3fecac9c71 100644 --- a/tests/phpunit/tests/formatting/RemoveAccents.php +++ b/tests/phpunit/tests/formatting/RemoveAccents.php @@ -115,8 +115,8 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { } /** - * @ticket 37086 - */ + * @ticket 37086 + */ public function test_remove_catalan_middot() { add_filter( 'locale', array( $this, '_set_locale_to_catalan' ) ); @@ -126,4 +126,21 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { $this->assertEquals( 'al·lallalla', remove_accents( 'al·lallaŀla' ) ); } + + public function _set_locale_to_serbian() { + return 'sr_RS'; + } + + /** + * @ticket 38078 + */ + public function test_transcribe_serbian_crossed_d() { + add_filter( 'locale', array( $this, '_set_locale_to_serbian' ) ); + + $this->assertEquals( 'DJdj', remove_accents( 'Đđ' ) ); + + remove_filter( 'locale', array( $this, '_set_locale_to_serbian' ) ); + + $this->assertEquals( 'Dd', remove_accents( 'Đđ' ) ); + } }