Skip to content

Commit

Permalink
wip translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-the-Diamond committed Jan 7, 2025
1 parent 39ffa9e commit 16acb6a
Show file tree
Hide file tree
Showing 24 changed files with 621 additions and 330 deletions.
5 changes: 5 additions & 0 deletions app/Locale/Models/StaticCountry.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ class StaticCountry extends Model
'phone_number_formatting' => 'array',
'currency_format' => 'array',
];

public function locales()
{
return $this->hasMany(StaticLocale::class);
}
}
5 changes: 5 additions & 0 deletions app/Locale/Models/StaticLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ class StaticLanguage extends Model
protected $casts = [
'exonyms' => 'array',
];

public function locales()
{
return $this->hasMany(StaticLocale::class);
}
}
36 changes: 36 additions & 0 deletions app/Locale/Models/StaticLocale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace App\Locale\Models;

use Illuminate\Database\Eloquent\Model;
use Moox\Core\Traits\Base\BaseInModel;
use Moox\Core\Traits\Simple\SingleSimpleInModel;

class StaticLocale extends Model
{
use BaseInModel, SingleSimpleInModel;

protected $table = 'static_locales';

protected $fillable = [
'language_id',
'country_id',
'locale',
'name',
'is_official_language'
];

public function language()
{
return $this->belongsTo(StaticLanguage::class);
}

public function country()
{
return $this->belongsTo(StaticCountry::class);
}

protected $casts = [];
}
37 changes: 37 additions & 0 deletions app/Locale/Plugins/StaticLocalePlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace App\Locale\Plugins;

use App\Locale\Resources\StaticLocaleResource;
use Filament\Contracts\Plugin;
use Filament\Panel;
use Filament\Support\Concerns\EvaluatesClosures;

class StaticLocalePlugin implements Plugin
{
use EvaluatesClosures;

public function getId(): string
{
return 'staticlocale';
}

public function register(Panel $panel): void
{
$panel->resources([
StaticLocaleResource::class,
]);
}

public function boot(Panel $panel): void
{
//
}

public static function make(): static
{
return app(static::class);
}
}
2 changes: 1 addition & 1 deletion app/Locale/Presets/LocalePreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function initializePreset(): void
label: 'language',
description: 'Language to Locale',
nullable: false,
relatedModel: \App\Locale\Locale\Models\StaticLanguage::class,
relatedModel: \App\Locale\Models\StaticLanguage::class,
),
new Relationship(
name: 'country',
Expand Down
326 changes: 41 additions & 285 deletions app/Locale/Resources/StaticCountryResource.php

Large diffs are not rendered by default.

50 changes: 24 additions & 26 deletions app/Locale/Resources/StaticLanguageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public static function getBreadcrumb(): string

public static function getNavigationGroup(): ?string
{
return config('app.navigation_group');
return config('static-language.navigation_group');
}

public static function getNavigationSort(): ?int
{
return config('navigation_sort') + 1;
return config('static-language.navigation_sort') + 1;
}

public static function form(Form $form): Form
Expand All @@ -68,22 +68,22 @@ public static function form(Form $form): Form
Section::make()
->schema([
TextInput::make('alpha2')
->label('Alpha-2 Code')
->label(__('locale.alpha2'))
->maxLength(255)->required(),
TextInput::make('alpha3_b')
->label('Alpha-3 Bibliographic Code')
->label(__('locale.alpha3_b'))
->maxLength(255)->nullable(),
TextInput::make('alpha3_t')
->label('Alpha-3 Terminology Code')
->label(__('locale.alpha3_t'))
->maxLength(255)->nullable(),
TextInput::make('common_name')
->label('Common Name')
->label(__('locale.common_name'))
->maxLength(255)->required(),
TextInput::make('native_name')
->label('Native Name')
->label(__('locale.native_name'))
->maxLength(255)->nullable(),
KeyValue::make('exonyms')
->label('Exonyms'),
->label(__('locale.exonyms')),
]),
])
->columnSpan(['lg' => 2]),
Expand All @@ -96,17 +96,15 @@ public static function form(Form $form): Form
Section::make('')
->schema([
Select::make('script')
->label('Script')
->placeholder(__('core::core.type'))
->options(['Latin' => 'Latin', 'Cyrillic' => 'Cyrillic', 'Arabic' => 'Arabic', 'Devanagari' => 'Devanagari', 'Other' => 'Other'])
->label(__('entities/static-language.script'))
->options(__('entities/static-language.script_options'))
->required(),
]),
Section::make('')
->schema([
Select::make('direction')
->label('Direction')
->placeholder(__('core::core.type'))
->options(['LTR' => 'LTR', 'RTL' => 'RTL'])
->label(__('entities/static-language.direction'))
->options(__('entities/static-language.direction_options'))
->required(),
]),
])
Expand Down Expand Up @@ -141,15 +139,15 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['alpha2'],
fn (Builder $query, $value): Builder => $query->where('alpha2', 'like', "%{$value}%"),
fn(Builder $query, $value): Builder => $query->where('alpha2', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['alpha2']) {
return null;
}

return 'Alpha-2 Code: '.$data['alpha2'];
return 'Alpha-2 Code: ' . $data['alpha2'];
}),
Filter::make('alpha3_b')
->form([
Expand All @@ -160,15 +158,15 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['alpha3_b'],
fn (Builder $query, $value): Builder => $query->where('alpha3_b', 'like', "%{$value}%"),
fn(Builder $query, $value): Builder => $query->where('alpha3_b', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['alpha3_b']) {
return null;
}

return 'Alpha-3 Bibliographic Code: '.$data['alpha3_b'];
return 'Alpha-3 Bibliographic Code: ' . $data['alpha3_b'];
}),
Filter::make('alpha3_t')
->form([
Expand All @@ -179,15 +177,15 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['alpha3_t'],
fn (Builder $query, $value): Builder => $query->where('alpha3_t', 'like', "%{$value}%"),
fn(Builder $query, $value): Builder => $query->where('alpha3_t', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['alpha3_t']) {
return null;
}

return 'Alpha-3 Terminology Code: '.$data['alpha3_t'];
return 'Alpha-3 Terminology Code: ' . $data['alpha3_t'];
}),
Filter::make('common_name')
->form([
Expand All @@ -198,15 +196,15 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['common_name'],
fn (Builder $query, $value): Builder => $query->where('common_name', 'like', "%{$value}%"),
fn(Builder $query, $value): Builder => $query->where('common_name', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['common_name']) {
return null;
}

return 'Common Name: '.$data['common_name'];
return 'Common Name: ' . $data['common_name'];
}),
Filter::make('native_name')
->form([
Expand All @@ -217,23 +215,23 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['native_name'],
fn (Builder $query, $value): Builder => $query->where('native_name', 'like', "%{$value}%"),
fn(Builder $query, $value): Builder => $query->where('native_name', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['native_name']) {
return null;
}

return 'Native Name: '.$data['native_name'];
return 'Native Name: ' . $data['native_name'];
}),
SelectFilter::make('script')
->label('Script')
->placeholder(__('core::core.filter').' Script')
->placeholder(__('core::core.filter') . ' Script')
->options(['Latin' => 'Latin', 'Cyrillic' => 'Cyrillic', 'Arabic' => 'Arabic', 'Devanagari' => 'Devanagari', 'Other' => 'Other']),
SelectFilter::make('direction')
->label('Direction')
->placeholder(__('core::core.filter').' Direction')
->placeholder(__('core::core.filter') . ' Direction')
->options(['LTR' => 'LTR', 'RTL' => 'RTL']),
]);
}
Expand Down
Loading

0 comments on commit 16acb6a

Please sign in to comment.