mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 18:54:29 +00:00
I18N: Add a $locale parameter for remove_accents().
This highlights the fact that `remove_accents()` is locale-aware and makes it easier to utilize the function with different locales without having to use `switch_to_locale()` or the `locale` filter. Additionally, this commit relaxes the check for character replacements in German locales to include formal and informal variants of any `de_*` locale, even if WordPress does not have a native translation for some of them yet. Props malthert, johnbillion, knutsp, ocean90, SergeyBiryukov. Fixes #54415. git-svn-id: https://develop.svn.wordpress.org/trunk@52809 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -80,67 +80,33 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase {
|
||||
$this->assertSame( 'aaeiouuAEIOUU', remove_accents( 'aɑeiouüAEIOUÜ' ) );
|
||||
}
|
||||
|
||||
public function remove_accents_germanic_umlauts_cb() {
|
||||
return 'de_DE';
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 3782
|
||||
*/
|
||||
public function test_remove_accents_germanic_umlauts() {
|
||||
add_filter( 'locale', array( $this, 'remove_accents_germanic_umlauts_cb' ) );
|
||||
|
||||
$this->assertSame( 'AeOeUeaeoeuess', remove_accents( 'ÄÖÜäöüß' ) );
|
||||
|
||||
remove_filter( 'locale', array( $this, 'remove_accents_germanic_umlauts_cb' ) );
|
||||
}
|
||||
|
||||
public function set_locale_to_danish() {
|
||||
return 'da_DK';
|
||||
$this->assertSame( 'AeOeUeaeoeuess', remove_accents( 'ÄÖÜäöüß', 'de_DE' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 23907
|
||||
*/
|
||||
public function test_remove_danish_accents() {
|
||||
add_filter( 'locale', array( $this, 'set_locale_to_danish' ) );
|
||||
|
||||
$this->assertSame( 'AeOeAaaeoeaa', remove_accents( 'ÆØÅæøå' ) );
|
||||
|
||||
remove_filter( 'locale', array( $this, 'set_locale_to_danish' ) );
|
||||
}
|
||||
|
||||
public function set_locale_to_catalan() {
|
||||
return 'ca';
|
||||
$this->assertSame( 'AeOeAaaeoeaa', remove_accents( 'ÆØÅæøå', 'da_DK' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 37086
|
||||
*/
|
||||
public function test_remove_catalan_middot() {
|
||||
add_filter( 'locale', array( $this, 'set_locale_to_catalan' ) );
|
||||
|
||||
$this->assertSame( 'allallalla', remove_accents( 'al·lallaŀla' ) );
|
||||
|
||||
remove_filter( 'locale', array( $this, 'set_locale_to_catalan' ) );
|
||||
|
||||
$this->assertSame( 'allallalla', remove_accents( 'al·lallaŀla', 'ca' ) );
|
||||
$this->assertSame( '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->assertSame( 'DJdj', remove_accents( 'Đđ' ) );
|
||||
|
||||
remove_filter( 'locale', array( $this, 'set_locale_to_serbian' ) );
|
||||
|
||||
$this->assertSame( 'DJdj', remove_accents( 'Đđ', 'sr_RS' ) );
|
||||
$this->assertSame( 'Dd', remove_accents( 'Đđ' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user