]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Merge pull request #13611 from annando/languages
[friendica.git] / src / Model / Item.php
index e505e76d97de699e170cbb7013e995da8361d99a..18b56215ce39ca9a680e64fc062f693c84dca392 100644 (file)
@@ -117,7 +117,7 @@ class Item
        const DELIVER_FIELDLIST = [
                'uid', 'id', 'parent', 'uri-id', 'uri', 'thr-parent', 'parent-uri', 'guid',
                'parent-guid', 'conversation', 'received', 'created', 'edited', 'verb', 'object-type', 'object', 'target',
-               'private', 'title', 'body', 'raw-body', 'location', 'coord', 'app',
+               'private', 'title', 'body', 'raw-body', 'language', 'location', 'coord', 'app',
                'inform', 'deleted', 'extid', 'post-type', 'post-reason', 'gravity',
                'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
                'author-id', 'author-addr', 'author-link', 'author-name', 'author-avatar', 'owner-id', 'owner-link', 'contact-uid',
@@ -1484,6 +1484,10 @@ class Item
         */
        private static function setOwnerforResharedItem(array $item)
        {
+               if ($item['uid'] == 0) {
+                       return;
+               }
+
                $parent = Post::selectFirst(
                        ['id', 'causer-id', 'owner-id', 'author-id', 'author-link', 'origin', 'post-reason'],
                        ['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid']]
@@ -2162,7 +2166,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;