Skip to content

Commit bdfc1ad

Browse files
Add Manage Localization Page (#285)
Co-authored-by: spoyntersmith <[email protected]> Co-authored-by: James Brooks <[email protected]>
1 parent f2beeb0 commit bdfc1ad

File tree

4 files changed

+67
-2
lines changed

4 files changed

+67
-2
lines changed

resources/lang/en/navigation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'items' => [
77
'manage_cachet' => 'Manage Cachet',
88
'manage_customization' => 'Manage Customization',
9+
'manage_localization' => 'Manage Localization',
910
'manage_theme' => 'Manage Theme',
1011
'manage_api_keys' => 'Manage API Keys',
1112
'manage_webhooks' => 'Manage Webhooks',

resources/lang/en/settings.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
'manage_cachet' => [
55
'site_name_label' => 'Site Name',
66
'about_this_site_label' => 'About This Site',
7-
'timezone_label' => 'Timezone',
87
'incident_days_label' => 'Incident Days',
98
'major_outage_threshold_label' => 'Major Outage Threshold',
109
'refresh_rate_label' => 'Automatically Refresh Page',
1110
'refresh_rate_label_input_suffix_seconds' => 'seconds',
1211
'recent_incidents_days_suffix_days' => 'days',
1312
'toggles' => [
1413
'support_cachet' => 'Support Cachet',
15-
'show_timezone' => 'Show Timezone',
1614
'show_dashboard_link' => 'Show Dashboard Link',
1715
'display_graphs' => 'Display Graphs',
1816
'enable_external_dependencies' => 'Enable External Dependencies',
@@ -27,6 +25,13 @@
2725
'footer_label' => 'Custom Footer HTML',
2826
'stylesheet_label' => 'Custom CSS',
2927
],
28+
'manage_localization' => [
29+
'locale_label' => 'Locale',
30+
'timezone_label' => 'Timezone',
31+
'toggles' => [
32+
'show_timezone' => 'Show Timezone',
33+
],
34+
],
3035
'manage_theme' => [
3136
'app_banner_label' => 'Banner Image',
3237
'status_page_accent' => [
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace Cachet\Filament\Pages\Settings;
4+
5+
use Cachet\Settings\AppSettings;
6+
use Filament\Forms;
7+
use Filament\Forms\Form;
8+
use Illuminate\Support\Str;
9+
10+
class ManageLocalization extends SettingsPage
11+
{
12+
protected static string $settings = AppSettings::class;
13+
14+
public static function getNavigationGroup(): ?string
15+
{
16+
return __('cachet::navigation.settings.label');
17+
}
18+
19+
public static function getNavigationLabel(): string
20+
{
21+
return __('cachet::navigation.settings.items.manage_localization');
22+
}
23+
24+
public function form(Form $form): Form
25+
{
26+
return $form
27+
->schema([
28+
Forms\Components\Section::make()->columns(2)->schema([
29+
Forms\Components\Select::make('locale')
30+
->label(__('cachet::settings.manage_localization.locale_label'))
31+
->options(
32+
config('cachet.supported_locales', [
33+
'en' => 'English',
34+
])
35+
)->searchable()
36+
->suffixIcon('heroicon-o-language'),
37+
38+
Forms\Components\Select::make('timezone')
39+
->label(__('cachet::settings.manage_localization.timezone_label'))
40+
->options(fn () => collect(timezone_identifiers_list())
41+
->mapToGroups(
42+
fn ($timezone) => [
43+
Str::of($timezone)
44+
->before('/')
45+
->toString() => [$timezone => $timezone],
46+
]
47+
)
48+
->map(fn ($group) => $group->collapse()))
49+
->searchable()
50+
->suffixIcon('heroicon-o-globe-alt'),
51+
52+
Forms\Components\Toggle::make('show_timezone')
53+
->label(__('cachet::settings.manage_localization.toggles.show_timezone')),
54+
]),
55+
]);
56+
}
57+
}

src/Settings/AppSettings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class AppSettings extends Settings
1414

1515
public bool $show_support = true;
1616

17+
public string $locale = 'en';
18+
1719
public string $timezone = 'UTC';
1820

1921
public bool $show_timezone = false;

0 commit comments

Comments
 (0)