本文整理匯總了PHP中Translation::setLocale方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translation::setLocale方法的具體用法?PHP Translation::setLocale怎麽用?PHP Translation::setLocale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Translation
的用法示例。
在下文中一共展示了Translation::setLocale方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct($door = "")
{
//iniciando a config básico, a menos que exita outro config, este vai ser o que vai ficar valendo
$domain = Navigation::getURIDomain();
if ($door) {
//use em $door ":8080" por exemplo
$domain = str_replace($door, "", $domain);
}
include "configs/" . $domain . "/config.php";
//se não foi passado algum locale na url apos o nome do site faz um redirect passando o locale padrão
$folders_array = Navigation::getURI(Config::getAliasFolder(), Navigation::URI_RETURN_TYPE_ARRAY);
$locale = Config::getLocale();
Translation::setLocale($locale);
//inicia e pega resultado da controller
$this->HttpResult = $this->getControllerResult();
//agora verifica que tipo de retorno esperado e chama a view, se for o caso
$ignore_name = Config::getAliasFolder();
if (Config::getLocale()) {
$ignore_name .= "/" . Config::getLocale();
}
//url com trata com regras de rota
$url = explode("/", Config::rewriteUrl(Navigation::getURI($ignore_name, Navigation::URI_RETURN_TYPE_STRING)));
$retornoDaView = self::searchFile($url, Config::getFolderView());
if ($retornoDaView->success) {
//echo Debug::li("retornoDaView:".$retornoDaView->urlToInclude);
$this->view = $retornoDaView->urlToInclude;
} else {
$this->view = Config::getFolderView() . "/index.php";
}
}
示例2: __construct
public function __construct()
{
//iniciando a config básico, a menos que exita outro config, este vai ser o que vai ficar valendo
include "configs/" . str_replace(":8888", "", Navigation::getURIDomain()) . "/config.php";
//se não foi passado algum locale na url apos o nome do site faz um redirect passando o locale padrão
//echo Debug::li(Config::getAliasFolder());
$folders_array = Navigation::getURI(Config::getAliasFolder(), Navigation::URI_RETURN_TYPE_ARRAY);
//echo Debug::li(Config::getRootApplication());
//$folders_array = Navigation::getURI(Config::getAliasFolder(), Navigation::URI_RETURN_TYPE_ARRAY);
$locale = Config::getLocale();
Translation::setLocale($locale);
//inicia e pega resultado da controller
$this->HttpResult = $this->getControllerResult();
//agora verifica que tipo de retorno esperado e chama a view, se for o caso
$ignore_name = Config::getAliasFolder();
if (Config::getLocale()) {
$ignore_name .= "/" . Config::getLocale();
}
//url com trata com regras de rota
$url = explode("/", Config::rewriteUrl(Navigation::getURI($ignore_name, Navigation::URI_RETURN_TYPE_STRING)));
$retornoDaView = self::searchFile($url, Config::getFolderView());
//Navigation::searchFileOrFolder(Config::getRootApplication()."/".Config::getLocale(), Config::getFolderView(), Navigation::SEARCH_FILE_MODE_FILE);
//echo Debug::li("retornoDaView");
//Debug::print_r($retornoDaView);
if ($retornoDaView->success) {
//echo Debug::li("retornoDaView:".$retornoDaView->urlToInclude);
$this->view = $retornoDaView->urlToInclude;
} else {
$this->view = Config::getFolderView() . "/index.php";
}
//exit();
//Debug::print_r("[SEARCH_FILE_MODE_CLASS_AND_METHOD]:".Navigation::searchFileOrFolder(Config::FOLDER_ROOT_APPLICATION, "view/democrart/", Navigation::SEARCH_FILE_MODE_CLASS_AND_METHOD, "", TRUE));
}
示例3: function
<?php
/**
Event::listen('illuminate.query', function($query)
{
var_dump($query);
});
*
*/
Route::group(['prefix' => 'lang', 'middleware' => ['locale']], function () {
Route::get('{lang}', function ($lang) {
Translation::setLocale($lang);
$previous = URL::previous();
$new = preg_replace('/(\\.[a-z]{2,5})(\\/[a-z]{0,2})?\\//', "\$1/" . $lang . "/", $previous);
return Redirect::to($new);
});
});
Route::group(['prefix' => Translation::getRoutePrefix(), 'middleware' => ['locale']], function () {
Route::group(['middleware' => 'auth'], function () {
Route::group(['middleware' => 'access.routeNeedsRoleOrPermission', 'role' => ['Administrator'], 'permission' => ['view_backend'], 'redirect' => '/', 'with' => ['flash_danger', 'You do not have access to do that.']], function () {
Route::get('download/{file}', function ($file) {
$file_path = storage_path() . '/' . $file;
//dd($file_path);
if (file_exists($file_path)) {
// Send Download
$filename = preg_filter('/[^\\d\\w\\s \\.]/', '_', $file);
return Response::download($file_path, $filename, ['Content-Length: ' . filesize($file_path)], 'attachment');
} else {
// Error
exit('Requested file does not exist on our server!');
}