Use php locale instead

This commit is contained in:
Lance Pioch 2024-03-23 10:39:19 -04:00
parent 62d56099d7
commit 18ad46fe16
2 changed files with 4 additions and 12 deletions

View File

@ -2,13 +2,11 @@
namespace App\Traits\Helpers;
use Matriphe\ISO639\ISO639;
use Locale;
use Illuminate\Filesystem\Filesystem;
trait AvailableLanguages
{
private ?ISO639 $iso639 = null;
private ?Filesystem $filesystem = null;
/**
@ -19,7 +17,8 @@ trait AvailableLanguages
{
return collect($this->getFilesystemInstance()->directories(base_path('lang')))->mapWithKeys(function ($path) use ($localize) {
$code = basename($path);
$value = $localize ? $this->getIsoInstance()->nativeByCode1($code) : $this->getIsoInstance()->languageByCode1($code);
$value = Locale::getDisplayName($code, app()->currentLocale());
return [$code => title_case($value)];
})->toArray();
@ -32,12 +31,4 @@ trait AvailableLanguages
{
return $this->filesystem = $this->filesystem ?: app()->make(Filesystem::class);
}
/**
* Return an instance of the ISO639 class for generating names.
*/
private function getIsoInstance(): ISO639
{
return $this->iso639 = $this->iso639 ?: app()->make(ISO639::class);
}
}

View File

@ -3,6 +3,7 @@
"description": "The free, open-source game management panel. Supporting Minecraft, Spigot, BungeeCord, and SRCDS servers.",
"require": {
"php": "^8.2",
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-pdo": "*",