mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 17:37:31 -04:00 
			
		
		
		
	Merge pull request #9857 from turbo124/v5-develop
Fixes for translations in client portal
This commit is contained in:
		
						commit
						ed0cb15013
					
				| @ -298,6 +298,9 @@ class PreviewController extends BaseController | |||||||
|                 ->mock(); |                 ->mock(); | ||||||
|         } catch(SyntaxError $e) { |         } 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') { |         if (request()->query('html') == 'true') { | ||||||
|             return $ts->getHtml(); |             return $ts->getHtml(); | ||||||
|  | |||||||
| @ -31,12 +31,8 @@ class TwigLint implements ValidationRule | |||||||
|         try { |         try { | ||||||
|             $twig->parse($twig->tokenize(new \Twig\Source(preg_replace('/<!--.*?-->/s', '', $value), ''))); |             $twig->parse($twig->tokenize(new \Twig\Source(preg_replace('/<!--.*?-->/s', '', $value), ''))); | ||||||
|         } catch (\Twig\Error\SyntaxError $e) { |         } catch (\Twig\Error\SyntaxError $e) { | ||||||
|             // echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
 |  | ||||||
|             nlog($e->getMessage()); |  | ||||||
|             $fail($e->getMessage()); |             $fail($e->getMessage()); | ||||||
| 
 |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -20,8 +20,6 @@ class PersonalAddress extends Component | |||||||
| 
 | 
 | ||||||
|     public $country_id; |     public $country_id; | ||||||
| 
 | 
 | ||||||
|     public $countries; |  | ||||||
| 
 |  | ||||||
|     public $saved; |     public $saved; | ||||||
| 
 | 
 | ||||||
|     protected $rules = [ |     protected $rules = [ | ||||||
| @ -33,7 +31,7 @@ class PersonalAddress extends Component | |||||||
|         'country_id' => ['sometimes'], |         'country_id' => ['sometimes'], | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|     public function mount($countries) |     public function mount() | ||||||
|     { |     { | ||||||
|         $this->fill([ |         $this->fill([ | ||||||
|             'profile' => auth()->guard('contact')->user()->client, |             'profile' => auth()->guard('contact')->user()->client, | ||||||
| @ -43,8 +41,6 @@ class PersonalAddress extends Component | |||||||
|             'state' => auth()->guard('contact')->user()->client->state, |             'state' => auth()->guard('contact')->user()->client->state, | ||||||
|             'postal_code' => auth()->guard('contact')->user()->client->postal_code, |             'postal_code' => auth()->guard('contact')->user()->client->postal_code, | ||||||
|             'country_id' => auth()->guard('contact')->user()->client->country_id, |             'country_id' => auth()->guard('contact')->user()->client->country_id, | ||||||
| 
 |  | ||||||
|             'countries' => $countries, |  | ||||||
|             'saved' => ctrans('texts.save'), |             'saved' => ctrans('texts.save'), | ||||||
|         ]); |         ]); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -20,8 +20,6 @@ class ShippingAddress extends Component | |||||||
| 
 | 
 | ||||||
|     public $shipping_country_id; |     public $shipping_country_id; | ||||||
| 
 | 
 | ||||||
|     public $countries; |  | ||||||
| 
 |  | ||||||
|     public $saved; |     public $saved; | ||||||
| 
 | 
 | ||||||
|     protected $rules = [ |     protected $rules = [ | ||||||
| @ -33,7 +31,7 @@ class ShippingAddress extends Component | |||||||
|         'shipping_country_id' => ['sometimes'], |         'shipping_country_id' => ['sometimes'], | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|     public function mount($countries) |     public function mount() | ||||||
|     { |     { | ||||||
|         $this->fill([ |         $this->fill([ | ||||||
|             'profile' => auth()->guard('contact')->user()->client, |             'profile' => auth()->guard('contact')->user()->client, | ||||||
| @ -43,8 +41,6 @@ class ShippingAddress extends Component | |||||||
|             'shipping_state' => auth()->guard('contact')->user()->client->shipping_state, |             'shipping_state' => auth()->guard('contact')->user()->client->shipping_state, | ||||||
|             'shipping_postal_code' => auth()->guard('contact')->user()->client->shipping_postal_code, |             'shipping_postal_code' => auth()->guard('contact')->user()->client->shipping_postal_code, | ||||||
|             'shipping_country_id' => auth()->guard('contact')->user()->client->shipping_country_id, |             'shipping_country_id' => auth()->guard('contact')->user()->client->shipping_country_id, | ||||||
| 
 |  | ||||||
|             'countries' => $countries, |  | ||||||
|             'saved' => ctrans('texts.save'), |             'saved' => ctrans('texts.save'), | ||||||
|         ]); |         ]); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -53,4 +53,9 @@ class Currency extends StaticModel | |||||||
|         'deleted_at' => 'timestamp', |         'deleted_at' => 'timestamp', | ||||||
|         'precision' => 'integer', |         'precision' => 'integer', | ||||||
|     ]; |     ]; | ||||||
|  | 
 | ||||||
|  |     public function getName(): string | ||||||
|  |     { | ||||||
|  |         return trans('texts.currency_'.$this->name); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @ -482,6 +482,8 @@ class TemplateService | |||||||
|                 default => $processed = [], |                 default => $processed = [], | ||||||
|             }; |             }; | ||||||
| 
 | 
 | ||||||
|  |             nlog(json_encode($processed)); | ||||||
|  | 
 | ||||||
|             return $processed; |             return $processed; | ||||||
| 
 | 
 | ||||||
|         })->toArray(); |         })->toArray(); | ||||||
|  | |||||||
| @ -34,8 +34,10 @@ class TranslationHelper | |||||||
|     { |     { | ||||||
|          |          | ||||||
|         /** @var \Illuminate\Support\Collection<\App\Models\Country> */ |         /** @var \Illuminate\Support\Collection<\App\Models\Country> */ | ||||||
|         // $countries = app('countries');
 |         $countries = app('countries'); | ||||||
| 
 | 
 | ||||||
|  |         return $countries; | ||||||
|  |          | ||||||
|         return \App\Models\Country::all()->each(function ($country) { |         return \App\Models\Country::all()->each(function ($country) { | ||||||
|             $country->name = ctrans('texts.country_'.$country->name); |             $country->name = ctrans('texts.country_'.$country->name); | ||||||
|         })->sortBy(function ($country) { |         })->sortBy(function ($country) { | ||||||
| @ -73,7 +75,8 @@ class TranslationHelper | |||||||
|     { |     { | ||||||
|          |          | ||||||
|         /** @var \Illuminate\Support\Collection<\App\Models\Currency> */ |         /** @var \Illuminate\Support\Collection<\App\Models\Currency> */ | ||||||
|         // $currencies = app('currencies');
 |         $currencies = app('currencies'); | ||||||
|  |         return $currencies; | ||||||
| 
 | 
 | ||||||
|         return \App\Models\Currency::all()->each(function ($currency) { |         return \App\Models\Currency::all()->each(function ($currency) { | ||||||
|             $currency->name = ctrans('texts.currency_'.Str::slug($currency->name, '_')); |             $currency->name = ctrans('texts.currency_'.Str::slug($currency->name, '_')); | ||||||
|  | |||||||
| @ -61,7 +61,7 @@ | |||||||
|                                     <option |                                     <option | ||||||
|                                         {{ $country == isset(auth()->user()->client->shipping_country->id) ? 'selected' : null }} value="{{ $country->id }}"> |                                         {{ $country == isset(auth()->user()->client->shipping_country->id) ? 'selected' : null }} value="{{ $country->id }}"> | ||||||
|                                         {{ $country->iso_3166_2 }} |                                         {{ $country->iso_3166_2 }} | ||||||
|                                         ({{ $country->name }}) |                                         ({{ $country->getName() }}) | ||||||
|                                     </option> |                                     </option> | ||||||
|                                 @endforeach |                                 @endforeach | ||||||
|                             </select> |                             </select> | ||||||
| @ -75,7 +75,7 @@ | |||||||
|                                     <option |                                     <option | ||||||
|                                         {{ $country == isset(auth()->user()->client->shipping_country->id) ? 'selected' : null }} value="{{ $country->id }}"> |                                         {{ $country == isset(auth()->user()->client->shipping_country->id) ? 'selected' : null }} value="{{ $country->id }}"> | ||||||
|                                         {{ $country->iso_3166_2 }} |                                         {{ $country->iso_3166_2 }} | ||||||
|                                         ({{ $country->name }}) |                                         ({{ $country->getName() }}) | ||||||
|                                     </option> |                                     </option> | ||||||
|                                 @endforeach |                                 @endforeach | ||||||
|                             </select> |                             </select> | ||||||
|  | |||||||
| @ -83,7 +83,7 @@ | |||||||
|                                         @foreach(App\Utils\TranslationHelper::getCountries() as $country) |                                         @foreach(App\Utils\TranslationHelper::getCountries() as $country) | ||||||
|                                             <option value="{{ $country->id }}"> |                                             <option value="{{ $country->id }}"> | ||||||
|                                                 {{ $country->iso_3166_2 }} |                                                 {{ $country->iso_3166_2 }} | ||||||
|                                                 ({{ $country->name }}) |                                                 ({{ $country->getName() }}) | ||||||
|                                             </option> |                                             </option> | ||||||
|                                         @endforeach |                                         @endforeach | ||||||
|                                     </select> |                                     </select> | ||||||
|  | |||||||
| @ -22,7 +22,7 @@ | |||||||
| 
 | 
 | ||||||
|                                 @foreach($countries as $country) |                                 @foreach($countries as $country) | ||||||
|                                     <option value="{{ $country->id }}"> |                                     <option value="{{ $country->id }}"> | ||||||
|                                         {{ $country->iso_3166_2 }} ({{ $country->name }}) |                                         {{ $country->iso_3166_2 }} ({{ $country->getName() }}) | ||||||
|                                     </option> |                                     </option> | ||||||
|                                 @endforeach |                                 @endforeach | ||||||
|                             </select> |                             </select> | ||||||
|  | |||||||
| @ -57,7 +57,7 @@ | |||||||
|         @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')]) |         @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> |             <select name="countries" id="country" name="country" class="form-select input w-full bg-white" required> | ||||||
|                 @foreach($countries as $country) |                 @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 |                 @endforeach | ||||||
|             </select> |             </select> | ||||||
|         @endcomponent |         @endcomponent | ||||||
| @ -65,7 +65,7 @@ | |||||||
|         @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.currency')]) |         @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.currency')]) | ||||||
|             <select name="currencies" id="currency" name="currency" class="form-select input w-full"> |             <select name="currencies" id="currency" name="currency" class="form-select input w-full"> | ||||||
|                 @foreach($currencies as $currency) |                 @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 |                 @endforeach | ||||||
|             </select> |             </select> | ||||||
|         @endcomponent |         @endcomponent | ||||||
|  | |||||||
| @ -51,9 +51,9 @@ | |||||||
|             <option disabled selected></option> |             <option disabled selected></option> | ||||||
|             @foreach($countries as $country) |             @foreach($countries as $country) | ||||||
|                 @if($country->iso_3166_2 == 'US') |                 @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 |                 @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 |                 @endif | ||||||
|             @endforeach |             @endforeach | ||||||
|         </select> |         </select> | ||||||
| @ -64,7 +64,7 @@ | |||||||
|             <option disabled selected></option> |             <option disabled selected></option> | ||||||
|             @foreach($currencies as $currency) |             @foreach($currencies as $currency) | ||||||
|                 @if($currency->code == 'USD') |                 @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 |                 @else | ||||||
|                     <option value="{{ $currency->code }}">{{ $currency->code }} ({{ $currency->name }})</option> |                     <option value="{{ $currency->code }}">{{ $currency->code }} ({{ $currency->name }})</option> | ||||||
|                 @endif |                 @endif | ||||||
|  | |||||||
| @ -47,7 +47,7 @@ | |||||||
|     @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')]) |     @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> |         <select name="countries" id="country" class="form-select input w-full bg-white" required> | ||||||
|             @foreach($countries as $country) |             @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 |             @endforeach | ||||||
|         </select> |         </select> | ||||||
|     @endcomponent |     @endcomponent | ||||||
| @ -55,7 +55,7 @@ | |||||||
|     @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.currency')]) |     @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.currency')]) | ||||||
|         <select name="currencies" id="currency" class="form-select input w-full"> |         <select name="currencies" id="currency" class="form-select input w-full"> | ||||||
|             @foreach($currencies as $currency) |             @foreach($currencies as $currency) | ||||||
|                 <option value="{{ $currency->code }}">{{ $currency->code }} ({{ $currency->name }})</option> |                 <option value="{{ $currency->code }}">{{ $currency->code }} ({{ $currency->getName() }})</option> | ||||||
|             @endforeach |             @endforeach | ||||||
|         </select> |         </select> | ||||||
|     @endcomponent |     @endcomponent | ||||||
|  | |||||||
| @ -47,7 +47,7 @@ | |||||||
|     @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')]) |     @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> |         <select name="countries" id="country" class="form-select input w-full bg-white" required> | ||||||
|             @foreach($countries as $country) |             @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 |             @endforeach | ||||||
|         </select> |         </select> | ||||||
|     @endcomponent |     @endcomponent | ||||||
| @ -55,7 +55,7 @@ | |||||||
|     @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.currency')]) |     @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.currency')]) | ||||||
|         <select name="currencies" id="currency" class="form-select input w-full"> |         <select name="currencies" id="currency" class="form-select input w-full"> | ||||||
|             @foreach($currencies as $currency) |             @foreach($currencies as $currency) | ||||||
|                 <option value="{{ $currency->code }}">{{ $currency->code }} ({{ $currency->name }})</option> |                 <option value="{{ $currency->code }}">{{ $currency->code }} ({{ $currency->getName() }})</option> | ||||||
|             @endforeach |             @endforeach | ||||||
|         </select> |         </select> | ||||||
|     @endcomponent |     @endcomponent | ||||||
|  | |||||||
| @ -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"> |                 <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> |                     <option value="{{ $client->country->id}}" selected>{{ $client->country->iso_3166_2 }} ({{ $client->country->name }})</option> | ||||||
|                     @foreach($countries as $country) |                     @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 |                     @endforeach | ||||||
|                 </select> |                 </select> | ||||||
|               </div> |               </div> | ||||||
|  | |||||||
| @ -28,8 +28,8 @@ | |||||||
|     @livewire('profile.settings.general') |     @livewire('profile.settings.general') | ||||||
| 
 | 
 | ||||||
|     <!-- Client personal address --> |     <!-- Client personal address --> | ||||||
|     @livewire('profile.settings.personal-address', ['countries' => $countries]) |     @livewire('profile.settings.personal-address') | ||||||
| 
 | 
 | ||||||
|     <!-- Client shipping address --> |     <!-- Client shipping address --> | ||||||
|     @livewire('profile.settings.shipping-address', ['countries' => $countries]) |     @livewire('profile.settings.shipping-address') | ||||||
| @endsection | @endsection | ||||||
|  | |||||||
| @ -61,7 +61,7 @@ | |||||||
|                                 <option value="none"></option> |                                 <option value="none"></option> | ||||||
|                                 @foreach($countries as $country) |                                 @foreach($countries as $country) | ||||||
|                                     <option value="{{ $country->id }}"> |                                     <option value="{{ $country->id }}"> | ||||||
|                                         {{ $country->iso_3166_2 }} ({{ $country->name }}) |                                         {{ $country->iso_3166_2 }} ({{ $country->getName() }}) | ||||||
|                                     </option> |                                     </option> | ||||||
|                                 @endforeach |                                 @endforeach | ||||||
|                             </select> |                             </select> | ||||||
|  | |||||||
| @ -62,7 +62,7 @@ | |||||||
|                                     <option value="none"></option> |                                     <option value="none"></option> | ||||||
|                                     @foreach($countries as $country) |                                     @foreach($countries as $country) | ||||||
|                                     <option value="{{ $country->id }}"> |                                     <option value="{{ $country->id }}"> | ||||||
|                                         {{ $country->iso_3166_2 }} ({{ $country->name }}) |                                         {{ $country->iso_3166_2 }} ({{ $country->getName() }}) | ||||||
|                                     </option> |                                     </option> | ||||||
|                                     @endforeach |                                     @endforeach | ||||||
|                                 </select> |                                 </select> | ||||||
|  | |||||||
| @ -152,7 +152,7 @@ | |||||||
|                                 <option value="none"></option> |                                 <option value="none"></option> | ||||||
|                                 @foreach($countries as $country) |                                 @foreach($countries as $country) | ||||||
|                                     <option value="{{ $country->id }}" @if($vendor->country_id == $country->id) selected @endif> |                                     <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> |                                     </option> | ||||||
|                                 @endforeach |                                 @endforeach | ||||||
|                             </select> |                             </select> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user