mirror of
https://github.com/friendica/friendica
synced 2024-12-23 08:40:16 +00:00
Merge pull request #9380 from annando/Improved-language-detection/display
Display language name / only search for available languages
This commit is contained in:
commit
b63d037967
4 changed files with 630 additions and 559 deletions
|
@ -64,7 +64,8 @@
|
|||
"npm-asset/moment": "^2.24",
|
||||
"npm-asset/perfect-scrollbar": "0.6.16",
|
||||
"npm-asset/textcomplete": "^0.18.2",
|
||||
"npm-asset/typeahead.js": "^0.11.1"
|
||||
"npm-asset/typeahead.js": "^0.11.1",
|
||||
"matriphe/iso-639": "^1.2"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
|
|
46
composer.lock
generated
46
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "744827edc867db110530c378e051db9b",
|
||||
"content-hash": "fd22bd8c29dcea3d6b6eeb117d79af52",
|
||||
"packages": [
|
||||
{
|
||||
"name": "asika/simple-console",
|
||||
|
@ -877,6 +877,50 @@
|
|||
],
|
||||
"time": "2013-10-27T16:25:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "matriphe/iso-639",
|
||||
"version": "1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/matriphe/php-iso-639.git",
|
||||
"reference": "0245d844daeefdd22a54b47103ffdb0e03c323e1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/matriphe/php-iso-639/zipball/0245d844daeefdd22a54b47103ffdb0e03c323e1",
|
||||
"reference": "0245d844daeefdd22a54b47103ffdb0e03c323e1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.7"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Matriphe\\ISO639\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Muhammad Zamroni",
|
||||
"email": "halo@matriphe.com"
|
||||
}
|
||||
],
|
||||
"description": "PHP library to convert ISO-639-1 code to language name.",
|
||||
"keywords": [
|
||||
"639",
|
||||
"iso",
|
||||
"iso-639",
|
||||
"lang",
|
||||
"language",
|
||||
"laravel"
|
||||
],
|
||||
"time": "2017-07-19T15:11:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "michelf/php-markdown",
|
||||
"version": "1.9.0",
|
||||
|
|
|
@ -2494,7 +2494,7 @@ class Item
|
|||
// Remove possibly remaining links
|
||||
$naked_body = preg_replace(Strings::autoLinkRegEx(), '', $naked_body);
|
||||
|
||||
$ld = new Language();
|
||||
$ld = new Language(DI::l10n()->getAvailableLanguages());
|
||||
$languages = $ld->detect($naked_body)->limit(0, 3)->close();
|
||||
if (is_array($languages)) {
|
||||
return json_encode($languages);
|
||||
|
@ -2505,11 +2505,13 @@ class Item
|
|||
|
||||
public static function getLanguageMessage(array $item)
|
||||
{
|
||||
$iso639 = new \Matriphe\ISO639\ISO639;
|
||||
|
||||
$used_languages = '';
|
||||
foreach (json_decode($item['language'], true) as $language => $reliability) {
|
||||
$used_languages .= $language . ": " . number_format($reliability, 5) . '\n';
|
||||
$used_languages .= $iso639->languageByCode1($language) . ' (' . $language . "): " . number_format($reliability, 5) . '\n';
|
||||
}
|
||||
$used_languages = DI::l10n()->t('Used languages in this post:\n%s', $used_languages);
|
||||
$used_languages = DI::l10n()->t('Detected languages in this post:\n%s', $used_languages);
|
||||
return $used_languages;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue