From 8eb020211f392c2bbfda6cba85de89fcb631820a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Tue, 29 Dec 2020 11:54:36 +0300 Subject: [PATCH] Select Contact Card dynamic language text --- .../View/Components/DocumentForm.php | 44 ++++++++++++++---- app/View/Components/SelectContactCard.php | 46 ++++++++++++++----- .../js/components/AkauntingContactCard.vue | 4 +- resources/lang/en-GB/general.php | 6 +++ .../documents/form/metadata.blade.php | 10 ++-- .../components/select-contact-card.blade.php | 10 ++-- 6 files changed, 87 insertions(+), 33 deletions(-) diff --git a/app/Abstracts/View/Components/DocumentForm.php b/app/Abstracts/View/Components/DocumentForm.php index 2f841df0c..97f5b2665 100644 --- a/app/Abstracts/View/Components/DocumentForm.php +++ b/app/Abstracts/View/Components/DocumentForm.php @@ -368,10 +368,16 @@ abstract class DocumentForm extends Component case 'bill': case 'expense': case 'purchase': - $textAddContact = 'vendor'; + $textAddContact = [ + 'general.form.add', + 'general.vendors' + ]; break; default: - $textAddContact = 'customer'; + $textAddContact = [ + 'general.form.add', + 'general.customers' + ]; break; } @@ -388,10 +394,16 @@ abstract class DocumentForm extends Component case 'bill': case 'expense': case 'purchase': - $textCreateNewContact = 'vendor'; + $textCreateNewContact = [ + 'general.form.add_new', + 'general.vendors' + ]; break; default: - $textCreateNewContact = 'customer'; + $textCreateNewContact = [ + 'general.form.add_new', + 'general.customers' + ]; break; } @@ -408,10 +420,16 @@ abstract class DocumentForm extends Component case 'bill': case 'expense': case 'purchase': - $textEditContact = 'vendor'; + $textEditContact = [ + 'general.form.contact_edit', + 'general.vendors' + ]; break; default: - $textEditContact = 'customer'; + $textEditContact = [ + 'general.form.contact_edit', + 'general.customers' + ]; break; } @@ -428,10 +446,10 @@ abstract class DocumentForm extends Component case 'bill': case 'expense': case 'purchase': - $textContactInfo = 'vendor'; + $textContactInfo = 'bills.bill_from'; break; default: - $textContactInfo = 'customer'; + $textContactInfo = 'invoices.bill_to'; break; } @@ -448,10 +466,16 @@ abstract class DocumentForm extends Component case 'bill': case 'expense': case 'purchase': - $textChooseDifferentContact = 'vendor'; + $textChooseDifferentContact = [ + 'general.form.choose_different', + 'general.vendors' + ]; break; default: - $textChooseDifferentContact = 'customer'; + $textChooseDifferentContact = [ + 'general.form.choose_different', + 'general.customers' + ]; break; } diff --git a/app/View/Components/SelectContactCard.php b/app/View/Components/SelectContactCard.php index c8948eb8a..516740e61 100644 --- a/app/View/Components/SelectContactCard.php +++ b/app/View/Components/SelectContactCard.php @@ -42,7 +42,7 @@ class SelectContactCard extends Component */ public function __construct( $type, $contact = false, $contacts = [], $search_route = '', $create_route = '', - string $textAddContact = '', string $textCreateNewContact = '', string $textEditContact = '', string $textContactInfo = '', string $textChooseDifferentContact = '' + $textAddContact = '', $textCreateNewContact = '', $textEditContact = '', $textContactInfo = '', $textChooseDifferentContact = '' ) { $this->type = $type; @@ -107,10 +107,16 @@ class SelectContactCard extends Component case 'bill': case 'expense': case 'purchase': - $textAddContact = 'vendor'; + $textAddContact = [ + 'general.form.add', + 'general.vendors' + ]; break; default: - $textAddContact = 'customer'; + $textAddContact = [ + 'general.form.add', + 'general.customers' + ]; break; } @@ -127,10 +133,16 @@ class SelectContactCard extends Component case 'bill': case 'expense': case 'purchase': - $textCreateNewContact = 'vendor'; + $textCreateNewContact = [ + 'general.form.add_new', + 'general.vendors' + ]; break; default: - $textCreateNewContact = 'customer'; + $textCreateNewContact = [ + 'general.form.add_new', + 'general.customers' + ]; break; } @@ -147,10 +159,16 @@ class SelectContactCard extends Component case 'bill': case 'expense': case 'purchase': - $textEditContact = 'vendor'; + $textEditContact = [ + 'general.form.contact_edit', + 'general.vendors' + ]; break; default: - $textEditContact = 'customer'; + $textEditContact = [ + 'general.form.contact_edit', + 'general.customers' + ]; break; } @@ -167,10 +185,10 @@ class SelectContactCard extends Component case 'bill': case 'expense': case 'purchase': - $textContactInfo = 'vendor'; + $textContactInfo = 'bills.bill_from'; break; default: - $textContactInfo = 'customer'; + $textContactInfo = 'invoices.bill_to'; break; } @@ -187,10 +205,16 @@ class SelectContactCard extends Component case 'bill': case 'expense': case 'purchase': - $textChooseDifferentContact = 'vendor'; + $textChooseDifferentContact = [ + 'general.form.choose_different', + 'general.vendors' + ]; break; default: - $textChooseDifferentContact = 'customer'; + $textChooseDifferentContact = [ + 'general.form.choose_different', + 'general.customers' + ]; break; } diff --git a/resources/assets/js/components/AkauntingContactCard.vue b/resources/assets/js/components/AkauntingContactCard.vue index c5a9bf236..2a603618e 100644 --- a/resources/assets/js/components/AkauntingContactCard.vue +++ b/resources/assets/js/components/AkauntingContactCard.vue @@ -105,7 +105,7 @@  •  - + @@ -224,7 +224,7 @@ export default { default: 'Tax number', description: "" }, - chooseDiffentContactText: { + chooseDifferentContactText: { type: String, default: 'Choose a different customer', description: "" diff --git a/resources/lang/en-GB/general.php b/resources/lang/en-GB/general.php index 56dea81ac..ecb7051ee 100644 --- a/resources/lang/en-GB/general.php +++ b/resources/lang/en-GB/general.php @@ -185,7 +185,13 @@ return [ 'field' => '- Select :field -', 'file' => 'Select File', ], + 'add' => 'Add a :field', + 'add_an' => 'Add an :field', 'add_new' => 'Add New :field', + 'edit' => 'Edit :field', + 'contact_edit' => 'Edit :contact_name :field', + 'choose' => 'Choose :field', + 'choose_different' => 'Choose a different :field', 'no_file_selected' => 'No file selected...', ], diff --git a/resources/views/components/documents/form/metadata.blade.php b/resources/views/components/documents/form/metadata.blade.php index e15bd81f3..8b6f4a270 100644 --- a/resources/views/components/documents/form/metadata.blade.php +++ b/resources/views/components/documents/form/metadata.blade.php @@ -8,11 +8,11 @@ :contacts="$contacts" :search_route="$contactSearchRoute" :create_route="$contactCreateRoute" - text-add-contact="{{ $textAddContact }}" - text-create-new-contact="{{ $textCreateNewContact }}" - text-edit-contact="{{ $textEditContact }}" - text-contact-info="{{ $textContactInfo }}" - text-choose-different-contact="{{ $textChooseDifferentContact }}" + :text-add-contact="$textAddContact" + :text-create-new-contact="$textCreateNewContact" + :text-edit-contact="$textEditContact" + :text-contact-info="$textContactInfo" + :text-choose-different-contact="$textChooseDifferentContact" /> @endif diff --git a/resources/views/components/select-contact-card.blade.php b/resources/views/components/select-contact-card.blade.php index be12f9c0c..89414ee0c 100644 --- a/resources/views/components/select-contact-card.blade.php +++ b/resources/views/components/select-contact-card.blade.php @@ -6,12 +6,12 @@ create-route="{{ $create_route }}" :contacts="{{ json_encode($contacts) }}" :selected="{{ json_encode($contact) }}" - add-contact-text="{{ $textAddContact }}" - create-new-contact-text="{{ $textCreateNewContact }}" - edit-contact-text="{{ $textEditContact }}" - contact-info-text="{{ $textContactInfo }}" + add-contact-text="{{ is_array($textAddContact) ? trans($textAddContact[0], ['field' => trans_choice($textAddContact[1], 1)]) : trans($textAddContact) }}" + create-new-contact-text="{{ is_array($textCreateNewContact) ? trans($textCreateNewContact[0], ['field' => trans_choice($textCreateNewContact[1], 1)]) : trans($textCreateNewContact) }}" + edit-contact-text="{{ is_array($textEditContact) ? trans($textEditContact[0], ['field' => trans_choice($textEditContact[1], 1)]) : trans($textEditContact) }}" + contact-info-text="{{ is_array($textContactInfo) ? trans($textContactInfo[0], ['field' => trans_choice($textContactInfo[1], 1)]) : trans($textContactInfo) }}" tax-number-text="{{ trans('general.tax_number') }}" - choose-different-contact-text="{{ $textChooseDifferentContact }}" + choose-different-contact-text="{{ is_array($textChooseDifferentContact) ? trans($textChooseDifferentContact[0], ['field' => trans_choice($textChooseDifferentContact[1], 1)]) : trans($textChooseDifferentContact) }}" :add-new="{{ json_encode([ 'status' => true, 'text' => trans('general.add_new'),