1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Merge pull request #9857 from turbo124/v5-develop

Fixes for translations in client portal
This commit is contained in:
David Bomba 2024-08-04 16:55:45 +10:00 committed by GitHub
commit ed0cb15013
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 37 additions and 36 deletions

View File

@ -298,6 +298,9 @@ class PreviewController extends BaseController
->mock();
} catch(SyntaxError $e) {
}
catch(\Exception $e) {
return response()->json(['message' => 'invalid data access', 'errors' => ['design.design.body' => $e->getMessage()]], 422);
}
if (request()->query('html') == 'true') {
return $ts->getHtml();

View File

@ -31,12 +31,8 @@ class TwigLint implements ValidationRule
try {
$twig->parse($twig->tokenize(new \Twig\Source(preg_replace('/<!--.*?-->/s', '', $value), '')));
} catch (\Twig\Error\SyntaxError $e) {
// echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
nlog($e->getMessage());
$fail($e->getMessage());
}
}
}

View File

@ -20,8 +20,6 @@ class PersonalAddress extends Component
public $country_id;
public $countries;
public $saved;
protected $rules = [
@ -33,7 +31,7 @@ class PersonalAddress extends Component
'country_id' => ['sometimes'],
];
public function mount($countries)
public function mount()
{
$this->fill([
'profile' => auth()->guard('contact')->user()->client,
@ -43,8 +41,6 @@ class PersonalAddress extends Component
'state' => auth()->guard('contact')->user()->client->state,
'postal_code' => auth()->guard('contact')->user()->client->postal_code,
'country_id' => auth()->guard('contact')->user()->client->country_id,
'countries' => $countries,
'saved' => ctrans('texts.save'),
]);
}

View File

@ -20,8 +20,6 @@ class ShippingAddress extends Component
public $shipping_country_id;
public $countries;
public $saved;
protected $rules = [
@ -33,7 +31,7 @@ class ShippingAddress extends Component
'shipping_country_id' => ['sometimes'],
];
public function mount($countries)
public function mount()
{
$this->fill([
'profile' => auth()->guard('contact')->user()->client,
@ -43,8 +41,6 @@ class ShippingAddress extends Component
'shipping_state' => auth()->guard('contact')->user()->client->shipping_state,
'shipping_postal_code' => auth()->guard('contact')->user()->client->shipping_postal_code,
'shipping_country_id' => auth()->guard('contact')->user()->client->shipping_country_id,
'countries' => $countries,
'saved' => ctrans('texts.save'),
]);
}

View File

@ -53,4 +53,9 @@ class Currency extends StaticModel
'deleted_at' => 'timestamp',
'precision' => 'integer',
];
public function getName(): string
{
return trans('texts.currency_'.$this->name);
}
}

File diff suppressed because one or more lines are too long

View File

@ -482,6 +482,8 @@ class TemplateService
default => $processed = [],
};
nlog(json_encode($processed));
return $processed;
})->toArray();

View File

@ -34,8 +34,10 @@ class TranslationHelper
{
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
// $countries = app('countries');
$countries = app('countries');
return $countries;
return \App\Models\Country::all()->each(function ($country) {
$country->name = ctrans('texts.country_'.$country->name);
})->sortBy(function ($country) {
@ -73,7 +75,8 @@ class TranslationHelper
{
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
// $currencies = app('currencies');
$currencies = app('currencies');
return $currencies;
return \App\Models\Currency::all()->each(function ($currency) {
$currency->name = ctrans('texts.currency_'.Str::slug($currency->name, '_'));

View File

@ -61,7 +61,7 @@
<option
{{ $country == isset(auth()->user()->client->shipping_country->id) ? 'selected' : null }} value="{{ $country->id }}">
{{ $country->iso_3166_2 }}
({{ $country->name }})
({{ $country->getName() }})
</option>
@endforeach
</select>
@ -75,7 +75,7 @@
<option
{{ $country == isset(auth()->user()->client->shipping_country->id) ? 'selected' : null }} value="{{ $country->id }}">
{{ $country->iso_3166_2 }}
({{ $country->name }})
({{ $country->getName() }})
</option>
@endforeach
</select>

View File

@ -83,7 +83,7 @@
@foreach(App\Utils\TranslationHelper::getCountries() as $country)
<option value="{{ $country->id }}">
{{ $country->iso_3166_2 }}
({{ $country->name }})
({{ $country->getName() }})
</option>
@endforeach
</select>

View File

@ -22,7 +22,7 @@
@foreach($countries as $country)
<option value="{{ $country->id }}">
{{ $country->iso_3166_2 }} ({{ $country->name }})
{{ $country->iso_3166_2 }} ({{ $country->getName() }})
</option>
@endforeach
</select>

View File

@ -57,7 +57,7 @@
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
<select name="countries" id="country" name="country" class="form-select input w-full bg-white" required>
@foreach($countries as $country)
<option value="{{ $country->iso_3166_2 }}" {{$country->iso_3166_2 == 'US' ? "selected" : ""}}>{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
<option value="{{ $country->iso_3166_2 }}" {{$country->iso_3166_2 == 'US' ? "selected" : ""}}>{{ $country->iso_3166_2 }} ({{ $country->getName() }})</option>
@endforeach
</select>
@endcomponent
@ -65,7 +65,7 @@
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.currency')])
<select name="currencies" id="currency" name="currency" class="form-select input w-full">
@foreach($currencies as $currency)
<option value="{{ $currency->code }}" {{$currency->code == 'USD' ? "selected" : ""}}>{{ $currency->code }} ({{ $currency->name }})</option>
<option value="{{ $currency->code }}" {{$currency->code == 'USD' ? "selected" : ""}}>{{ $currency->code }} ({{ $currency->getName() }})</option>
@endforeach
</select>
@endcomponent

View File

@ -51,9 +51,9 @@
<option disabled selected></option>
@foreach($countries as $country)
@if($country->iso_3166_2 == 'US')
<option value="{{ $country->iso_3166_2 }}" selected>{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
<option value="{{ $country->iso_3166_2 }}" selected>{{ $country->iso_3166_2 }} ({{ $country->getName() }})</option>
@else
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->getName() }})</option>
@endif
@endforeach
</select>
@ -64,7 +64,7 @@
<option disabled selected></option>
@foreach($currencies as $currency)
@if($currency->code == 'USD')
<option value="{{ $currency->code }}" selected>{{ $currency->code }} ({{ $currency->name }})</option>
<option value="{{ $currency->code }}" selected>{{ $currency->code }} ({{ $currency->getName() }})</option>
@else
<option value="{{ $currency->code }}">{{ $currency->code }} ({{ $currency->name }})</option>
@endif

View File

@ -47,7 +47,7 @@
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
<select name="countries" id="country" class="form-select input w-full bg-white" required>
@foreach($countries as $country)
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->getName() }})</option>
@endforeach
</select>
@endcomponent
@ -55,7 +55,7 @@
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.currency')])
<select name="currencies" id="currency" class="form-select input w-full">
@foreach($currencies as $currency)
<option value="{{ $currency->code }}">{{ $currency->code }} ({{ $currency->name }})</option>
<option value="{{ $currency->code }}">{{ $currency->code }} ({{ $currency->getName() }})</option>
@endforeach
</select>
@endcomponent

View File

@ -47,7 +47,7 @@
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
<select name="countries" id="country" class="form-select input w-full bg-white" required>
@foreach($countries as $country)
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->getName() }})</option>
@endforeach
</select>
@endcomponent
@ -55,7 +55,7 @@
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.currency')])
<select name="currencies" id="currency" class="form-select input w-full">
@foreach($currencies as $currency)
<option value="{{ $currency->code }}">{{ $currency->code }} ({{ $currency->name }})</option>
<option value="{{ $currency->code }}">{{ $currency->code }} ({{ $currency->getName() }})</option>
@endforeach
</select>
@endcomponent

View File

@ -1526,7 +1526,7 @@ Ensure the default browser behavior of the `hidden` attribute.
<select name="country" id="country" class="form-select w-full py-[9.5px] px-[12px] border border-light-grey rounded transition ease-in-out m-0 focus:border-primary-blue focus:outline-none bg-white">
<option value="{{ $client->country->id}}" selected>{{ $client->country->iso_3166_2 }} ({{ $client->country->name }})</option>
@foreach($countries as $country)
<option value="{{ $country->id }}">{{ $country->iso_3166_2 }} ({{ $country->name }})></option>
<option value="{{ $country->id }}">{{ $country->iso_3166_2 }} ({{ $country->getName() }})></option>
@endforeach
</select>
</div>

View File

@ -28,8 +28,8 @@
@livewire('profile.settings.general')
<!-- Client personal address -->
@livewire('profile.settings.personal-address', ['countries' => $countries])
@livewire('profile.settings.personal-address')
<!-- Client shipping address -->
@livewire('profile.settings.shipping-address', ['countries' => $countries])
@livewire('profile.settings.shipping-address')
@endsection

View File

@ -61,7 +61,7 @@
<option value="none"></option>
@foreach($countries as $country)
<option value="{{ $country->id }}">
{{ $country->iso_3166_2 }} ({{ $country->name }})
{{ $country->iso_3166_2 }} ({{ $country->getName() }})
</option>
@endforeach
</select>

View File

@ -62,7 +62,7 @@
<option value="none"></option>
@foreach($countries as $country)
<option value="{{ $country->id }}">
{{ $country->iso_3166_2 }} ({{ $country->name }})
{{ $country->iso_3166_2 }} ({{ $country->getName() }})
</option>
@endforeach
</select>

View File

@ -152,7 +152,7 @@
<option value="none"></option>
@foreach($countries as $country)
<option value="{{ $country->id }}" @if($vendor->country_id == $country->id) selected @endif>
{{ $country->iso_3166_2 }} ({{ $country->name }})
{{ $country->iso_3166_2 }} ({{ $country->getName() }})
</option>
@endforeach
</select>