1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02:00

Merge pull request #4755 from turbo124/v5-develop

Translations
This commit is contained in:
David Bomba 2021-01-25 15:21:51 +11:00 committed by GitHub
commit c57c66d1b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 88 additions and 281 deletions

View File

@ -307,6 +307,14 @@ class DemoMode extends Command
'client_id' => $client->id,
'company_id' => $client->company_id,
]);
Expense::all()->each(function ($expense){
$expense->number = $this->getNextExpenseNumber($expense);
$expense->save();
});
}
private function createVendor($client, $assigned_user_id = null)
@ -329,15 +337,23 @@ class DemoMode extends Command
'company_id' => $client->company_id,
'is_primary' => 0,
]);
$vendor->id_number = $this->getNextVendorNumber($vendor);
$vendor->save();
}
private function createTask($client, $assigned_user_id = null)
{
$vendor = Task::factory()->create([
$task = Task::factory()->create([
'user_id' => $client->user->id,
'company_id' => $client->company_id,
'client_id' => $client->id
]);
$task->number = $this->getNextTaskNumber($task);
$task->save();
}
private function createProject($client, $assigned_user_id = null)

View File

@ -13,6 +13,7 @@ namespace App\Events\Invoice;
use App\Models\Company;
use App\Models\Invoice;
use App\Models\Payment;
use Illuminate\Queue\SerializesModels;
/**
@ -27,6 +28,8 @@ class InvoiceWasPaid
*/
public $invoice;
public $payment;
public $company;
public $event_vars;
@ -38,9 +41,10 @@ class InvoiceWasPaid
* @param Company $company
* @param array $event_vars
*/
public function __construct(Invoice $invoice, Company $company, array $event_vars)
public function __construct(Invoice $invoice, Payment $payment, Company $company, array $event_vars)
{
$this->invoice = $invoice;
$this->payment = $payment;
$this->company = $company;
$this->event_vars = $event_vars;
}

View File

@ -136,7 +136,7 @@ class ActivityController extends BaseController
$backup = $activity->backup;
if (! $backup || ! $backup->html_backup) {
return response()->json(['message'=> 'No backup exists for this activity', 'errors' => new stdClass], 404);
return response()->json(['message'=> ctrans('texts.no_backup_exists'), 'errors' => new stdClass], 404);
}
$pdf = $this->makePdf(null, null, $backup->html_backup);

View File

@ -150,7 +150,7 @@ class BaseController extends Controller
*/
public function notFound()
{
return response()->json(['message' => '404 | Nothing to see here!'], 404)
return response()->json(['message' => ctrans('texts.api_404')], 404)
->header('X-API-VERSION', config('ninja.minimum_client_version'))
->header('X-APP-VERSION', config('ninja.app_version'));
}
@ -198,7 +198,7 @@ class BaseController extends Controller
$updated_at = request()->has('updated_at') ? request()->input('updated_at') : 0;
if (auth()->user()->getCompany()->is_large && ! request()->has('updated_at')) {
return response()->json(['message' => 'Cannot load a large account without a updated_at parameter', 'errors' =>[]], 401);
return response()->json(['message' => ctrans('texts.large_account_update_parameter'), 'errors' =>[]], 401);
}
$updated_at = date('Y-m-d H:i:s', $updated_at);

View File

@ -501,6 +501,6 @@ class CompanyController extends BaseController
}
}
return response()->json(['message' => 'success'], 200);
return response()->json(['message' => ctrans('texts.success')], 200);
}
}

View File

@ -115,7 +115,7 @@ class CompanyUserController extends BaseController
$company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first();
if (! $company_user) {
throw new ModelNotFoundException('Company User record not found');
throw new ModelNotFoundException(ctrans('texts.company_user_not_found'));
return;
}

View File

@ -484,7 +484,7 @@ class CreditController extends BaseController
$credits = Credit::withTrashed()->whereIn('id', $this->transformKeys($ids));
if (! $credits) {
return response()->json(['message' => 'No Credits Found']);
return response()->json(['message' => ctrans('texts.no_credits_found')]);
}
$credits->each(function ($credit, $key) use ($action) {
@ -561,7 +561,7 @@ class CreditController extends BaseController
break;
default:
return response()->json(['message' => "The requested action `{$action}` is not available."], 400);
return response()->json(['message' => ctrans('texts.action_unavailable', ['action' => $action])], 400);
break;
}
}

View File

@ -124,7 +124,7 @@ class DocumentController extends BaseController
{
$this->document_repo->delete($document);
return response()->json(['message'=>'success']);
return response()->json(['message'=> ctrans('texts.success')]);
}
public function bulk()
@ -136,7 +136,7 @@ class DocumentController extends BaseController
$documents = Document::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get();
if (! $invoices) {
return response()->json(['message' => 'No Documents Found']);
return response()->json(['message' => ctrans('texts.no_documents_found')]);
}
/*

View File

@ -481,7 +481,7 @@ class GroupSettingController extends BaseController
$group_settings = GroupSetting::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get();
if (! $group_settings) {
return response()->json(['message' => 'No Group Settings Found']);
return response()->json(['message' => ctrans('texts.no_group_settings_found')]);
}
/*

View File

@ -95,7 +95,7 @@ class ImportController extends Controller
{
CSVImport::dispatch($request->all(), auth()->user()->company());
return response()->json(['message' => 'Importing data, email will be sent on completion'], 200);
return response()->json(['message' => ctrans('texts.import_started')], 200);
}
private function getEntityMap($entity_type)

View File

@ -387,7 +387,7 @@ class InvoiceController extends BaseController
}
if ($invoice->isLocked()) {
return response()->json(['message' => 'Invoice is locked, no modifications allowed']);
return response()->json(['message' => ctrans('texts.locked_invoice')]);
}
$invoice = $this->invoice_repo->save($request->all(), $invoice);
@ -526,13 +526,13 @@ class InvoiceController extends BaseController
if ($action == 'download' && $invoices->count() > 1) {
$invoices->each(function ($invoice) {
if (auth()->user()->cannot('view', $invoice)) {
return response()->json(['message' => 'Insufficient privileges to access invoice '.$invoice->number]);
return response()->json(['message' => ctrans('text.access_denied')]);
}
});
ZipInvoices::dispatch($invoices, $invoices->first()->company, auth()->user()->email);
return response()->json(['message' => 'Email Sent!'], 200);
return response()->json(['message' => ctrans('texts.sent_message')], 200);
}
/*
@ -649,7 +649,7 @@ class InvoiceController extends BaseController
break;
case 'mark_paid':
if ($invoice->balance < 0 || $invoice->status_id == Invoice::STATUS_PAID || $invoice->is_deleted === true) {
return $this->errorResponse(['message' => 'Invoice cannot be marked as paid'], 400);
return $this->errorResponse(['message' => ctrans('texts.invoice_cannot_be_marked_paid')], 400);
}
$invoice = $invoice->service()->markPaid();
@ -686,9 +686,7 @@ class InvoiceController extends BaseController
}
break;
case 'delete':
//need to make sure the invoice is cancelled first!!
//$invoice->service()->handleCancellation()s->save();
nlog("inside delete");
$this->invoice_repo->delete($invoice);
if (! $bulk) {
@ -735,7 +733,7 @@ nlog("inside delete");
break;
default:
return response()->json(['message' => "The requested action `{$action}` is not available."], 400);
return response()->json(['message' => ctrans('texts.action_unavailable', ['action' => $action])], 400);
break;
}
}

View File

@ -134,7 +134,7 @@ class LicenseController extends BaseController
}
$error = [
'message' => 'Invalid license, or invalid environment '.config('ninja.environment'),
'message' => ctrans('texts.invoice_license_or_environment', ['environment' => config('ninja.environment')]),
'errors' => new stdClass,
];

View File

@ -74,7 +74,7 @@ class PingController extends BaseController
public function health()
{
if (Ninja::isNinja()) {
return response()->json(['message' => 'Route not available', 'errors'=>[]], 403);
return response()->json(['message' => ctrans('texts.route_not_available'), 'errors'=>[]], 403);
}
return response()->json(SystemHealth::check(), 200);

View File

@ -81,7 +81,7 @@ class PreviewController extends BaseController
$design_object = json_decode(json_encode(request()->input('design')));
if (! is_object($design_object)) {
return response()->json(['message' => 'Invalid custom design object'], 400);
return response()->json(['message' => ctrans('texts.invalid_design_object')], 400);
}
$entity = ucfirst(request()->input('entity'));

View File

@ -507,7 +507,7 @@ class QuoteController extends BaseController
$quotes = Quote::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get();
if (! $quotes) {
return response()->json(['message' => 'No Quote/s Found']);
return response()->json(['message' => ctrans('texts.quote_not_found')]);
}
/*
@ -517,13 +517,13 @@ class QuoteController extends BaseController
if ($action == 'download' && $quotes->count() >= 1) {
$quotes->each(function ($quote) {
if (auth()->user()->cannot('view', $quote)) {
return response()->json(['message'=>'Insufficient privileges to access quote '.$quote->number]);
return response()->json(['message'=> ctrans('texts.access_denied')]);
}
});
ZipInvoices::dispatch($quotes, $quotes->first()->company, auth()->user()->email);
return response()->json(['message' => 'Email Sent!'], 200);
return response()->json(['message' => ctrans('texts.sent_message')], 200);
}
if ($action == 'convert') {
@ -651,7 +651,7 @@ class QuoteController extends BaseController
case 'approve':
//make sure it hasn't already been approved!!
if ($quote->status_id != Quote::STATUS_SENT) {
return response()->json(['message' => 'Unable to approve this quote as it has expired.'], 400);
return response()->json(['message' => ctrans('texts.quote_unapprovable')], 400);
}
return $this->itemResponse($quote->service()->approve()->save());
@ -692,7 +692,7 @@ class QuoteController extends BaseController
case 'email':
$quote->service()->sendEmail();
return response()->json(['message'=>'email sent'], 200);
return response()->json(['message'=> ctrans('texts.sent_message')], 200);
break;
case 'mark_sent':
$quote->service()->markSent()->save();
@ -702,7 +702,7 @@ class QuoteController extends BaseController
}
break;
default:
return response()->json(['message' => "The requested action `{$action}` is not available."], 400);
return response()->json(['message' => ctrans('texts.action_unavailable',['action' => $action])], 400);
break;
}
}

View File

@ -7,9 +7,9 @@ class SchedulerController extends Controller
public function index()
{
if (auth()->user()->company()->account->latest_version == '0.0.0') {
return response()->json(['message' => 'Scheduler has never run'], 400);
return response()->json(['message' => ctrans('texts.scheduler_has_never_run')], 400);
} else {
return response()->json(['message' => 'Scheduler has run'], 200);
return response()->json(['message' => ctrans('texts.scheduler_has_run')], 200);
}
}
}

View File

@ -59,7 +59,7 @@ class SelfUpdateController extends BaseController
define('STDIN', fopen('php://stdin', 'r'));
if (Ninja::isNinja()) {
return response()->json(['message' => 'Self update not available on this system.'], 403);
return response()->json(['message' => ctrans('texts.self_update_not_available')], 403);
}
/* .git MUST be owned/writable by the webserver user */

View File

@ -1,101 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Controllers;
use Illuminate\Http\Request;
/**
* Class SettingsController.
*/
class SettingsController extends BaseController
{
public function __construct()
{
parent::__construct();
}
/**
* Display a listing of the resource.
*
* @return void
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return void
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return void
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return void
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return void
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return void
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return void
*/
public function destroy($id)
{
//
}
}

View File

@ -1,123 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
/**
* Class TranslationController.
*/
class TranslationController extends BaseController
{
public function __construct()
{
parent::__construct();
}
/**
* Display a listing of the resource.
*
* @return void
*/
public function index()
{
$strings = Cache::rememberForever('lang.js', function () {
$lang = config('app.locale');
$files = glob(resource_path('lang/'.$lang.'/*.php'));
$strings = [];
foreach ($files as $file) {
$name = basename($file, '.php');
$strings[$name] = require $file;
}
return $strings;
});
header('Content-Type: text/javascript');
echo 'i18n = '.$this->easyMinify(json_encode($strings)).';';
exit();
}
private function easyMinify($javascript)
{
return preg_replace(["/\s+\n/", "/\n\s+/", '/ +/'], ["\n", "\n ", ' '], $javascript);
}
/**
* Show the form for creating a new resource.
*
* @return void
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return void
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return void
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return void
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return void
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return void
*/
public function destroy($id)
{
//
}
}

View File

@ -668,6 +668,6 @@ class UserController extends BaseController
$company_user->delete();
}
return response()->json(['message' => 'User detached from company'], 200);
return response()->json(['message' => ctrans('texts.user_detached')], 200);
}
}

View File

@ -364,7 +364,7 @@ class WebhookController extends BaseController
$webhook->save();
if (! $webhook->id) {
return response()->json('Failed to create Webhook', 400);
return response()->json(ctrans('texts.create_webhook_failure'), 400);
}
return $this->itemResponse($webhook);

View File

@ -25,13 +25,4 @@ class EditClientRequest extends Request
return auth()->user()->can('edit', $this->client);
}
// public function prepareForValidation()
// {
// $input = $this->all();
// //$input['id'] = $this->encodePrimaryKey($input['id']);
// $this->replace($input);
// }
}

View File

@ -47,6 +47,7 @@ class InvoicePaidActivity implements ShouldQueue
$fields->user_id = $event->invoice->user_id;
$fields->company_id = $event->invoice->company_id;
$fields->activity_type_id = Activity::PAID_INVOICE;
$fields->payment_id = $event->payment->id;
$this->activity_repo->save($fields, $event->invoice, $event->event_vars);

View File

@ -187,7 +187,7 @@ class BaseDriver extends AbstractPaymentDriver
$payment->invoices()->sync($invoices);
$invoices->each(function ($invoice) use ($payment) {
event(new InvoiceWasPaid($invoice, $payment->company, Ninja::eventVars()));
event(new InvoiceWasPaid($invoice, $payment, $payment->company, Ninja::eventVars()));
});
return $payment->service()->applyNumber()->save();

View File

@ -148,7 +148,7 @@ class ApplyPayment
if ((int)$this->invoice->balance == 0) {
$this->invoice->service()->deletePdf();
event(new InvoiceWasPaid($this->invoice, $this->payment->company, Ninja::eventVars()));
event(new InvoiceWasPaid($this->invoice, $payment, $this->payment->company, Ninja::eventVars()));
}
}
}

View File

@ -80,7 +80,7 @@ class MarkPaid extends AbstractService
/* Update Invoice balance */
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
event(new InvoiceWasPaid($this->invoice, $payment->company, Ninja::eventVars()));
event(new InvoiceWasPaid($this->invoice, $payment, $payment->company, Ninja::eventVars()));
$payment->ledger()
->updatePaymentBalance($payment->amount * -1);

View File

@ -98,12 +98,12 @@ class VendorTransformer extends EntityTransformer
'custom_value3' => $vendor->custom_value3 ?: '',
'custom_value4' => $vendor->custom_value4 ?: '',
'is_deleted' => (bool) $vendor->is_deleted,
'vat_number' => $vendor->vat_number ?: '',
'id_number' => $vendor->id_number ?: '',
'vat_number' => (string) $vendor->vat_number ?: '',
'id_number' => (string) $vendor->id_number ?: '',
'updated_at' => (int) $vendor->updated_at,
'archived_at' => (int) $vendor->deleted_at,
'created_at' => (int) $vendor->created_at,
'number' => (string)$vendor->number ?: '',
'number' => (string) $vendor->number ?: '',
];
}
}

View File

@ -188,6 +188,7 @@ class HtmlEngine
$data['$invoice.custom4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice4', $this->entity->custom_value4, $this->client) ?: '&nbsp;', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice4')];
$data['$invoice.public_notes'] = ['value' => nl2br($this->entity->public_notes) ?: '&nbsp;', 'label' => ctrans('texts.public_notes')];
$data['$entity.public_notes'] = &$data['$invoice.public_notes'];
$data['$public_notes'] = &$data['$invoice.public_notes'];
$data['$entity_issued_to'] = ['value' => '', 'label' => ctrans("texts.{$this->entity_string}_issued_to")];
$data['$your_entity'] = ['value' => '', 'label' => ctrans("texts.your_{$this->entity_string}")];

View File

@ -3407,4 +3407,26 @@ return [
'invoice_cannot_be_refunded' => 'Invoice id :number cannot be refunded',
'attempted_refund_failed' => 'Attempting to refund :amount only :refundable_amount available for refund',
'user_not_associated_with_this_account' => 'This user is unable to be attached to this company. Perhaps they have already registered a user on another account?',
'migration_completed' => 'Migration completed',
'migration_completed_description' => 'Your migration has completed, please review your data after logging in.',
'api_404' => '404 | Nothing to see here!',
'large_account_update_parameter' => 'Cannot load a large account without a updated_at parameter',
'no_backup_exists' => 'No backup exists for this activity',
'company_user_not_found' => 'Company User record not found',
'no_credits_found' => 'No credits found.',
'action_unavailable' => 'The requested action :action is not available.',
'no_documents_found' => 'No Documents Found',
'no_group_settings_found' => 'No group settings found',
'access_denied' => 'Insufficient privileges to access/modify this resource',
'invoice_cannot_be_marked_paid' => 'Invoice cannot be marked as paid',
'invoice_license_or_environment' => 'Invalid license, or invalid environment :environment',
'route_not_available' => 'Route not available',
'invalid_design_object' => 'Invalid custom design object',
'quote_not_found' => 'Quote/s not found',
'quote_unapprovable' => 'Unable to approve this quote as it has expired.',
'scheduler_has_run' => 'Scheduler has run',
'scheduler_has_never_run' => 'Scheduler has never run',
'self_update_not_available' => 'Self update not available on this system.',
'user_detached' => 'User detached from company',
'create_webhook_failure' => 'Failed to create Webhook',
];

View File

@ -4,10 +4,10 @@
@include('email.components.header', ['logo' => 'https://www.invoiceninja.com/wp-content/uploads/2015/10/logo-white-horizontal-1.png'])
@endslot
<h1>Migration completed</h1>
<p>We're happy to inform you that migration has been completed successfully. It is ready for you to review it.</p>
<h1>{{ ctrans('texts.migration_completed')}}</h1>
<p>{{ ctrans('texts.migration_completed_description')}}</p>
<a href="{{ url('/') }}" target="_blank" class="button">Visit portal</a>
<a href="{{ url('/') }}" target="_blank" class="button">{{ ctrans('texts.account_login')}}</a>
<p>Thank you, <br/> Invoice Ninja</p>
<p>{{ ctrans('texts.email_signature')}}<br/> {{ ctrans('texts.email_from') }}</p>
@endcomponent

View File

@ -178,8 +178,6 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
Route::post('tasks/bulk', 'TaskController@bulk')->name('tasks.bulk');
Route::get('settings', 'SettingsController@index')->name('user.settings');
*/
Route::get('scheduler', 'SchedulerController@index');
Route::post('support/messages/send', 'Support\Messages\SendingController');