From: Michael Date: Fri, 3 Nov 2023 05:32:57 +0000 (+0000) Subject: Use "toISO6391" instead of "substr" X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a7ab14b3b3a42e58ef29392c21bf531adb187248;p=friendica.git Use "toISO6391" instead of "substr" --- diff --git a/src/Core/L10n.php b/src/Core/L10n.php index 87d11de6fb..328fb0307d 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -442,7 +442,7 @@ class L10n $code = $this->toISO6391($code); $native = $iso639->nativeByCode1($code); $language = $iso639->languageByCode1($code); - if ($native != $iso639->languageByCode1($code) && $international) { + if ($native != $language && $international) { $languages[$code] = $this->t('%s (%s)', $native, $language); } else { $languages[$code] = $native; diff --git a/src/Model/Item.php b/src/Model/Item.php index e505e76d97..518edecb4e 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2162,7 +2162,15 @@ class Item $used_languages = ''; foreach (json_decode($item['language'], true) as $language => $reliability) { - $used_languages .= $iso639->nativeByCode1(substr($language, 0, 2)) . ' (' . $iso639->languageByCode1(substr($language, 0, 2)) . ' - ' . $language . "): " . number_format($reliability, 5) . '\n'; + $code = DI::l10n()->toISO6391($language); + + $native = $iso639->nativeByCode1($code); + $language = $iso639->languageByCode1($code); + if ($native != $language) { + $used_languages .= DI::l10n()->t('%s (%s - %s): %s', $native, $language, $code, number_format($reliability, 5)) . '\n'; + } else { + $used_languages .= DI::l10n()->t('%s (%s): %s', $native, $code, number_format($reliability, 5)) . '\n'; + } } $used_languages = DI::l10n()->t('Detected languages in this post:\n%s', $used_languages); return $used_languages; diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index acafb66ab6..525cb32c30 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -242,7 +242,7 @@ class Temporal // First day of the week (0 = Sunday) $firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week', 0); - $lang = substr(DI::l10n()->getCurrentLang(), 0, 2); + $lang = DI::l10n()->toISO6391(DI::l10n()->getCurrentLang()); // Check if the detected language is supported by the picker if (!in_array($lang,