Skip to content

Commit

Permalink
Merge pull request #1 from SWEET1S/main
Browse files Browse the repository at this point in the history
Localization for Admin Panel Moonshine in English, Russian and Romanian
  • Loading branch information
alexvenga authored Aug 24, 2023
2 parents 3b9f7a3 + 7ae49ea commit 96e765d
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 28 deletions.
15 changes: 15 additions & 0 deletions lang/en/ui.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

return [
'main' => 'Main',
'group' => 'Group',
'slug' => 'Slug',
'hint' => 'Hint',
'not_used' => 'Not used on the site, only for ease of administration!',
'value' => 'Value',
'created_at' => 'Created at',
'updated_at' => 'Updated at',
'count_settings' => 'Count settings',
'settings_groups' => 'Settings groups',
'settings' => 'Settings'
];
15 changes: 15 additions & 0 deletions lang/ro/ui.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

return [
'main' => 'Principala',
'group' => 'Grupul',
'slug' => 'Slug',
'hint' => 'Indiciu',
'not_used' => 'Nu este folosit pe site, doar pentru ușurința de administrare!',
'value' => 'Valoare',
'created_at' => 'Creat la',
'updated_at' => 'Actualizat la',
'count_settings' => 'Numărul de setări',
'settings_groups' => 'Grupuri de setări',
'settings' => 'Setări'
];
15 changes: 15 additions & 0 deletions lang/ru/ui.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

return [
'main' => 'Главная',
'group' => 'Группа',
'slug' => 'Slug',
'hint' => 'Подсказка',
'not_used' => 'Не используется на сайте, только для удобства администрирования!',
'value' => 'Значение',
'created_at' => 'Создано в',
'updated_at' => 'Обновлено на',
'count_settings' => 'Счетчик настроек',
'settings_groups' => 'Группы настроек',
'settings' => 'Настройки'
];
8 changes: 7 additions & 1 deletion src/LaravelSiteSettingsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public function boot()
Setting::observe(LSSObserver::class);
SettingGroup::observe(LSSObserver::class);

$this->loadTranslationsFrom(__DIR__.'/../lang', 'laravel-site-settings');

$this->publishes([
__DIR__.'/../lang' => $this->app->langPath('vendor/laravel-site-settings'),
]);

}

}
}
25 changes: 12 additions & 13 deletions src/MoonShine/Resources/SettingGroupResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,42 @@ class SettingGroupResource extends Resource

public static array $activeActions = ['create', 'show', 'edit'];

// TODO Add translation
//public function title(): string
//{
// return trans('moonshine::ui.resource.admins_title');
//}
public function title(): string
{
return trans('laravel-site-settings::ui.settings_groups');
}

public function fields(): array
{
return [
Block::make('Main', [
Block::make(trans('laravel-site-settings::ui.main'), [
ID::make()->sortable(),

Text::make('Slug', 'slug')
Text::make(trans('laravel-site-settings::ui.slug'), 'slug')
->required()
->sortable()
->hint('a-z, 0-9, -, _')
->showOnExport(),

Text::make('Hint', 'hint')
Text::make(trans('laravel-site-settings::ui.hint'), 'hint')
->nullable()
->sortable()
->hint('Не используется на сайте, только для удобства администрирования!')
->hint(trans('laravel-site-settings::ui.not_used'))
->showOnExport(),

NoInput::make('Created at', 'created_at',
NoInput::make(trans('laravel-site-settings::ui.created_at'), 'created_at',
fn(SettingGroup $item)=>$item->created_at->isoFormat('lll'))
->sortable()
->hideOnForm()
->showOnExport(),

NoInput::make('Updated at', 'updated_at',
NoInput::make(trans('laravel-site-settings::ui.updated_at'), 'updated_at',
fn(SettingGroup $item)=>$item->updated_at->isoFormat('lll'))
->sortable()
->hideOnForm()
->showOnExport(),

NoInput::make('Count settings', 'settings_count')
NoInput::make(trans('laravel-site-settings::ui.count_settings'), 'settings_count')
->sortable()
->hideOnForm()
->hideOnDetail()
Expand Down Expand Up @@ -95,7 +94,7 @@ public function filters(): array
public function actions(): array
{
return [

];
}

Expand Down
27 changes: 13 additions & 14 deletions src/MoonShine/Resources/SettingResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,48 @@ class SettingResource extends Resource

public static array $activeActions = ['create', 'show', 'edit'];

// TODO Add translation
//public function title(): string
//{
// return trans('moonshine::ui.resource.admins_title');
//}
public function title(): string
{
return trans('laravel-site-settings::ui.settings');
}

public function fields(): array
{
return [
Block::make('Main', [
Block::make(trans('laravel-site-settings::ui.main'), [
ID::make()->sortable(),

BelongsTo::make(
'Group',
trans('laravel-site-settings::ui.group'),
'settingGroup',
new SettingGroupResource()
)
->nullable()
->sortable()
->showOnExport(),

Text::make('Slug', 'slug')
Text::make(trans('laravel-site-settings::ui.slug'), 'slug')
->required()
->sortable()
->hint('a-z, 0-9, -, _')
->showOnExport(),

Text::make('Hint', 'hint')
Text::make(trans('laravel-site-settings::ui.hint'), 'hint')
->nullable()
->sortable()
->hint('Не используется на сайте, только для удобства администрирования!')
->hint(trans('laravel-site-settings::ui.not_used'))
->showOnExport(),

Textarea::make('Value', 'value')->nullable()->sortable()
Textarea::make(trans('laravel-site-settings::ui.value'), 'value')->nullable()->sortable()
->showOnExport(),

NoInput::make('Created at', 'created_at',
NoInput::make(trans('laravel-site-settings::ui.created_at'), 'created_at',
fn(Setting $item) => $item->created_at->isoFormat('lll'))
->sortable()
->hideOnForm()
->showOnExport(),

NoInput::make('Updated at', 'updated_at',
NoInput::make(trans('laravel-site-settings::ui.updated_at'), 'updated_at',
fn(Setting $item) => $item->updated_at->isoFormat('lll'))
->sortable()
->hideOnForm()
Expand Down Expand Up @@ -118,7 +117,7 @@ public function filters(): array
public function actions(): array
{
return [

];
}

Expand Down

0 comments on commit 96e765d

Please sign in to comment.