]> git.mxchange.org Git - friendica.git/commitdiff
Use "toISO6391" instead of "substr"
authorMichael <heluecht@pirati.ca>
Fri, 3 Nov 2023 05:32:57 +0000 (05:32 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 3 Nov 2023 05:32:57 +0000 (05:32 +0000)
src/Core/L10n.php
src/Model/Item.php
src/Util/Temporal.php

index 87d11de6fba466a4078f1ff319b00f805fff5226..328fb0307df2141ac81de73e1c60127c0aa6b5b2 100644 (file)
@@ -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;
index e505e76d97de699e170cbb7013e995da8361d99a..518edecb4e7f0d78b8f79167ed8d43e5b748f0f5 100644 (file)
@@ -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;
index acafb66ab60538949a9b0cacd2540b19b2bc7382..525cb32c30889a863de9158997523507b0dd4150 100644 (file)
@@ -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,