mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Merge pull request #5443 from turbo124/v5-develop
Custom Translations in emails
This commit is contained in:
commit
ec471283ba
@ -11,11 +11,14 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\TemplateEngine;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesInvoiceHtml;
|
||||
use App\Utils\Traits\MakesTemplateData;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
|
||||
class TemplateController extends BaseController
|
||||
{
|
||||
@ -89,7 +92,7 @@ class TemplateController extends BaseController
|
||||
$subject = request()->has('subject') ? request()->input('subject') : '';
|
||||
$body = request()->has('body') ? request()->input('body') : '';
|
||||
$template = request()->has('template') ? request()->input('template') : '';
|
||||
|
||||
|
||||
$data = (new TemplateEngine($body, $subject, $entity, $entity_id, $template))->build();
|
||||
|
||||
return response()->json($data, 200);
|
||||
|
@ -12,7 +12,10 @@
|
||||
namespace App\Mail\Engine;
|
||||
|
||||
use App\Utils\HtmlEngine;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Number;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
|
||||
class CreditEmailEngine extends BaseEmailEngine
|
||||
{
|
||||
@ -40,6 +43,9 @@ class CreditEmailEngine extends BaseEmailEngine
|
||||
|
||||
public function build()
|
||||
{
|
||||
App::forgetInstance('translator');
|
||||
Lang::replace(Ninja::transformTranslations($this->client->getMergedSettings()));
|
||||
|
||||
if (is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0) {
|
||||
$body_template = $this->template_data['body'];
|
||||
} else {
|
||||
|
@ -14,7 +14,10 @@ namespace App\Mail\Engine;
|
||||
use App\DataMapper\EmailTemplateDefaults;
|
||||
use App\Models\Account;
|
||||
use App\Utils\HtmlEngine;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Number;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
|
||||
class InvoiceEmailEngine extends BaseEmailEngine
|
||||
{
|
||||
@ -42,6 +45,10 @@ class InvoiceEmailEngine extends BaseEmailEngine
|
||||
|
||||
public function build()
|
||||
{
|
||||
|
||||
App::forgetInstance('translator');
|
||||
Lang::replace(Ninja::transformTranslations($this->client->getMergedSettings()));
|
||||
|
||||
if (is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0) {
|
||||
$body_template = $this->template_data['body'];
|
||||
} elseif (strlen($this->client->getSetting('email_template_'.$this->reminder_template)) > 0) {
|
||||
|
@ -13,7 +13,10 @@ namespace App\Mail\Engine;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Utils\HtmlEngine;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Number;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
|
||||
class QuoteEmailEngine extends BaseEmailEngine
|
||||
{
|
||||
@ -41,6 +44,9 @@ class QuoteEmailEngine extends BaseEmailEngine
|
||||
|
||||
public function build()
|
||||
{
|
||||
App::forgetInstance('translator');
|
||||
Lang::replace(Ninja::transformTranslations($this->client->getMergedSettings()));
|
||||
|
||||
if (is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0) {
|
||||
$body_template = $this->template_data['body'];
|
||||
} else {
|
||||
|
@ -33,7 +33,21 @@ class NinjaTranslationServiceProvider extends TranslationServiceProvider
|
||||
*
|
||||
*/
|
||||
|
||||
// $this->app->bind('translator', function($app) {
|
||||
|
||||
// $loader = $app['translation.loader'];
|
||||
// $locale = $app['config']['app.locale'];
|
||||
|
||||
// $trans = new NinjaTranslator($loader, $locale);
|
||||
|
||||
// $trans->setFallback($app['config']['app.fallback_locale']);
|
||||
|
||||
// return $trans;
|
||||
|
||||
// });
|
||||
|
||||
$this->app->singleton('translator', function ($app) {
|
||||
|
||||
$loader = $app['translation.loader'];
|
||||
$locale = $app['config']['app.locale'];
|
||||
|
||||
@ -42,6 +56,8 @@ class NinjaTranslationServiceProvider extends TranslationServiceProvider
|
||||
$trans->setFallback($app['config']['app.fallback_locale']);
|
||||
|
||||
return $trans;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,10 +16,13 @@ use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesInvoiceHtml;
|
||||
use App\Utils\Traits\MakesTemplateData;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
|
||||
class TemplateEngine
|
||||
@ -96,6 +99,9 @@ class TemplateEngine
|
||||
$this->settings = $this->settings_entity->settings;
|
||||
}
|
||||
|
||||
App::forgetInstance('translator');
|
||||
Lang::replace(Ninja::transformTranslations($this->settings));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user