Working on multi-language support

This commit is contained in:
Hillel Coren 2014-04-02 15:28:23 +03:00
parent 36d57e7ac8
commit f1f6d67af1
24 changed files with 140 additions and 135 deletions

View File

@ -55,9 +55,10 @@ class HomeController extends BaseController {
'text' => $message
];
$this->mailer->sendTo(CONTACT_EMAIL, CONTACT_EMAIL, CONTACT_NAME, 'Invoice Ninja Feedback', 'contact', $data);
$this->mailer->sendTo(CONTACT_EMAIL, CONTACT_EMAIL, CONTACT_NAME, 'Invoice Ninja Feedback', 'contact', $data);
Session::flash('message', 'Successfully sent message');
$message = trans('texts.sent_message');
Session::flash('message', $message);
return Redirect::to('/contact');
}

View File

@ -207,12 +207,6 @@ class InvoiceController extends \BaseController {
public static function getViewModel()
{
// Temporary fix to let users know to re-upload their logos for higher res
if (Auth::user()->account->getLogoHeight() == 80)
{
Session::flash('warning', "We've increased the logo resolution in the PDF. Please re-upload your logo to take advantage of it.");
}
return [
'account' => Auth::user()->account,
'products' => Product::scope()->orderBy('id')->get(array('product_key','notes','cost','qty')),
@ -262,7 +256,7 @@ class InvoiceController extends \BaseController {
if ($errors = $this->invoiceRepo->getErrors($invoice))
{
Session::flash('error', 'Please make sure to select a client and correct any errors');
Session::flash('error', trans('texts.invoice_error'));
return Redirect::to('invoices/create')
->withInput()->withErrors($errors);
@ -314,12 +308,12 @@ class InvoiceController extends \BaseController {
}
}
$message = '';
$message = trans($publicId ? 'texts.updated_invoice' : 'texts.created_invoice');
if ($input->invoice->client->public_id == '-1')
{
$message = ' and created client';
$url = URL::to('clients/' . $client->public_id);
$message = $message . ' ' . trans('texts.and_created_client');
$url = URL::to('clients/' . $client->public_id);
Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT, $url);
}
@ -332,25 +326,18 @@ class InvoiceController extends \BaseController {
if (Auth::user()->confirmed)
{
$this->mailer->sendInvoice($invoice);
Session::flash('message', 'Successfully emailed invoice'.$message);
Session::flash('message', $message);
}
else
{
Session::flash('message', 'Successfully saved invoice'.$message);
if (Auth::user()->registered)
{
Session::flash('error', 'Please confirm your email address');
}
else
{
Session::flash('error', 'Please sign up to email an invoice');
}
$errorMessage = trans(Auth::user()->registered ? 'texts.confirmation_required' : 'texts.registration_required');
Session::flash('error', $errorMessage);
Session::flash('message', $message);
}
}
else
{
Session::flash('message', 'Successfully saved invoice'.$message);
Session::flash('message', $message);
}
$url = 'invoices/' . $invoice->public_id . '/edit';
@ -431,7 +418,7 @@ class InvoiceController extends \BaseController {
$clone->invoice_items()->save($cloneItem);
}
Session::flash('message', 'Successfully cloned invoice');
Session::flash('message', trans('texts.cloned_invoice'));
return Redirect::to('invoices/' . $clone->public_id);
}
}

View File

@ -270,7 +270,7 @@ class PaymentController extends \BaseController
Event::fire('invoice.paid', $payment);
Session::flash('message', 'Successfully applied payment');
Session::flash('message', trans('texts.applied_payment'));
return Redirect::to('view/' . $payment->invitation->invitation_key);
}
else if ($response->isRedirect())
@ -282,13 +282,17 @@ class PaymentController extends \BaseController
}
else
{
Session::flash('error', $response->getMessage());
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $response->getMessage());
$errorMessage = trans('texts.payment_error') . "\n\n" . $response->getMessage();
Session::flash('error', $errorMessage);
Utils::logError($errorMessage);
return Redirect::to('view/' . $payment->invitation->invitation_key);
}
}
catch (\Exception $e)
{
Session::flash('error', $e->getMessage());
$errorMessage = trans('texts.payment_error');
Session::flash('error', $errorMessage);
Utils::logError($e->getMessage());
return Redirect::to('payment/' . $invitationKey)
->withInput();
}
@ -345,19 +349,23 @@ class PaymentController extends \BaseController
Event::fire('invoice.paid', $payment);
Session::flash('message', 'Successfully applied payment');
Session::flash('message', trans('texts.applied_payment'));
return Redirect::to('view/' . $invitation->invitation_key);
}
else
{
Session::flash('error', $response->getMessage());
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $response->getMessage());
$errorMessage = trans('texts.payment_error') . "\n\n" . $response->getMessage();
Session::flash('error', $errorMessage);
Utils::logError($errorMessage);
return Redirect::to('view/' . $invitation->invitation_key);
}
}
catch (\Exception $e)
{
Session::flash('error', $e->getMessage());
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $e);
$errorMessage = trans('texts.payment_error');
Session::flash('error', $errorMessage);
Utils::logError($errorMessage . "\n\n" . $e->getMessage());
return Redirect::to('view/' . $invitation->invitation_key);
}
}
@ -385,8 +393,7 @@ class PaymentController extends \BaseController
{
$this->paymentRepo->save($publicId, Input::all());
$message = $publicId ? 'Successfully updated payment' : 'Successfully created payment';
Session::flash('message', $message);
Session::flash('message', trans('texts.created_payment'));
return Redirect::to('clients/' . Input::get('client'));
}
}
@ -399,11 +406,10 @@ class PaymentController extends \BaseController
if ($count > 0)
{
$message = Utils::pluralize('Successfully '.$action.'d ? payment', $count);
$message = Utils::pluralize($action.'d_payment', $count);
Session::flash('message', $message);
}
return Redirect::to('payments');
}
}

View File

@ -21,7 +21,11 @@ App::before(function($request)
}
}
if (Auth::check())
if (Input::has('lang'))
{
App::setLocale(Input::get('lang'));
}
else if (Auth::check())
{
App::setLocale(Auth::user()->getLocale());
}

View File

@ -170,7 +170,7 @@ return array(
'adjustment' => 'Adjustment',
'are_you_sure' => 'Are you sure?',
// new payment page
// payment pages
'payment_type_id' => 'Payment type',
'amount' => 'Amount',
@ -208,10 +208,15 @@ return array(
// application messages
'created_client' => 'Successfully created client',
'created_clients' => 'Successfully created ? clients',
'limit_clients' => 'Sorry, this will exceed the limit of ? clients',
'updated_settings' => 'Successfully updated settings',
'removed_logo' => 'Successfully removed logo',
'sent_message' => 'Successfully sent message',
'invoice_error' => 'Please make sure to select a client and correct any errors',
'limit_clients' => 'Sorry, this will exceed the limit of ? clients',
'payment_error' => 'There was an error processing your payment. Please try again later.',
'registration_required' => 'Please sign up to email an invoice',
'confirmation_required' => 'Please confirm your email address',
'updated_client' => 'Successfully updated client',
'created_client' => 'Successfully created client',
'archived_client' => 'Successfully archived client',
@ -221,6 +226,9 @@ return array(
'updated_invoice' => 'Successfully updated invoice',
'created_invoice' => 'Successfully created invoice',
'cloned_invoice' => 'Successfully cloned invoice',
'emailed_invoice' => 'Successfully emailed invoice',
'and_created_client' => 'and created client',
'archived_invoice' => 'Successfully archived credit',
'archived_invoices' => 'Successfully archived ? credits',
'deleted_invoice' => 'Successfully deleted credit',
@ -231,6 +239,7 @@ return array(
'archived_payments' => 'Successfully archived ? payments',
'deleted_payment' => 'Successfully deleted payment',
'deleted_payments' => 'Successfully deleted ? payments',
'applied_payment' => 'Successfully applied payment',
'created_credit' => 'Successfully created credit',
'archived_credit' => 'Successfully archived credit',
@ -238,6 +247,26 @@ return array(
'deleted_credit' => 'Successfully deleted credit',
'deleted_credits' => 'Successfully deleted ? credits',
// Emails
'confirmation_subject' => 'Invoice Ninja Account Confirmation',
'confirmation_header' => 'Account Confirmation',
'confirmation_message' => 'Please access the link below to confirm your account.',
'invoice_subject' => 'New invoice :invoice',
'invoice_message' => 'To view your invoice for :amount, click the link below.',
'payment_subject' => 'Payment Received :invoice',
'payment_message' => 'Thank you for your payment of :amount.',
'email_salutation' => 'Dear :name,',
'email_signature' => 'Regards,',
'email_from' => 'The InvoiceNinja Team',
'user_email_footer' => 'To adjust your email notification settings please visit http://www.invoiceninja.com/company/notifications',
'invoice_link_message' => 'To view your client invoice click the link below:',
'notification_paid_subject' => 'Invoice :invoice was paid by :client',
'notification_sent_subject' => 'Invoice :invoice was sent by :client',
'notification_viewed_subject' => 'Invoice :invoice was viewed by :client',
'notification_paid' => 'A payment of :amount was made by client :client towards Invoice :invoice.',
'notification_sent' => 'The following client :client was emailed Invoice :invoice for :amount.',
'notification_viewed' => 'The following client :client viewed Invoice :invoice for :amount.',
'reset_password' => 'You can reset your account password by clicking the following link:',
'reset_password_footer' => 'If you did not request this password reset please email our support: ' . CONTACT_EMAIL,
);

View File

@ -14,7 +14,7 @@ class ContactMailer extends Mailer {
public function sendInvoice(Invoice $invoice)
{
$view = 'invoice';
$subject = 'New invoice ' . $invoice->invoice_number;
$subject = trans('texts.invoice_subject', ['invoice' => $invoice->invoice_number]);
$invoice->load('invitations', 'client', 'account');
@ -57,7 +57,7 @@ class ContactMailer extends Mailer {
public function sendPaymentConfirmation(Payment $payment)
{
$view = 'payment_confirmation';
$subject = 'Payment Received ' . $payment->invoice->invoice_number;
$subject = trans('texts.payment_subject', ['invoice' => $payment->invoice->invoice_number]);
$data = [
'accountName' => $payment->account->getDisplayName(),

View File

@ -16,7 +16,7 @@ class UserMailer extends Mailer {
}
$view = 'confirm';
$subject = 'Invoice Ninja Account Confirmation';
$subject = trans('texts.confirmation_subject');
$data = [
'user' => $user
@ -48,20 +48,7 @@ class UserMailer extends Mailer {
$data['paymentAmount'] = Utils::formatMoney($payment->amount, $invoice->client->currency_id);
}
if ($type == 'paid')
{
$action = 'paid by';
}
else if ($type == 'sent')
{
$action = 'sent to';
}
else
{
$action = 'viewed by';
}
$subject = "Invoice {$invoice->invoice_number} was $action {$invoice->client->getDisplayName()}";
$subject = trans('texts.notification_'.$type.'_subject', ['invoice'=>$invoice->invoice_number, 'client'=>$invoice->client->getDisplayName()]);
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
}

View File

@ -1,8 +1,9 @@
<h1>{{ Lang::get('confide::confide.email.account_confirmation.subject') }}</h1>
<h1>{{ trans('texts.confirmation_header') }}</h1>
<p>{{ Lang::get('confide::confide.email.account_confirmation.body') }}</p>
<p>{{ trans('texts.confirmation_message') }}</p>
<a href='{{{ URL::to("user/confirm/{$user->confirmation_code}") }}}'>
{{{ URL::to("user/confirm/{$user->confirmation_code}") }}}
</a>
<p>{{ Lang::get('confide::confide.email.account_confirmation.farewell') }}</p>
{{ trans('texts.email_signature') }}<br/>
{{ trans('texts.email_from') }}

View File

@ -1,6 +1,7 @@
{{ Lang::get('confide::confide.email.account_confirmation.subject') }}
{{ trans('texts.confirmation_header') }}
{{ Lang::get('confide::confide.email.account_confirmation.body') }}
{{ trans('texts.confirmation_message') }}
{{{ URL::to("user/confirm/{$user->confirmation_code}") }}}
{{ Lang::get('confide::confide.email.account_confirmation.farewell') }}
{{ trans('texts.email_signature') }}
{{ trans('texts.email_from') }}

View File

@ -1,3 +1,3 @@
Name: {{ $name }}<br/>
Email: {{ $email }}<p/>
Message: {{ $text }}
Message: {{ nl2br($text) }}

View File

@ -1,4 +1,4 @@
Name: {{ $name }}
Email: {{ $email }}
Message: {{ $text }}
Message: {{ $text }}

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en-US">
<html>
<head>
<meta charset="utf-8">
</head>
@ -7,14 +7,13 @@
{{ $clientName }},<p/>
To view your invoice for {{ $invoiceAmount }}, click the link below:<p/>
{{ trans('texts.invoice_message', ['amount' => $invoiceAmount]) }}<p/>
{{ $link }}<p/>
@if ($emailFooter)
{{ nl2br($emailFooter) }}
@else
Best regards,<br/>
{{ trans('texts.email_signature') }}<br/>
{{ $accountName }}
@endif

View File

@ -1,22 +1,21 @@
<!DOCTYPE html>
<html lang="en-US">
<html>
<head>
<meta charset="utf-8">
</head>
<body>
Dear {{ $userName }}, <p/>
{{ trans('texts.email_salutation', ['name' => $userName]) }} <p/>
A payment of {{ $paymentAmount }} was made by client {{ $clientName }} towards invoice {{ $invoiceNumber }}. <p/>
{{ trans('texts.notification_paid', ['amount' => $paymentAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} <p/>
To view your client invoice click the link below: <br/>
{{ trans('texts.invoice_link_message') }} <br/>
{{ $invoiceLink }} <p/>
To adjust your email notification settings please <a href="http://www.invoiceninja.com/company/notifications">click here</a>.
Regards, <p/>
The InvoiceNinja Team
{{ trans('texts.email_signature') }} <br/>
{{ trans('texts.email_from') }} <p/>
{{ trans('texts.user_email_footer') }} <p/>
</body>
</html>

View File

@ -1,9 +1,11 @@
Dear {{ $userName }},
{{ trans('texts.email_salutation', ['name' => $userName]) }}
A payment of {{ $paymentAmount }} was made by client {{ $clientName }} towards invoice {{ $invoiceNumber }}.
{{ trans('texts.notification_paid', ['amount' => $paymentAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }}
To view your client invoice click the link below:
{{ trans('texts.invoice_link_message') }}
{{ $invoiceLink }}
To adjust your email notification settings please visit http://www.invoiceninja.com/company/notifications
{{ trans('texts.email_signature') }}
{{ trans('texts.email_from') }}
{{ trans('texts.user_email_footer') }}

View File

@ -1,19 +1,18 @@
<!DOCTYPE html>
<html lang="en-US">
<html>
<head>
<meta charset="utf-8">
</head>
<body>
Dear {{ $userName }},<p/>
{{ trans('texts.email_salutation', ['name' => $userName]) }} <p/>
The following client {{ $clientName }} was emailed Invoice {{ $invoiceNumber }} for {{ $invoiceAmount}}.<p/>
{{ trans('texts.notification_sent', ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} <p/>
Regards, <p/>
The InvoiceNinja Team <p/>
To adjust your email notification settings please <a href="http://www.invoiceninja.com/company/notifications">click here</a>.<p/>
{{ trans('texts.email_signature') }} <br/>
{{ trans('texts.email_from') }} <p/>
{{ trans('texts.user_email_footer') }} <p/>
</body>
</html>

View File

@ -1,5 +1,8 @@
Dear {{ $userName }},
{{ trans('texts.email_salutation', ['name' => $userName]) }}
The following client {{ $clientName }} was emailed Invoice {{ $invoiceNumber }} for {{ $invoiceAmount}}.
{{ trans('texts.notification_sent', ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }}
To adjust your email notification settings visit this link http://www.invoiceninja.com/company/notifications
{{ trans('texts.email_signature') }}
{{ trans('texts.email_from') }}
{{ trans('texts.user_email_footer') }}

View File

@ -1,12 +1,11 @@
{{ $clientName }},
To view your invoice for {{ $invoiceAmount }}, click the link below:
{{ trans('texts.invoice_message', ['amount' => $invoiceAmount]) }}
{{ $link }}
@if ($emailFooter)
{{ $emailFooter }}
@else
Best regards,
{{ trans('texts.email_signature') }}
{{ $accountName }}
@endif

View File

@ -5,15 +5,14 @@
</head>
<body>
Dear {{ $userName }},<p/>
{{ trans('texts.email_salutation', ['name' => $userName]) }} <p/>
The following client {{ $clientName }} viewed Invoice {{ $invoiceNumber }} for {{ $invoiceAmount}}.<p/>
{{ trans('texts.notification_viewed', ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} <p/>
Regards,<p/>
The InvoiceNinja Team<p/>
To adjust your email notification settings please <a href="http://www.invoiceninja.com/company/notifications">click here</a>.<p/>
{{ trans('texts.email_signature') }} <br/>
{{ trans('texts.email_from') }} <p/>
{{ trans('texts.user_email_footer') }} <p/>
</body>
</html>

View File

@ -1,9 +1,8 @@
Dear {{ $userName }},
{{ trans('texts.email_salutation', ['name' => $userName]) }}
The following client {{ $clientName }} viewed Invoice {{ $invoiceNumber }} for {{ $invoiceAmount }}.
{{ trans('texts.notification_viewed', ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }}
Regards,
{{ trans('texts.email_signature') }}
{{ trans('texts.email_from') }}
The InvoiceNinja Team
To adjust your email notification settings visit this link http://www.invoiceninja.com/company/notifications
{{ trans('texts.user_email_footer') }}

View File

@ -1,8 +1,9 @@
Hi there! {{ $user->username }}<p/>
{{ trans('texts.email_salutation', ['name' => $user->username]) }} <p/>
You can reset your account password by clicking the following link {{{ (Confide::checkAction('UserController@reset_password', array($token))) ? : URL::to('user/reset/'.$token) }}}<p/>
{{ trans('texts.reset_password') }} <br/>
{{{ (Confide::checkAction('UserController@reset_password', array($token))) ? : URL::to('user/reset/'.$token) }}}<p/>
Regards, <br/>
The InvoiceNinja Team <p/>
{{ trans('texts.email_signature') }} <br/>
{{ trans('texts.email_from') }} <p/>
If you did not request this password reset please email our support: admin@invoiceninja.com <p/>
{{ trans('texts.reset_password_footer') }} <p/>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en-US">
<html>
<head>
<meta charset="utf-8">
</head>
@ -7,12 +7,12 @@
{{ $clientName }},<p/>
Thank you for your payment of {{ $paymentAmount }}.<p/>
{{ trans('texts.payment_message', ['amount' => $paymentAmount]) }}<p/>
@if ($emailFooter)
{{ nl2br($emailFooter) }}
@else
Best regards,<br/>
{{ trans('texts.email_signature') }}<br/>
{{ $accountName }}
@endif

View File

@ -1,10 +1,10 @@
{{ $clientName }},
Thank you for your payment of {{ $paymentAmount }}.
{{ trans('texts.payment_message', ['amount' => $paymentAmount]) }}
@if ($emailFooter)
{{ $emailFooter }}
@else
Best regards,
{{ trans('texts.email_signature') }}
{{ $accountName }}
@endif

View File

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
</head>
<body>
<h2>Welcome</h2>
</body>
</html>

View File

@ -1 +0,0 @@
Welcome