Opened 6 years ago
Closed 6 years ago
#45592 closed enhancement (worksforme)
Remove Accents
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.0 |
Component: | Formatting | Keywords: | |
Focuses: | Cc: |
Description
I have been lately working on an extension for library filename sanitization and seen this on wp-includes/formatting.php :
<?php // Used for locale-specific rules $locale = get_locale(); if ( 'de_DE' == $locale || 'de_DE_formal' == $locale || 'de_CH' == $locale || 'de_CH_informal' == $locale ) { $chars['Ä'] = 'Ae'; $chars['ä'] = 'ae'; $chars['Ö'] = 'Oe'; $chars['ö'] = 'oe'; $chars['Ü'] = 'Ue'; $chars['ü'] = 'ue'; $chars['ß'] = 'ss'; } elseif ( 'da_DK' === $locale ) { $chars['Æ'] = 'Ae'; $chars['æ'] = 'ae'; $chars['Ø'] = 'Oe'; $chars['ø'] = 'oe'; $chars['Å'] = 'Aa'; $chars['å'] = 'aa'; } elseif ( 'ca' === $locale ) { $chars['l·l'] = 'll'; } elseif ( 'sr_RS' === $locale || 'bs_BA' === $locale ) { $chars['Đ'] = 'DJ'; $chars['đ'] = 'dj'; }
What is the purpose about applying theses replacements only for certains languages ?
Moreover, why base this on the locale and not the user locale ?
Change History (4)
#2
follow-up:
↓ 3
@
6 years ago
Seems legit @swissspidy, thx.
But why doing "replacements" only for certains languages ?
If my site is french and I upload an image with a filename with a "ß", I would expect to be replaced, isn't it ?
#3
in reply to:
↑ 2
@
6 years ago
- Keywords close added
Replying to MaximeCulea:
But why doing "replacements" only for certains languages ?
Above the code you've quoted, there's a longer list of replacements that apply to all locales. Some locales, however, transliterate some characters differently. See #3782, #23907, #37086, #38078 for details. As noted in the comment, these are locale-specific replacements.
If my site is french and I upload an image with a filename with a "ß", I would expect to be replaced, isn't it ?
It will be replaced with 's'
, as per 'ß' => 's'
in line 1550.
remove_accents()
is used to remove accents from usernames and permalink slugs. These things are dependant on the site locale, not the user locale.