Answer the question
In order to leave comments, you need to log in
How is the app()->setLocale() function implemented?
Hello.
In Laravel, to change the language of the application, you need to run
App::setLocale();
// или
app()->setLocale();
use
. Tried to find information on the Internet, but without success. I would be grateful for any help and information on this matter. PHP I only study, but you can kick. :) class App
{
protected static $instance = null;
protected $locale = 'ru';
public static function getIstance() {
if ( self::$instance === null ) self::$instance = new self();
return self::$instance;
}
public function __construct() {}
public function __clone() {}
public function setLocale( $locale ) {
$this->locale = $locale;
}
public function getLocale( $locale ) {
return $this->locale;
}
}
function app() { return App::getIstance(); }
app()->getLocale(); // ru
app()->setLocale('en');
app()->getLocale(); // en
Answer the question
In order to leave comments, you need to log in
Onatskyi , the first way uses facades that run on php magic
https://www.php.net/manual/en/language.oop5.magic.php
The second way uses global functions that are created via composer in the application file
App() gives access to laravel container
Read about dependency injection and service container. These are the patterns that are implemented in the lara
. And you tried to make a singleton, but the lara already has everything for this, you can put the necessary instances into the service container yourself.
opened the screen and got scared, what is this entry: section col-lg-12?
This is Bootstrap and there is no free creativity in it, open the tutorial and learn.
this is how you can write, and since you are not
<div class="container-fluid main-offer">
<div class="row">
<div class="col-sm-5 text-center description">
<h1>gina</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam porro illum reiciendis magni cupiditate, blanditiis sapiente! Labore quo optio aliquam.</p>
</div>
</div
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question