mirror of
https://github.com/avecms/AVE.cms.git
synced 2026-08-01 00:45:44 +00:00
959 B
959 B
SearchText - search text
App\Helpers\SearchText - small utilities for preparing search queries.
use App\Helpers\SearchText;
Methods
###containsRussian($text): bool
Is there a Cyrillic alphabet in the text?
SearchText::containsRussian('кресло'); // true
SearchText::containsRussian('chair'); // false
###toRussian($input)
Reduces the layout to Russian - “Latin, typed by mistake” → Cyrillic (according to
keyboard layout).
SearchText::toRussian('rhtckj'); // 'кресло'
Recipe
Auto-correct layout before searching:
$q = Request::getStr('q');
if ($q !== '' && !SearchText::containsRussian($q)) {
$fixed = SearchText::toRussian($q);
// искать и по $q, и по $fixed — пользователь мог забыть переключить раскладку
}
For morphology (different word forms) - RussianStemmer.