From: Michael Date: Sun, 7 Jan 2024 12:45:08 +0000 (+0000) Subject: Improved handling of undetected languages X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=220a7e660a936a5beea87601d7a08201088eb3db;p=friendica.git Improved handling of undetected languages --- diff --git a/src/Model/Item.php b/src/Model/Item.php index a672f5b174..4c7f0d24fa 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2071,10 +2071,7 @@ class Item return !empty($transmitted) ? json_encode($transmitted) : null; } - $languages = self::getLanguageArray($content, 3, $item['uri-id'], $item['author-id']); - if (empty($languages)) { - return !empty($transmitted) ? json_encode($transmitted) : null; - } + $languages = self::getLanguageArray($content, 3, $item['uri-id'], $item['author-id'], $transmitted); if (!empty($transmitted)) { $languages = array_merge($transmitted, $languages); @@ -2091,9 +2088,10 @@ class Item * @param integer $count * @param integer $uri_id * @param integer $author_id + * @param array $default * @return array */ - public static function getLanguageArray(string $body, int $count, int $uri_id = 0, int $author_id = 0): array + public static function getLanguageArray(string $body, int $count, int $uri_id = 0, int $author_id = 0, array $default = ['un' => 1]): array { $searchtext = BBCode::toSearchText($body, $uri_id); @@ -2107,7 +2105,7 @@ class Item } if (empty($searchtext)) { - return ['un' => 1]; + return $default; } $ld = new Language(DI::l10n()->getDetectableLanguages()); @@ -2131,7 +2129,7 @@ class Item } if (empty($result)) { - return ['un' => 1]; + return $default; } $result = self::compactLanguages($result); diff --git a/src/Protocol/Relay.php b/src/Protocol/Relay.php index 1b9c7a0563..ae0ad949d0 100644 --- a/src/Protocol/Relay.php +++ b/src/Protocol/Relay.php @@ -188,7 +188,7 @@ class Relay } } - if (empty($detected)) { + if (empty($detected) && empty($languages)) { $detected = ['un']; }