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
This commit is contained in:
Sergey Biryukov 2016-09-23 00:06:24 +00:00
parent 1c2d321ed3
commit 8bc6917cc3
2 changed files with 30 additions and 2 deletions

View File

@ -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);

View File

@ -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( 'Đđ' ) );
}
}