Constant for undeterminded language

This commit is contained in:
Michael 2024-01-15 06:20:49 +00:00
parent 7a13d8b8ac
commit 9075d7f37d
5 changed files with 11 additions and 7 deletions

View File

@ -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
{

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)) {