Skip to content

Commit

Permalink
feat(Localization): Translatable labels for Moonshine in EN/RU/RO
Browse files Browse the repository at this point in the history
  • Loading branch information
SWEET1S committed Jul 17, 2023
1 parent e5408d5 commit 8b28e6b
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 22 deletions.
5 changes: 4 additions & 1 deletion lang/en/ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
'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' => 'Настройки'
];
2 changes: 1 addition & 1 deletion src/LaravelSiteSettingsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ public function boot()

}

}
}
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 __('laravel-site-settings::ui.settings_groups');
}

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

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

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

NoInput::make('Created at', 'created_at',
NoInput::make(__('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(__('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(__('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
13 changes: 6 additions & 7 deletions src/MoonShine/Resources/SettingResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ 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 __('laravel-site-settings::ui.settings');
}

public function fields(): array
{
Expand All @@ -55,7 +54,7 @@ public function fields(): array
Text::make(__('laravel-site-settings::ui.hint'), 'hint')
->nullable()
->sortable()
->hint(__('laravel-site-settings::not_used'))
->hint(__('laravel-site-settings::ui.not_used'))
->showOnExport(),

Textarea::make(__('laravel-site-settings::ui.value'), 'value')->nullable()->sortable()
Expand Down Expand Up @@ -118,7 +117,7 @@ public function filters(): array
public function actions(): array
{
return [

];
}

Expand Down

0 comments on commit 8b28e6b

Please sign in to comment.