@@ -75,41 +75,52 @@ public static function form(Schema $schema): Schema
7575 if ($ state ) {
7676 $ language = StaticLanguage::find ($ state );
7777 if ($ language ) {
78- $ set ('locale_variant ' , $ language ->alpha2 );
78+ $ mainLocale = $ language ->alpha2 . '_ ' . strtoupper ($ language ->alpha2 );
79+ $ set ('locale_variant ' , $ mainLocale );
7980 }
8081 }
8182 }),
8283 TextInput::make ('title ' )
8384 ->label (__ ('localization::fields.title ' ))
8485 ->required ()
85- ->afterStateUpdated (fn (Set $ set , ?string $ state ) => $ set ('slug ' , Str::slug ($ state ))),
86+ ->afterStateUpdated (fn (Set $ set , ?string $ state ) => $ set ('slug ' , Str::slug ($ state ))),
8687 TextInput::make ('slug ' )
8788 ->label (__ ('localization::fields.slug ' ))
8889 ->required (),
8990 Select::make ('locale_variant ' )
9091 ->label ('Locale Variant ' )
9192 ->options (function ($ get ) {
9293 $ languageId = $ get ('language_id ' );
93- if (! $ languageId ) {
94+ if (!$ languageId ) {
9495 return [];
9596 }
9697
9798 $ language = StaticLanguage::find ($ languageId );
98- if (! $ language ) {
99+ if (!$ language ) {
99100 return [];
100101 }
101102
102103 $ baseLanguage = $ language ->alpha2 ;
104+ $ mainLocale = $ baseLanguage . '_ ' . strtoupper ($ baseLanguage );
103105
104106 $ locales = StaticLocale::where ('language_id ' , $ languageId )->with ('country ' )->get ();
105107
106- $ options = [
107- $ baseLanguage => $ language ->common_name .' ( ' .$ baseLanguage .') ' ,
108- ];
108+ $ options = [];
109109
110110 foreach ($ locales as $ locale ) {
111111 $ countryName = $ locale ->country ? $ locale ->country ->common_name : 'Unknown ' ;
112- $ options [$ locale ->locale ] = $ language ->common_name .' ( ' .$ countryName .') ' ;
112+
113+ // Wenn es der Haupt-Locale ist (z.B. de_DE), zeige "Standard"
114+ if ($ locale ->locale === $ mainLocale ) {
115+ $ options [$ locale ->locale ] = $ language ->common_name . ' (Standard) ' ;
116+ } else {
117+ $ options [$ locale ->locale ] = $ language ->common_name . ' ( ' . $ countryName . ') ' ;
118+ }
119+ }
120+
121+ // Falls kein Locale in der DB existiert, füge den Haupt-Locale hinzu
122+ if (empty ($ options )) {
123+ $ options [$ mainLocale ] = $ language ->common_name . ' (Standard) ' ;
113124 }
114125
115126 return $ options ;
@@ -193,35 +204,40 @@ public static function table(Table $table): Table
193204 {
194205 return $ table
195206 ->columns ([
207+ // Basic Info Group
196208 IconColumn::make ('table_flag ' )
197209 ->label ('Flag ' )
198- ->icon (fn (string $ state ): string => $ state ),
210+ ->icon (fn (string $ state ): string => $ state ),
199211 TextColumn::make ('display_name ' )
200212 ->label (__ ('localization::fields.language ' ))
201- ->searchable (),
213+ ->searchable ()
214+ ->width (150 ),
202215 TextColumn::make ('locale_variant ' )
203- ->label ('Locale Variant ' ),
204- TextColumn::make ('display_name ' )
205- ->label (__ ('localization::fields.title ' ))
206- ->searchable (),
216+ ->label ('Locale ' )
217+ ->width (100 ),
207218 TextColumn::make ('slug ' )
208- ->label (__ ('localization::fields.slug ' )),
209- TextColumn:: make ( ' fallbackLanguage.title ' )
210- -> label ( __ ( ' localization::fields.fallback_language ' )),
219+ ->label (__ ('localization::fields.slug ' ))
220+ -> width ( 120 ),
221+ // Status Toggles Group
211222 ToggleColumn::make ('is_active_admin ' )
212- ->label (__ ('localization::fields.is_activ_admin ' )),
223+ ->label ('Admin ' )
224+ ->width (80 ),
213225 ToggleColumn::make ('is_active_frontend ' )
214- ->label (__ ('localization::fields.is_activ_frontend ' )),
226+ ->label ('Frontend ' )
227+ ->width (80 ),
215228 ToggleColumn::make ('is_default ' )
216- ->label (__ ('localization::fields.is_default ' ))
229+ ->label ('Default ' )
230+ ->width (80 )
217231 ->afterStateUpdated (function ($ state , $ record ) {
218232 if ($ state ) {
219233 static ::getModel ()::where ('id ' , '!= ' , $ record ->id )
220234 ->update (['is_default ' => false ]);
221235 }
222236 }),
237+ // Config Toggles Group
223238 ToggleColumn::make ('language_settings->use_native_names ' )
224- ->label (__ ('localization::fields.use_native_names ' ))
239+ ->label ('Native ' )
240+ ->width (80 )
225241 ->getStateUsing (function ($ record ) {
226242 return $ record ->getLanguageSetting ('use_native_names ' );
227243 })
@@ -231,7 +247,8 @@ public static function table(Table $table): Table
231247 $ record ->update (['language_settings ' => $ settings ]);
232248 }),
233249 ToggleColumn::make ('language_settings->show_regional_variants ' )
234- ->label (__ ('localization::fields.show_regional_variants ' ))
250+ ->label ('Regional ' )
251+ ->width (80 )
235252 ->getStateUsing (function ($ record ) {
236253 return $ record ->getLanguageSetting ('show_regional_variants ' );
237254 })
@@ -241,7 +258,8 @@ public static function table(Table $table): Table
241258 $ record ->update (['language_settings ' => $ settings ]);
242259 }),
243260 ToggleColumn::make ('language_settings->use_country_translations ' )
244- ->label (__ ('localization::fields.use_country_translations ' ))
261+ ->label ('Country ' )
262+ ->width (80 )
245263 ->getStateUsing (function ($ record ) {
246264 return $ record ->getLanguageSetting ('use_country_translations ' );
247265 })
@@ -260,7 +278,7 @@ public static function table(Table $table): Table
260278 ->groups ([
261279 Group::make ('language.common_name ' )
262280 ->label (__ ('localization::fields.language ' ))
263- ->getTitleFromRecordUsing (fn (Localization $ record ): string => $ record ->language ->common_name )
281+ ->getTitleFromRecordUsing (fn (Localization $ record ): string => $ record ->language ->common_name )
264282 ->collapsible (),
265283 ])
266284 ->defaultGroup ('language.common_name ' )
0 commit comments