From d1cb62b4445e4322a4ead57c1faa4a112cf0f278 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 7 Dec 2017 12:33:46 +0200 Subject: [PATCH] Localization fixes --- app/Models/Currency.php | 9 +++++++++ app/Models/InvoiceStatus.php | 11 ++++++++++- app/Models/User.php | 2 +- resources/lang/en/texts.php | 1 + resources/views/expenses/edit.blade.php | 2 +- resources/views/master.blade.php | 1 + resources/views/payments/edit.blade.php | 7 ++++++- resources/views/reports/d3.blade.php | 16 ++++++++-------- 8 files changed, 37 insertions(+), 12 deletions(-) diff --git a/app/Models/Currency.php b/app/Models/Currency.php index 6992a8cd74..77d99d543a 100644 --- a/app/Models/Currency.php +++ b/app/Models/Currency.php @@ -3,6 +3,7 @@ namespace App\Models; use Eloquent; +use Str; /** * Class Currency. @@ -28,4 +29,12 @@ class Currency extends Eloquent { return $this->name; } + + /** + * @return mixed + */ + public function getTranslatedName() + { + return trans('texts.currency_' . Str::slug($this->name, '_')); + } } diff --git a/app/Models/InvoiceStatus.php b/app/Models/InvoiceStatus.php index 302b79ca9f..9b0132ae08 100644 --- a/app/Models/InvoiceStatus.php +++ b/app/Models/InvoiceStatus.php @@ -3,6 +3,7 @@ namespace App\Models; use Eloquent; +use Str; /** * Class InvoiceStatus. @@ -33,6 +34,14 @@ class InvoiceStatus extends Eloquent return INVOICE_STATUS_UNPAID; default: return false; - } + } + } + + /** + * @return mixed + */ + public function getTranslatedName() + { + return trans('texts.status_' . Str::slug($this->name, '_')); } } diff --git a/app/Models/User.php b/app/Models/User.php index 2501448e9a..4b0c8bdbc0 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -178,7 +178,7 @@ class User extends Authenticatable } elseif ($this->email) { return $this->email; } else { - return 'Guest'; + return trans('texts.guest'); } } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 276995ae77..9b0cff0859 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2609,6 +2609,7 @@ $LANG = array( 'copy_shipping' => 'Copy Shipping', 'copy_billing' => 'Copy Billing', 'quote_has_expired' => 'The quote has expired, please contact the merchant.', + 'empty_table_footer' => 'Showing 0 to 0 of 0 entries', ); diff --git a/resources/views/expenses/edit.blade.php b/resources/views/expenses/edit.blade.php index d3a79b76ef..b855b1d258 100644 --- a/resources/views/expenses/edit.blade.php +++ b/resources/views/expenses/edit.blade.php @@ -55,7 +55,7 @@ {!! Former::select('expense_currency_id')->addOption('','') ->data_bind('combobox: expense_currency_id') ->label(trans('texts.currency_id')) - ->data_placeholder(Utils::getFromCache($account->getCurrencyId(), 'currencies')->name) + ->data_placeholder(Utils::getFromCache($account->getCurrencyId(), 'currencies')->getTranslatedName()) ->fromQuery($currencies, 'name', 'id') !!} @if (! $isRecurring) diff --git a/resources/views/master.blade.php b/resources/views/master.blade.php index b88433ef12..e309a76716 100644 --- a/resources/views/master.blade.php +++ b/resources/views/master.blade.php @@ -124,6 +124,7 @@ "bInfo": true, "oLanguage": { 'sEmptyTable': "{{ trans('texts.empty_table') }}", + 'sInfoEmpty': "{{ trans('texts.empty_table_footer') }}", 'sLengthMenu': '_MENU_ {{ trans('texts.rows') }}', 'sInfo': "{{ trans('texts.datatable_info', ['start' => '_START_', 'end' => '_END_', 'total' => '_TOTAL_']) }}", 'sSearch': '' diff --git a/resources/views/payments/edit.blade.php b/resources/views/payments/edit.blade.php index aeee5e4413..10d2422d0f 100644 --- a/resources/views/payments/edit.blade.php +++ b/resources/views/payments/edit.blade.php @@ -138,6 +138,11 @@ var clientMap = {}; var invoiceMap = {}; var invoicesForClientMap = {}; + var statuses = []; + + @foreach (cache('invoiceStatus') as $status) + statuses[{{ $status->id }}] = "{{ $status->getTranslatedName() }}"; + @endforeach for (var i=0; i