Improved handling for undeterminded languages

This commit is contained in:
Michael 2024-01-07 10:11:52 +00:00
parent 6cd0e1e35f
commit 6e830f7774
4 changed files with 79 additions and 72 deletions

View File

@ -436,7 +436,9 @@ class L10n
{ {
$iso639 = new \Matriphe\ISO639\ISO639; $iso639 = new \Matriphe\ISO639\ISO639;
$languages = ['un' => $this->t('Undeteced Language')]; // 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')];
foreach ($this->getDetectableLanguages() as $code) { foreach ($this->getDetectableLanguages() as $code) {
$code = $this->toISO6391($code); $code = $this->toISO6391($code);

View File

@ -2107,7 +2107,7 @@ class Item
} }
if (empty($searchtext)) { if (empty($searchtext)) {
return []; return ['un' => 1];
} }
$ld = new Language(DI::l10n()->getDetectableLanguages()); $ld = new Language(DI::l10n()->getDetectableLanguages());
@ -2130,6 +2130,10 @@ class Item
} }
} }
if (empty($result)) {
return ['un' => 1];
}
$result = self::compactLanguages($result); $result = self::compactLanguages($result);
arsort($result); arsort($result);
@ -2240,8 +2244,13 @@ class Item
foreach (json_decode($item['language'], true) as $language => $reliability) { foreach (json_decode($item['language'], true) as $language => $reliability) {
$code = DI::l10n()->toISO6391($language); $code = DI::l10n()->toISO6391($language);
$native = $iso639->nativeByCode1($code); if ($code == 'un') {
$language = $iso639->languageByCode1($code); $native = $language = DI::l10n()->t('Undetermined');
} else {
$native = $iso639->nativeByCode1($code);
$language = $iso639->languageByCode1($code);
}
if ($native != $language) { if ($native != $language) {
$used_languages .= DI::l10n()->t('%s (%s - %s): %s', $native, $language, $code, number_format($reliability, 5)) . '\n'; $used_languages .= DI::l10n()->t('%s (%s - %s): %s', $native, $language, $code, number_format($reliability, 5)) . '\n';
} else { } else {

View File

@ -432,12 +432,8 @@ class Timeline extends BaseModule
$conditions = []; $conditions = [];
$languages = $languages ?: User::getWantedLanguages($uid); $languages = $languages ?: User::getWantedLanguages($uid);
foreach ($languages as $language) { foreach ($languages as $language) {
if ($language == 'un') { $conditions[] = "JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?";
$conditions[] = "`language` IS NULL"; $condition[] = $language;
} else {
$conditions[] = "JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?";
$condition[] = $language;
}
} }
if (!empty($conditions)) { if (!empty($conditions)) {
$condition[0] .= " AND (" . implode(' OR ', $conditions) . ")"; $condition[0] .= " AND (" . implode(' OR ', $conditions) . ")";

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2024.03-dev\n" "Project-Id-Version: 2024.03-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-06 21:56+0000\n" "POT-Creation-Date: 2024-01-07 10:10+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -1766,7 +1766,7 @@ msgstr ""
msgid "Create new group" msgid "Create new group"
msgstr "" msgstr ""
#: src/Content/Item.php:332 src/Model/Item.php:3195 #: src/Content/Item.php:332 src/Model/Item.php:3204
msgid "event" msgid "event"
msgstr "" msgstr ""
@ -1774,7 +1774,7 @@ msgstr ""
msgid "status" msgid "status"
msgstr "" msgstr ""
#: src/Content/Item.php:341 src/Model/Item.php:3197 #: src/Content/Item.php:341 src/Model/Item.php:3206
#: src/Module/Post/Tag/Add.php:123 #: src/Module/Post/Tag/Add.php:123
msgid "photo" msgid "photo"
msgstr "" msgstr ""
@ -2187,8 +2187,8 @@ msgid ""
"<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s" "<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:994 src/Model/Item.php:3928 #: src/Content/Text/BBCode.php:994 src/Model/Item.php:3937
#: src/Model/Item.php:3934 src/Model/Item.php:3935 #: src/Model/Item.php:3943 src/Model/Item.php:3944
msgid "Link to source" msgid "Link to source"
msgstr "" msgstr ""
@ -2851,167 +2851,167 @@ msgstr ""
msgid "Could not connect to database." msgid "Could not connect to database."
msgstr "" msgstr ""
#: src/Core/L10n.php:439 #: src/Core/L10n.php:441 src/Model/Item.php:2248
msgid "Undeteced Language" msgid "Undetermined"
msgstr "" msgstr ""
#: src/Core/L10n.php:446 #: src/Core/L10n.php:448
#, php-format #, php-format
msgid "%s (%s)" msgid "%s (%s)"
msgstr "" msgstr ""
#: src/Core/L10n.php:494 src/Model/Event.php:430 #: src/Core/L10n.php:496 src/Model/Event.php:430
#: src/Module/Settings/Display.php:284 #: src/Module/Settings/Display.php:284
msgid "Monday" msgid "Monday"
msgstr "" msgstr ""
#: src/Core/L10n.php:494 src/Model/Event.php:431 #: src/Core/L10n.php:496 src/Model/Event.php:431
#: src/Module/Settings/Display.php:285 #: src/Module/Settings/Display.php:285
msgid "Tuesday" msgid "Tuesday"
msgstr "" msgstr ""
#: src/Core/L10n.php:494 src/Model/Event.php:432 #: src/Core/L10n.php:496 src/Model/Event.php:432
#: src/Module/Settings/Display.php:286 #: src/Module/Settings/Display.php:286
msgid "Wednesday" msgid "Wednesday"
msgstr "" msgstr ""
#: src/Core/L10n.php:494 src/Model/Event.php:433 #: src/Core/L10n.php:496 src/Model/Event.php:433
#: src/Module/Settings/Display.php:287 #: src/Module/Settings/Display.php:287
msgid "Thursday" msgid "Thursday"
msgstr "" msgstr ""
#: src/Core/L10n.php:494 src/Model/Event.php:434 #: src/Core/L10n.php:496 src/Model/Event.php:434
#: src/Module/Settings/Display.php:288 #: src/Module/Settings/Display.php:288
msgid "Friday" msgid "Friday"
msgstr "" msgstr ""
#: src/Core/L10n.php:494 src/Model/Event.php:435 #: src/Core/L10n.php:496 src/Model/Event.php:435
#: src/Module/Settings/Display.php:289 #: src/Module/Settings/Display.php:289
msgid "Saturday" msgid "Saturday"
msgstr "" msgstr ""
#: src/Core/L10n.php:494 src/Model/Event.php:429 #: src/Core/L10n.php:496 src/Model/Event.php:429
#: src/Module/Settings/Display.php:283 #: src/Module/Settings/Display.php:283
msgid "Sunday" msgid "Sunday"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Model/Event.php:450 #: src/Core/L10n.php:500 src/Model/Event.php:450
msgid "January" msgid "January"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Model/Event.php:451 #: src/Core/L10n.php:500 src/Model/Event.php:451
msgid "February" msgid "February"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Model/Event.php:452 #: src/Core/L10n.php:500 src/Model/Event.php:452
msgid "March" msgid "March"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Model/Event.php:453 #: src/Core/L10n.php:500 src/Model/Event.php:453
msgid "April" msgid "April"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Core/L10n.php:517 src/Model/Event.php:441 #: src/Core/L10n.php:500 src/Core/L10n.php:519 src/Model/Event.php:441
msgid "May" msgid "May"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Model/Event.php:454 #: src/Core/L10n.php:500 src/Model/Event.php:454
msgid "June" msgid "June"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Model/Event.php:455 #: src/Core/L10n.php:500 src/Model/Event.php:455
msgid "July" msgid "July"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Model/Event.php:456 #: src/Core/L10n.php:500 src/Model/Event.php:456
msgid "August" msgid "August"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Model/Event.php:457 #: src/Core/L10n.php:500 src/Model/Event.php:457
msgid "September" msgid "September"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Model/Event.php:458 #: src/Core/L10n.php:500 src/Model/Event.php:458
msgid "October" msgid "October"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Model/Event.php:459 #: src/Core/L10n.php:500 src/Model/Event.php:459
msgid "November" msgid "November"
msgstr "" msgstr ""
#: src/Core/L10n.php:498 src/Model/Event.php:460 #: src/Core/L10n.php:500 src/Model/Event.php:460
msgid "December" msgid "December"
msgstr "" msgstr ""
#: src/Core/L10n.php:513 src/Model/Event.php:422 #: src/Core/L10n.php:515 src/Model/Event.php:422
msgid "Mon" msgid "Mon"
msgstr "" msgstr ""
#: src/Core/L10n.php:513 src/Model/Event.php:423 #: src/Core/L10n.php:515 src/Model/Event.php:423
msgid "Tue" msgid "Tue"
msgstr "" msgstr ""
#: src/Core/L10n.php:513 src/Model/Event.php:424 #: src/Core/L10n.php:515 src/Model/Event.php:424
msgid "Wed" msgid "Wed"
msgstr "" msgstr ""
#: src/Core/L10n.php:513 src/Model/Event.php:425 #: src/Core/L10n.php:515 src/Model/Event.php:425
msgid "Thu" msgid "Thu"
msgstr "" msgstr ""
#: src/Core/L10n.php:513 src/Model/Event.php:426 #: src/Core/L10n.php:515 src/Model/Event.php:426
msgid "Fri" msgid "Fri"
msgstr "" msgstr ""
#: src/Core/L10n.php:513 src/Model/Event.php:427 #: src/Core/L10n.php:515 src/Model/Event.php:427
msgid "Sat" msgid "Sat"
msgstr "" msgstr ""
#: src/Core/L10n.php:513 src/Model/Event.php:421 #: src/Core/L10n.php:515 src/Model/Event.php:421
msgid "Sun" msgid "Sun"
msgstr "" msgstr ""
#: src/Core/L10n.php:517 src/Model/Event.php:437 #: src/Core/L10n.php:519 src/Model/Event.php:437
msgid "Jan" msgid "Jan"
msgstr "" msgstr ""
#: src/Core/L10n.php:517 src/Model/Event.php:438 #: src/Core/L10n.php:519 src/Model/Event.php:438
msgid "Feb" msgid "Feb"
msgstr "" msgstr ""
#: src/Core/L10n.php:517 src/Model/Event.php:439 #: src/Core/L10n.php:519 src/Model/Event.php:439
msgid "Mar" msgid "Mar"
msgstr "" msgstr ""
#: src/Core/L10n.php:517 src/Model/Event.php:440 #: src/Core/L10n.php:519 src/Model/Event.php:440
msgid "Apr" msgid "Apr"
msgstr "" msgstr ""
#: src/Core/L10n.php:517 src/Model/Event.php:442 #: src/Core/L10n.php:519 src/Model/Event.php:442
msgid "Jun" msgid "Jun"
msgstr "" msgstr ""
#: src/Core/L10n.php:517 src/Model/Event.php:443 #: src/Core/L10n.php:519 src/Model/Event.php:443
msgid "Jul" msgid "Jul"
msgstr "" msgstr ""
#: src/Core/L10n.php:517 src/Model/Event.php:444 #: src/Core/L10n.php:519 src/Model/Event.php:444
msgid "Aug" msgid "Aug"
msgstr "" msgstr ""
#: src/Core/L10n.php:517 #: src/Core/L10n.php:519
msgid "Sep" msgid "Sep"
msgstr "" msgstr ""
#: src/Core/L10n.php:517 src/Model/Event.php:446 #: src/Core/L10n.php:519 src/Model/Event.php:446
msgid "Oct" msgid "Oct"
msgstr "" msgstr ""
#: src/Core/L10n.php:517 src/Model/Event.php:447 #: src/Core/L10n.php:519 src/Model/Event.php:447
msgid "Nov" msgid "Nov"
msgstr "" msgstr ""
#: src/Core/L10n.php:517 src/Model/Event.php:448 #: src/Core/L10n.php:519 src/Model/Event.php:448
msgid "Dec" msgid "Dec"
msgstr "" msgstr ""
@ -3409,91 +3409,91 @@ msgstr ""
msgid "Happy Birthday %s" msgid "Happy Birthday %s"
msgstr "" msgstr ""
#: src/Model/Item.php:2246 #: src/Model/Item.php:2255
#, php-format #, php-format
msgid "%s (%s - %s): %s" msgid "%s (%s - %s): %s"
msgstr "" msgstr ""
#: src/Model/Item.php:2248 #: src/Model/Item.php:2257
#, php-format #, php-format
msgid "%s (%s): %s" msgid "%s (%s): %s"
msgstr "" msgstr ""
#: src/Model/Item.php:2251 #: src/Model/Item.php:2260
#, php-format #, php-format
msgid "Detected languages in this post:\\n%s" msgid "Detected languages in this post:\\n%s"
msgstr "" msgstr ""
#: src/Model/Item.php:3199 #: src/Model/Item.php:3208
msgid "activity" msgid "activity"
msgstr "" msgstr ""
#: src/Model/Item.php:3201 #: src/Model/Item.php:3210
msgid "comment" msgid "comment"
msgstr "" msgstr ""
#: src/Model/Item.php:3204 src/Module/Post/Tag/Add.php:123 #: src/Model/Item.php:3213 src/Module/Post/Tag/Add.php:123
msgid "post" msgid "post"
msgstr "" msgstr ""
#: src/Model/Item.php:3374 #: src/Model/Item.php:3383
#, php-format #, php-format
msgid "%s is blocked" msgid "%s is blocked"
msgstr "" msgstr ""
#: src/Model/Item.php:3376 #: src/Model/Item.php:3385
#, php-format #, php-format
msgid "%s is ignored" msgid "%s is ignored"
msgstr "" msgstr ""
#: src/Model/Item.php:3378 #: src/Model/Item.php:3387
#, php-format #, php-format
msgid "Content from %s is collapsed" msgid "Content from %s is collapsed"
msgstr "" msgstr ""
#: src/Model/Item.php:3382 #: src/Model/Item.php:3391
#, php-format #, php-format
msgid "Content warning: %s" msgid "Content warning: %s"
msgstr "" msgstr ""
#: src/Model/Item.php:3835 #: src/Model/Item.php:3844
msgid "bytes" msgid "bytes"
msgstr "" msgstr ""
#: src/Model/Item.php:3866 #: src/Model/Item.php:3875
#, php-format #, php-format
msgid "%2$s (%3$d%%, %1$d vote)" msgid "%2$s (%3$d%%, %1$d vote)"
msgid_plural "%2$s (%3$d%%, %1$d votes)" msgid_plural "%2$s (%3$d%%, %1$d votes)"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:3868 #: src/Model/Item.php:3877
#, php-format #, php-format
msgid "%2$s (%1$d vote)" msgid "%2$s (%1$d vote)"
msgid_plural "%2$s (%1$d votes)" msgid_plural "%2$s (%1$d votes)"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:3873 #: src/Model/Item.php:3882
#, php-format #, php-format
msgid "%d voter. Poll end: %s" msgid "%d voter. Poll end: %s"
msgid_plural "%d voters. Poll end: %s" msgid_plural "%d voters. Poll end: %s"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:3875 #: src/Model/Item.php:3884
#, php-format #, php-format
msgid "%d voter." msgid "%d voter."
msgid_plural "%d voters." msgid_plural "%d voters."
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:3877 #: src/Model/Item.php:3886
#, php-format #, php-format
msgid "Poll end: %s" msgid "Poll end: %s"
msgstr "" msgstr ""
#: src/Model/Item.php:3911 src/Model/Item.php:3912 #: src/Model/Item.php:3920 src/Model/Item.php:3921
msgid "View on separate page" msgid "View on separate page"
msgstr "" msgstr ""