Added PTB Translation of emails and some pages

Now the main page, item page and e-mails are translated
into Brazilian Portuguese
This commit is contained in:
2018-09-27 13:00:03 -03:00
parent 1ff8a4f492
commit 63ef369e16
28 changed files with 476 additions and 66 deletions

View File

@@ -73,7 +73,7 @@ class RegisterController extends Controller
\Mail::to($user)->send(new Welcome($user));
session()->flash(FlashMessage::PRIMARY, 'Thanks for registering. Please, do not forget to validate your e-mail address.');
session()->flash(FlashMessage::PRIMARY, __('Thanks for registering. Please, do not forget to validate your e-mail address.'));
return $user;
}

View File

@@ -25,7 +25,7 @@ class VerificationController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/';
/**
* Create a new controller instance.

View File

@@ -13,7 +13,11 @@ class ItemController extends Controller
{
$item = Item::find($id);
if (!$item || $item->product->user_id != \Auth::id()) {
session()->flash(flash::DANGER, "The item doesn't exist.");
session()->flash(flash::DANGER,
\Lang::getFromJson(
"The item doesn't exist."
)
);
return back();
}
$users = $item->users()->get();

View File

@@ -71,7 +71,12 @@ class ProductController extends Controller
$product = Product::fromAuthUser()->find($id);
if (!$product) {
session()->flash(flash::DANGER, "The product doesn't exist or doesn't belongs to you.");
session()->flash(
flash::DANGER,
\Lang::getFromJson(
"The product doesn't exist or doesn't belongs to you."
)
);
return redirect('/product');
}
return view('product.show', compact('product'));

View File

@@ -13,7 +13,11 @@ class TakeController extends Controller
{
$item = User::loggedIn()->items()->find(request('item'));
if ($item->used_by) {
return back()->withErrors("This item is already taken");
return back()->withErrors(
\Lang::getFromJson(
"This item is already taken"
)
);
}
$item->used_by = \Auth::id();
$item->save();

View File

@@ -42,14 +42,22 @@ class UserController extends Controller
$userArray = User::where('email', request('email'))->get();
if (count($userArray) == 0) {
return back()->withErrors("The e-mail address is not registered yet.");
return back()->withErrors(
\Lang::getFromJson("The e-mail address is not registered yet.")
);
}
$item = Item::findOrFail(request('item_id'));
if ($item->product->user_id == \Auth::id()) {
User::findOrFail($userArray[0]->id)->items()->syncWithoutDetaching([request('item_id')]);
User::findOrFail($userArray[0]->id)
->items()
->syncWithoutDetaching([request('item_id')]);
} else {
return back()->withErrors("You cannot add a user to a product that is not yourse.");
return back()->withErrors(
\Lang::getFromJson(
"You cannot add a user to a product that is not yourse."
)
);
}
return back();
}
@@ -67,12 +75,20 @@ class UserController extends Controller
$item = Item::findOrFail(request('item_id'));
if ($item->product->user_id == \Auth::id()) {
$returnItem = User::findOrFail(request('user_id'))->items()->findOrFail(request('item_id'));
$returnItem = User::findOrFail(request('user_id'))
->items()
->findOrFail(request('item_id'));
$returnItem->used_by = null;
$returnItem->save();
User::findOrFail(request('user_id'))->items()->detach([request('item_id')]);
User::findOrFail(request('user_id'))
->items()
->detach([request('item_id')]);
} else {
return back()->withErrors("You cannot remove a user from a product that is not yourse.");
return back()->withErrors(
\Lang::getFromJson(
"You cannot remove a user from a product that is not yourse."
)
);
}
return back();
}

View File

@@ -32,7 +32,11 @@ class ItemAvailable extends Mailable
*/
public function build()
{
return $this->subject($this->item->name . ' is available!')
->markdown('emails.itemAvailable');
return $this->subject(
\Lang::getFromJson(
':itemname is available!',
['itemname' => $this->item->name]
)
)->markdown('emails.itemAvailable');
}
}

View File

@@ -34,7 +34,14 @@ class UserWaiting extends Mailable
*/
public function build()
{
return $this->subject($this->waitingUser . ' wants to use ' . $this->item->name)
->markdown('emails.userWaiting');
return $this->subject(
\Lang::getFromJson(
':waitinguser wants to use :itemname',
[
'waitinguser' => $this->waitingUser,
'itemname' => $this->item->name
]
)
)->markdown('emails.userWaiting');
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Mail;
use \Lang;
use \App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
@@ -30,6 +31,6 @@ class Welcome extends Mailable
*/
public function build()
{
return $this->markdown('emails.welcome');
return $this->subject(Lang::getFromJson('Welcome'))->markdown('emails.welcome');
}
}