value map, and assigning that map back through `setAttribute` * writes each translation. So a field whose state path is "title.ca" hydrates * and saves the Catalan translation with no extra wiring. */ final class TranslatableTabs { /** * @param Closure(string $locale, bool $isDefault): array $fields * Receives the locale code and whether it is the primary one, * and returns the components for that tab. */ public static function make(Closure $fields, ?string $label = null): Tabs { $default = (string) config('locales.default'); $tabs = []; foreach (config('locales.supported') as $locale => $meta) { $tabs[] = Tab::make($locale) ->label(trim(($meta['flag'] ?? '').' '.($meta['native'] ?? $locale))) // Marks the primary language, the one every other tab falls // back to when left empty. ->badge($locale === $default ? '★' : null) ->schema($fields($locale, $locale === $default)); } $tabs = Tabs::make($label ?? __('panel.pages.fields.translations')) ->tabs($tabs) ->columnSpanFull(); // Open the tab for the language the admin is currently working in. return $tabs->persistTabInQueryString('locale_tab'); } /** * Suffix for a field label inside a locale tab, e.g. "Título (Català)". * Useful when a field sits outside the tabs but still targets one locale. */ public static function suffix(string $locale): string { return (string) (config("locales.supported.{$locale}.native") ?? $locale); } }