From a35a1a9c75ebffbfea9f39b220fe7f0c76ebbe41 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Thu, 23 Jun 2016 13:27:32 +0000 Subject: [PATCH] I18N: Add support for the Catalan flown dot in `remove_accents()`. Props xavivars, SergeyBiryukov. Fixes #37086. git-svn-id: https://develop.svn.wordpress.org/trunk@37853 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/formatting.php | 10 +++++++++- tests/phpunit/tests/formatting/RemoveAccents.php | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 70f5ef1123..40ac4c2036 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -1484,8 +1484,14 @@ function utf8_uri_encode( $utf8_string, $length = 0 ) { * | U+00C5 | Å | Aa | Latin capital letter A with ring above | * | U+00E5 | å | aa | Latin small letter a with ring above | * + * Catalan (`ca`) locale: + * + * | Code | Glyph | Replacement | Description | + * | -------- | ----- | ----------- | --------------------------------------- | + * | U+00B7 | l·l | ll | Flown dot (between two Ls) | + * * @since 1.2.1 - * @since 4.6.0 Locale support was added for `de_CH` and `de_CH_informal`. + * @since 4.6.0 Locale support was added for `de_CH`, `de_CH_informal`, and `ca`. * * @param string $string Text that might have accent characters * @return string Filtered string with replaced "nice" characters. @@ -1689,6 +1695,8 @@ function remove_accents( $string ) { $chars[ chr(195).chr(184) ] = 'oe'; $chars[ chr(195).chr(133) ] = 'Aa'; $chars[ chr(195).chr(165) ] = 'aa'; + } elseif ( 'ca' === $locale ) { + $chars[ chr(108).chr(194).chr(183).chr(108) ] = 'll'; } $string = strtr($string, $chars); diff --git a/tests/phpunit/tests/formatting/RemoveAccents.php b/tests/phpunit/tests/formatting/RemoveAccents.php index a1a85e1bb9..7176d71eb3 100644 --- a/tests/phpunit/tests/formatting/RemoveAccents.php +++ b/tests/phpunit/tests/formatting/RemoveAccents.php @@ -110,4 +110,20 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { remove_filter( 'locale', array( $this, '_set_locale_to_danish' ) ); } + public function _set_locale_to_catalan() { + return 'ca'; + } + + /** + * @ticket 37086 + */ + public function test_remove_catalan_middot() { + add_filter( 'locale', array( $this, '_set_locale_to_catalan' ) ); + + $this->assertEquals( 'allallalla', remove_accents( 'al·lallaŀla' ) ); + + remove_filter( 'locale', array( $this, '_set_locale_to_catalan' ) ); + + $this->assertEquals( 'al·lallalla', remove_accents( 'al·lallaŀla' ) ); + } }