From: Michael Date: Mon, 15 Jan 2024 06:20:49 +0000 (+0000) Subject: Constant for undeterminded language X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=56255f58b8ad01b49b49254f865bbeec0cd49fc2;p=friendica.git Constant for undeterminded language --- diff --git a/src/Content/Conversation/Entity/Timeline.php b/src/Content/Conversation/Entity/Timeline.php index 914f3795c6..a27d9fb98f 100644 --- a/src/Content/Conversation/Entity/Timeline.php +++ b/src/Content/Conversation/Entity/Timeline.php @@ -35,7 +35,7 @@ namespace Friendica\Content\Conversation\Entity; * @property-read array $languages Channel languages * @property-read int $circle Circle or timeline this channel is based on * @property-read bool $publish Publish the channel - * @property-read bool $valid Signalizes that the search condiions are valid + * @property-read bool $valid Indicates that the search conditions are valid */ class Timeline extends \Friendica\BaseEntity { diff --git a/src/Core/L10n.php b/src/Core/L10n.php index d00cd0df5c..2b1e7b9e4b 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -65,6 +65,9 @@ class L10n 'zh-cn' => '简体中文', ]; + /** @var string Undetermined language */ + const UNDETERMINED_LANGUAGE = 'un'; + /** * A string indicating the current language used for translation: * - Two-letter ISO 639-1 code. @@ -438,7 +441,7 @@ class L10n // In ISO 639-2 undetermined languages have got the code "und". // There is no official code for ISO 639-1, but "un" is not assigned to any language. - $languages = ['un' => $this->t('Undetermined')]; + $languages = [self::UNDETERMINED_LANGUAGE => $this->t('Undetermined')]; foreach ($this->getDetectableLanguages() as $code) { $code = $this->toISO6391($code); diff --git a/src/Model/Item.php b/src/Model/Item.php index f3fab4d965..91e7e8613e 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -28,6 +28,7 @@ use Friendica\Content\Post\Entity\PostMedia; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Hook; +use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; @@ -2124,7 +2125,7 @@ class Item */ public static function getLanguageArray(string $body, int $count, int $uri_id = 0, int $author_id = 0, array $default = []): array { - $default = $default ?: ['un' => 1]; + $default = $default ?: [L10n::UNDETERMINED_LANGUAGE => 1]; $searchtext = BBCode::toSearchText($body, $uri_id); @@ -2274,7 +2275,7 @@ class Item foreach (json_decode($item['language'], true) as $language => $reliability) { $code = DI::l10n()->toISO6391($language); - if ($code == 'un') { + if ($code == L10n::UNDETERMINED_LANGUAGE) { $native = $language = DI::l10n()->t('Undetermined'); } else { $native = $iso639->nativeByCode1($code); diff --git a/src/Model/User.php b/src/Model/User.php index c60f8d7b28..a13b45e23b 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -645,7 +645,7 @@ class User } if (!DI::config()->get('system', 'relay_deny_undetected_language')) { - $languages['un'] = 'un'; + $languages[L10n::UNDETERMINED_LANGUAGE] = L10n::UNDETERMINED_LANGUAGE; } ksort($languages); diff --git a/src/Protocol/Relay.php b/src/Protocol/Relay.php index ae0ad949d0..9b1911315a 100644 --- a/src/Protocol/Relay.php +++ b/src/Protocol/Relay.php @@ -23,7 +23,7 @@ namespace Friendica\Protocol; use Friendica\Content\Smilies; use Friendica\Content\Text\BBCode; -use Friendica\Core\Cache\Enum\Duration; +use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\DBA; @@ -189,7 +189,7 @@ class Relay } if (empty($detected) && empty($languages)) { - $detected = ['un']; + $detected = [L10n::UNDETERMINED_LANGUAGE]; } if (empty($body) || Smilies::isEmojiPost($body)) {