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(); | ||||
|         } 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(); | ||||
|  | ||||
| @ -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()); | ||||
| 
 | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -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'), | ||||
|         ]); | ||||
|     } | ||||
|  | ||||
| @ -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'), | ||||
|         ]); | ||||
|     } | ||||
|  | ||||
| @ -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
											
										
									
								
							| @ -482,6 +482,8 @@ class TemplateService | ||||
|                 default => $processed = [], | ||||
|             }; | ||||
| 
 | ||||
|             nlog(json_encode($processed)); | ||||
| 
 | ||||
|             return $processed; | ||||
| 
 | ||||
|         })->toArray(); | ||||
|  | ||||
| @ -34,7 +34,9 @@ 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); | ||||
| @ -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, '_')); | ||||
|  | ||||
| @ -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> | ||||
|  | ||||
| @ -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> | ||||
|  | ||||
| @ -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> | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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> | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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> | ||||
|  | ||||
| @ -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> | ||||
|  | ||||
| @ -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> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user