Files
pterodactyl-panel/app/Traits/Helpers/AvailableLanguages.php
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

32 lines
864 B
PHP

<?php
declare(strict_types=1);
namespace Pterodactyl\Traits\Helpers;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Locale;
use Pterodactyl\Support\JsonValueGuard;
trait AvailableLanguages
{
/**
* Return all the available languages on the Panel based on those
* that are present in the language folder.
*
* @return array<string, string> language code mapped to its display name
*/
public function getAvailableLanguages(bool $localize = false): array
{
$languages = [];
foreach (JsonValueGuard::stringList(File::directories(resource_path('lang'))) as $path) {
$code = basename($path);
$value = Locale::getDisplayLanguage($code, $localize ? $code : 'en') ?: $code;
$languages[$code] = Str::title($value);
}
return $languages;
}
}