Skip to content
Snippets Groups Projects
Commit 337b913c authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #1239 from greezybacon/issue/1229


i18n: Correctly initialize the word break iterator

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents fdd82a7f 3f010591
No related branches found
No related tags found
No related merge requests found
...@@ -575,7 +575,9 @@ class Format { ...@@ -575,7 +575,9 @@ class Format {
// Performs Unicode normalization (where possible) and splits words at // Performs Unicode normalization (where possible) and splits words at
// difficult word boundaries (for far eastern languages) // difficult word boundaries (for far eastern languages)
function searchable($text) { function searchable($text, $lang=false) {
global $cfg;
if (function_exists('normalizer_normalize')) { if (function_exists('normalizer_normalize')) {
// Normalize text input :: remove diacritics and such // Normalize text input :: remove diacritics and such
$text = normalizer_normalize($text, Normalizer::FORM_C); $text = normalizer_normalize($text, Normalizer::FORM_C);
...@@ -613,7 +615,9 @@ class Format { ...@@ -613,7 +615,9 @@ class Format {
if (class_exists('IntlBreakIterator')) { if (class_exists('IntlBreakIterator')) {
// Split by word boundaries // Split by word boundaries
if ($tokenizer = IntlBreakIterator::createWordInstance()) { if ($tokenizer = IntlBreakIterator::createWordInstance(
$lang ?: ($cfg ? $cfg->getSystemLanguage() : 'en_US'))
) {
$tokenizer->setText($text); $tokenizer->setText($text);
$text = implode(' ', $tokenizer); $text = implode(' ', $tokenizer);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment