[wp-trac] [WordPress Trac] #54415: remove_accent does not remove accents

WordPress Trac noreply at wordpress.org
Thu Nov 11 12:31:33 UTC 2021


#54415: remove_accent does not remove accents
-----------------------------------------+------------------------------
 Reporter:  malthert                     |       Owner:  (none)
     Type:  defect (bug)                 |      Status:  new
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  Formatting                   |     Version:
 Severity:  normal                       |  Resolution:
 Keywords:  reporter-feedback has-patch  |     Focuses:
-----------------------------------------+------------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:6 malthert]:
 > 1) add the missing locales to the existing function
 > or: remove _formal/_informal from locale string and just check for
 de_DE, de_AT, de_CH so all those cases are covered
 > => best: I think we should just use the first 2 letters of the locale
 here, so it will be consistent for all "de" locale, as this is what is
 originally intended here.

 Sounds good to me, let's just check for any `de_*` locale.

 > 2) the letter "ß" is only used in German languages anyway and there is
 no transliteration of ß => s to be found anywhere.
 > This will be removed from the conditional and update the "general"
 transliteration of ß to ss

 I think I'd prefer for this to be added to the conditial too, for clarity
 and consistency, to keep the replacements relevant to German locales in a
 single place.
 >
 > 3) add a 2nd arg to the function remove_accents: $locale = false (@param
 string $locale optionally set a locale if you do not want to use the
 locale of the current language)

 I think this can already be achieved by using `switch_to_locale()` and
 `restore_previous_locale()`:
 {{{
 $switched_locale = switch_to_locale( '...' );

 $string = remove_accents( $string );

 if ( $switched_locale ) {
         restore_previous_locale();
 }
 }}}

 The same approach is used when sending emails in user's language instead
 of site language, without the need for passing any additional parameters
 to the functions.

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


More information about the wp-trac mailing list