From 038ea05d560db5c136f803c0aab6358bed6ce787 Mon Sep 17 00:00:00 2001 From: Konstantinos Arvanitakis Date: Tue, 15 Sep 2026 23:53:59 +0300 Subject: [PATCH] Feature: translations on regions and countries on payment methods --- .../components/region-country.blade.php | 8 +++++- .../checkout/components/select.blade.php | 26 +++++++++++++++++-- .../partials/payment-methods.blade.php | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/resources/views/checkout/components/region-country.blade.php b/resources/views/checkout/components/region-country.blade.php index bbaebae..7e1e006 100644 --- a/resources/views/checkout/components/region-country.blade.php +++ b/resources/views/checkout/components/region-country.blade.php @@ -21,6 +21,7 @@ label="{{ __('checkout.page.state') }}" :options="$regions" value-field="name" + translation-group="states" :value="$address?->state" placeholder="{{ __('checkout.page.state_placeholder') }}" required @@ -28,7 +29,11 @@
{{ __('checkout.page.country') }} -

{{ $storeCountry->name }}

+

+ {{ \Illuminate\Support\Facades\Lang::has("core::countries.{$storeCountry->name}") + ? __("core::countries.{$storeCountry->name}") + : $storeCountry->name }} +

@else @@ -38,6 +43,7 @@ :name="$prefix . '_country_id'" label="{{ __('checkout.page.country') }}" :options="$countries" + translation-group="countries" :value="$address?->country_id" placeholder="{{ __('checkout.page.country_placeholder') }}" required diff --git a/resources/views/checkout/components/select.blade.php b/resources/views/checkout/components/select.blade.php index 6a722a1..3474c67 100644 --- a/resources/views/checkout/components/select.blade.php +++ b/resources/views/checkout/components/select.blade.php @@ -1,11 +1,20 @@ {{-- - + `options` is an iterable of models/objects; `label` is always read from `->name`, the submitted value from `->{$valueField}` (default `id`, but e.g. `name` for Lunar states — table-rate-shipping resolves those with State::whereName(), so the address must carry the exact name string). + + `translationGroup` (optional, e.g. "countries"/"states") looks the raw + `->name` up in boboko-core's `core::{group}.{name}` lang file (see + boboko-core's lang/el/countries.php, lang/el/states.php) for the + DISPLAYED label only — the submitted `value` is always the untranslated + `->{$valueField}`, since table-rate-shipping/Lunar's Country lookups key + off the original English name. Falls back to the raw name when no + translation exists for the current locale (e.g. English, or a country + outside the covered set). --}} @props([ 'name', @@ -15,8 +24,21 @@ 'placeholder' => null, 'required' => false, 'valueField' => 'id', + 'translationGroup' => null, ]) +@php + $optionLabel = function ($option) use ($translationGroup) { + if (! $translationGroup) { + return $option->name; + } + + $key = "core::{$translationGroup}.{$option->name}"; + + return \Illuminate\Support\Facades\Lang::has($key) ? __($key) : $option->name; + }; +@endphp + @php($selected = old($name, $value))
@@ -32,7 +54,7 @@ @endif @foreach ($options as $option) @endforeach diff --git a/resources/views/checkout/partials/payment-methods.blade.php b/resources/views/checkout/partials/payment-methods.blade.php index 3891042..ca239cf 100644 --- a/resources/views/checkout/partials/payment-methods.blade.php +++ b/resources/views/checkout/partials/payment-methods.blade.php @@ -23,7 +23,7 @@ @checked($selected === $method->type) data-action="change->bbk-payment#selectMethod" > - {{ $method->name }} + {{ $method->translate('name') }} @endforeach