Implement accent-insensitive search for Portuguese characters #3260
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR implements accent-insensitive search functionality to address the issue where users cannot find results when searching without accents (e.g., searching 'simoes' to find 'Simões').
Problem
Users in Portuguese-speaking countries often don't type accents when searching, but expect to find results with accented characters. This is especially common in Brazilian Portuguese where users might search for:
Solution
Added a new configuration option
ignore_accents
that when enabled, normalizes both search terms and data to their base characters before comparison.Changes Made
'ignore_accents' => false
to the search config indatatables.php
Helper::normalizeAccents()
to convert accented characters to base charactersConfig::isIgnoreAccents()
to check if the feature is enabledSupported Characters (Portuguese Brazilian)
Usage
Enable the feature in your config:
When enabled:
Testing
Database Compatibility
The feature uses appropriate database functions:
REPLACE()
function cascade for each accent mappingUNACCENT()
function if available, fallback toREPLACE()
REPLACE()
function cascadeREPLACE()
function cascadeBreaking Changes
None - this is a new optional feature that is disabled by default.
Fixes #3249