Keep the public site readable after import (nbsp, highlighter, wrapping code, compact pager) and finish the admin extras already in this tree: sticky levels, preview, page cache, and live llms.txt. Co-authored-by: Cursor <cursoragent@cursor.com>
92 lines
2.2 KiB
PHP
92 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use Filament\Pages\Page;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
class Languages extends Page
|
|
{
|
|
protected static \UnitEnum|string|null $navigationGroup = '管理';
|
|
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-language';
|
|
|
|
protected static ?string $navigationLabel = '语言';
|
|
|
|
protected static ?string $title = '语言';
|
|
|
|
protected static ?string $slug = 'languages';
|
|
|
|
protected static ?int $navigationSort = 21;
|
|
|
|
protected string $view = 'filament.pages.languages';
|
|
|
|
/**
|
|
* @return array{
|
|
* locale: string,
|
|
* fallback: string,
|
|
* faker: string,
|
|
* app_files: list<string>,
|
|
* filament_locales: list<string>,
|
|
* content_i18n: bool
|
|
* }
|
|
*/
|
|
public function getInfoProperty(): array
|
|
{
|
|
return [
|
|
'locale' => app()->getLocale(),
|
|
'fallback' => (string) config('app.fallback_locale'),
|
|
'faker' => (string) config('app.faker_locale'),
|
|
'app_files' => $this->appLanguageFiles(),
|
|
'filament_locales' => $this->filamentLocales(),
|
|
'content_i18n' => false,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
private function appLanguageFiles(): array
|
|
{
|
|
$found = [];
|
|
|
|
foreach (File::glob(lang_path('*.json')) as $file) {
|
|
$found[] = basename((string) $file, '.json');
|
|
}
|
|
|
|
foreach (File::directories(lang_path()) as $directory) {
|
|
$name = basename($directory);
|
|
if ($name === 'vendor') {
|
|
continue;
|
|
}
|
|
$found[] = $name;
|
|
}
|
|
|
|
$found = array_values(array_unique($found));
|
|
sort($found);
|
|
|
|
return $found;
|
|
}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
private function filamentLocales(): array
|
|
{
|
|
$path = lang_path('vendor/filament');
|
|
if (! File::isDirectory($path)) {
|
|
return [];
|
|
}
|
|
|
|
$locales = array_map(
|
|
static fn (string $directory): string => basename($directory),
|
|
File::directories($path)
|
|
);
|
|
sort($locales);
|
|
|
|
return $locales;
|
|
}
|
|
}
|