From 3650feb2567ff5285db4fd987c3bb56d9d16602c Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 19 Sep 2022 12:46:28 +0200 Subject: [PATCH] "Count" parameter added --- src/Model/Item.php | 6 +++--- src/Protocol/Relay.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 3fb8e52a50..89c972ea57 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1870,7 +1870,7 @@ class Item return ''; } - $languages = self::getLanguageArray(trim($item['title'] . "\n" . $item['body'])); + $languages = self::getLanguageArray(trim($item['title'] . "\n" . $item['body']), 3); if (empty($languages)) { return ''; } @@ -1878,7 +1878,7 @@ class Item return json_encode($languages); } - public static function getLanguageArray(string $body): array + public static function getLanguageArray(string $body, int $count): array { // Convert attachments to links $naked_body = BBCode::removeAttachment($body); @@ -1908,7 +1908,7 @@ class Item $availableLanguages['fa'] = 'fa'; $ld = new Language(array_keys($availableLanguages)); - return $ld->detect($naked_body)->limit(0, 3)->close() ?: []; + return $ld->detect($naked_body)->limit(0, $count)->close() ?: []; } /** diff --git a/src/Protocol/Relay.php b/src/Protocol/Relay.php index f427d85b67..ff82762507 100644 --- a/src/Protocol/Relay.php +++ b/src/Protocol/Relay.php @@ -129,7 +129,7 @@ class Relay } $languages = []; - foreach (Item::getLanguageArray($body) as $language => $reliability) { + foreach (Item::getLanguageArray($body, 10) as $language => $reliability) { if ($reliability > 0) { $languages[] = $language; }