Opened 9 years ago
Closed 2 years ago
#32939 closed enhancement (fixed)
Add filter for get_locale() in remove_accents()
Reported by: | akirk | Owned by: | Dualcube |
---|---|---|---|
Milestone: | 6.0 | Priority: | normal |
Severity: | normal | Version: | 4.3 |
Component: | I18N | Keywords: | has-patch |
Focuses: | Cc: |
Description
In the remove_accents()
function, a filter for the call of get_locale()
is needed for installations that want to make use of the special cases for hardcoded locales when those are different in their local installation.
Attachments (2)
Change History (16)
#2
@
9 years ago
Not sure where you'd suggest to put a parameter?
For example, when creating a slug for a new post, the blog language is German but with a different locale than de_DE
. So to have a way to rewrite the locale to the expected value (to make use of the special cases defined here), a filter (as in the patch) works as a simple solution.
Another option would be to remove the hardcoded de_DE
and do that with a filter:
if ( apply_filters( 'locale_de_DE', 'de_DE' ) === $locale ) { ... } elseif ( apply_filters( 'locale_da_DK', 'da_DK' ) === $locale ) { ... }
To me the solution from the current patch seems a bit more flexible.
#4
@
9 years ago
- Keywords needs-docs added
The filter needs to be documented as per the documentation standards.
#5
@
8 years ago
- Keywords good-first-bug needs-patch added
In the meantime, one could probably do something like this:
<?php function wp32939_change_locale( $title, $raw_title, $context ) { remove_filter( 'sanitize_title', 'wp32939_change_locale ' ); add_filter( 'locale', function() { return 'de_DE'; } ); return sanitize_title( $raw_title, '', $context ); } add_filter( 'sanitize_title', 'wp32939_change_locale', 10, 3 );
@
8 years ago
We added a filter called update_locale_for_remove_accents which could be used to change the WP default locale for installations that want to make use of the special cases for hardcoded locales when those are different in their local installation.
#6
@
7 years ago
- Keywords has-patch added; needs-patch removed
- Owner set to Dualcube
- Status changed from new to assigned
Assigning ownership to mark the good-first-bug
as "claimed".
This ticket was mentioned in Slack in #core by sergey. View the logs.
5 years ago
This ticket was mentioned in Slack in #core by david.baumwald. View the logs.
5 years ago
#10
@
5 years ago
- Keywords needs-refresh added
This will need a @since
refresh whichever cycle it ends up landing in.
This ticket was mentioned in Slack in #core by david.baumwald. View the logs.
5 years ago
#12
@
5 years ago
- Milestone changed from 5.4 to Future Release
This ticket still needs a refresh and review, and with 5.4 Beta 1 landing tomorrow, this is being moved to Future Release
. If any maintainer or committer feels this can be included in 5.4 or wishes to assume ownership during a specific cycle, feel free to update the milestone accordingly.
#13
follow-up:
↓ 14
@
2 years ago
- Keywords close added
Since WordPress 6.0 the remove_accents()
function now has a $locale
parameter, which seems to solve this use case.
#14
in reply to:
↑ 13
@
2 years ago
- Keywords needs-docs good-first-bug needs-refresh close removed
- Milestone changed from Future Release to 6.0
- Resolution set to fixed
- Status changed from assigned to closed
Replying to swissspidy:
Since WordPress 6.0 the
remove_accents()
function now has a$locale
parameter, which seems to solve this use case.
Thanks! [52809] / #54415 is the relevant commit.
Feel free to reopen if a filter is still needed here.
Would it be better to have a parameter to the function? or to attach the custom-locale replacements via a filter of some kind?
I guess I'm just not clear on the use-case of this filter.