diff --git a/lang/en/ui.php b/lang/en/ui.php new file mode 100644 index 0000000..7cebaf5 --- /dev/null +++ b/lang/en/ui.php @@ -0,0 +1,15 @@ + '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' +]; diff --git a/lang/ro/ui.php b/lang/ro/ui.php new file mode 100644 index 0000000..1138031 --- /dev/null +++ b/lang/ro/ui.php @@ -0,0 +1,15 @@ + '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' +]; diff --git a/lang/ru/ui.php b/lang/ru/ui.php new file mode 100644 index 0000000..16a979d --- /dev/null +++ b/lang/ru/ui.php @@ -0,0 +1,15 @@ + 'Главная', + 'group' => 'Группа', + 'slug' => 'Slug', + 'hint' => 'Подсказка', + 'not_used' => 'Не используется на сайте, только для удобства администрирования!', + 'value' => 'Значение', + 'created_at' => 'Создано в', + 'updated_at' => 'Обновлено на', + 'count_settings' => 'Счетчик настроек', + 'settings_groups' => 'Группы настроек', + 'settings' => 'Настройки' +]; diff --git a/src/LaravelSiteSettingsProvider.php b/src/LaravelSiteSettingsProvider.php index 3b5b89b..a4da3db 100644 --- a/src/LaravelSiteSettingsProvider.php +++ b/src/LaravelSiteSettingsProvider.php @@ -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'), + ]); + } -} \ No newline at end of file +} diff --git a/src/MoonShine/Resources/SettingGroupResource.php b/src/MoonShine/Resources/SettingGroupResource.php index 756c227..3f366d6 100644 --- a/src/MoonShine/Resources/SettingGroupResource.php +++ b/src/MoonShine/Resources/SettingGroupResource.php @@ -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() @@ -95,7 +94,7 @@ public function filters(): array public function actions(): array { return [ - + ]; } diff --git a/src/MoonShine/Resources/SettingResource.php b/src/MoonShine/Resources/SettingResource.php index d61e7a7..b976c23 100644 --- a/src/MoonShine/Resources/SettingResource.php +++ b/src/MoonShine/Resources/SettingResource.php @@ -25,20 +25,19 @@ 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() ) @@ -46,28 +45,28 @@ public function fields(): array ->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() @@ -118,7 +117,7 @@ public function filters(): array public function actions(): array { return [ - + ]; }