From 3ddbaa6111c19afbd42d32184910f37073f1c293 Mon Sep 17 00:00:00 2001 From: Abdelrahman Saeed Elhassan Yousif Date: Sun, 22 Sep 2024 12:41:13 +0200 Subject: [PATCH 1/2] Change template key to be selectable list --- src/Resources/EmailTemplateResource.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Resources/EmailTemplateResource.php b/src/Resources/EmailTemplateResource.php index d541a4b..6cef70b 100644 --- a/src/Resources/EmailTemplateResource.php +++ b/src/Resources/EmailTemplateResource.php @@ -94,10 +94,9 @@ public static function form(Form $form): Form Grid::make(['default' => 1, 'sm' => 1, 'md' => 2]) ->schema( [ - TextInput::make('key') - ->afterStateUpdated( - fn (Set $set, ?string $state) => $set('key', Str::slug($state)) - ) + Select::make('key') + ->options(config('filament-email-templates.template_keys')) + ->searchable() ->label(__('vb-email-templates::email-templates.form-fields-labels.key')) ->hint(__('vb-email-templates::email-templates.form-fields-labels.key-hint')) ->required() From 49e304aebfbae0e4dd1c71a0976d2e410f404d9d Mon Sep 17 00:00:00 2001 From: Abdelrahman Saeed Elhassan Yousif Date: Sun, 22 Sep 2024 13:07:03 +0200 Subject: [PATCH 2/2] Allow json file translation --- resources/lang/ar.json | 4 ++++ src/EmailTemplatesServiceProvider.php | 4 ++++ src/Resources/EmailTemplateResource.php | 4 ++-- src/Resources/EmailTemplateThemeResource.php | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 resources/lang/ar.json diff --git a/resources/lang/ar.json b/resources/lang/ar.json new file mode 100644 index 0000000..cfb6232 --- /dev/null +++ b/resources/lang/ar.json @@ -0,0 +1,4 @@ +{ + "Email Templates": "قوالب البريد الإلكتروني", + "Email Template Themes": "ثيمات قالب البريد الإلكتروني" +} diff --git a/src/EmailTemplatesServiceProvider.php b/src/EmailTemplatesServiceProvider.php index 7b3d22b..5792630 100644 --- a/src/EmailTemplatesServiceProvider.php +++ b/src/EmailTemplatesServiceProvider.php @@ -21,6 +21,7 @@ public function configurePackage(Package $package): void ->hasMigrations(['create_email_templates_themes_table','create_email_templates_table']) ->hasConfigFile(['filament-email-templates', 'filament-tiptap-editor']) ->hasAssets() + ->hasTranslations() ->hasViews('vb-email-templates') ->runsMigrations() ->hasCommands([ @@ -32,6 +33,9 @@ public function packageRegistered(): void { parent::packageRegistered(); + $this->loadJsonTranslationsFrom(__DIR__.'/../resources/lang/'); + + $this->app->singleton(CreateMailableInterface::class, CreateMailableHelper::class); $this->app->singleton(FormHelperInterface::class, FormHelper::class); $this->app->register(EmailTemplatesEventServiceProvider::class); diff --git a/src/Resources/EmailTemplateResource.php b/src/Resources/EmailTemplateResource.php index 6cef70b..78cbe51 100644 --- a/src/Resources/EmailTemplateResource.php +++ b/src/Resources/EmailTemplateResource.php @@ -51,12 +51,12 @@ public static function getNavigationSort(): ?int public static function getModelLabel(): string { - return config('filament-email-templates.navigation.templates.label'); + return __(config('filament-email-templates.navigation.templates.label')); } public static function getPluralModelLabel(): string { - return config('filament-email-templates.navigation.templates.label'); + return __(config('filament-email-templates.navigation.templates.label')); } public static function getCluster(): string diff --git a/src/Resources/EmailTemplateThemeResource.php b/src/Resources/EmailTemplateThemeResource.php index e311042..76c71d8 100644 --- a/src/Resources/EmailTemplateThemeResource.php +++ b/src/Resources/EmailTemplateThemeResource.php @@ -36,12 +36,12 @@ public static function getNavigationSort(): ?int public static function getModelLabel(): string { - return config('filament-email-templates.navigation.themes.label'); + return __(config('filament-email-templates.navigation.themes.label')); } public static function getPluralModelLabel(): string { - return config('filament-email-templates.navigation.themes.label'); + return __(config('filament-email-templates.navigation.themes.label')); } public static function getCluster(): string