@extends(backpack_view('blank')) @section('content') @php $locale = request()->query('_locale', app()->getLocale()); $isSpanish = $locale === 'es'; // English values are the canonical values submitted by the form. $productTypes = [ 'Originator Brand' => $isSpanish ? 'Marca original' : 'Originator Brand', 'Generic' => $isSpanish ? 'Genérico' : 'Generic', 'Biosimilar' => 'Biosimilar', 'Biocomparable' => 'Biocomparable', 'API Only' => $isSpanish ? 'Solo API' : 'API Only', 'Special Import/Named Patient' => $isSpanish ? 'Importación especial / paciente nominal' : 'Special Import/Named Patient', 'Govt Procurement Only' => $isSpanish ? 'Solo para compras gubernamentales' : 'Govt Procurement Only', ]; // Normalize translated product-type labels to canonical English values. $spanishToEnglish = [ 'Marca original' => 'Originator Brand', 'Genérico' => 'Generic', 'Solo API' => 'API Only', 'Importación especial / paciente nominal' => 'Special Import/Named Patient', 'Solo para compras gubernamentales' => 'Govt Procurement Only', ]; // Read a translatable value from JSON, an array, or a string. $localizedValue = function ($value) use ($locale) { if (is_string($value)) { $decoded = json_decode($value, true); if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) { return $decoded[$locale] ?? $decoded['en'] ?? ''; } } if (is_array($value)) { return $value[$locale] ?? $value['en'] ?? ''; } return $value ?? ''; }; @endphp