简体   繁体   English

如何在 Laravel 中创建多语言翻译路线

[英]How to create multilingual translated routes in Laravel

I would like to create application with many translated routes depending on selected language.我想根据所选语言创建具有许多翻译路线的应用程序。 I've once described it at 3 methods of creating URLs in multilingual websites .我曾经在多语言网站中创建 URL 的 3 种方法中描述了它。

In this case it should be the first method from mentioned topic so:在这种情况下,它应该是上述主题的第一种方法,因此:

  1. I have one default language我有一种默认语言
  2. I can have many other languages我可以有很多其他语言
  3. Current language should be calculated only by URL (without cookies/sessions) to make it really friendly also for search engines当前语言应仅通过 URL(没有 cookie/会话)计算,以使其对搜索引擎也非常友好
  4. For default language there should be no prefix in URL, for other languages should be language prefix after domain对于默认语言,URL 中不应该有前缀,对于其他语言,应该是域后的语言前缀
  5. Each part of url should be translated according to the current language. url 的每一部分都应该根据当前语言进行翻译。

Let's assume I have set default language pl and 2 other languages en and fr .假设我设置了默认语言pl和其他 2 种语言enfr I have only 3 pages - mainpage, contact page and about page.我只有 3 页 - 主页、联系页面和关于页面。

Urls for site should look then this way:网站的网址应该是这样的:

/
/[about]
/[contact]
/en
/en/[about]
/en/[contact]
/fr
/fr/[about]
/fr/[contact]

whereas [about] and [contact] should be translated according to selected language, for example in English it should be left contact but for Polish it should be kontakt and so on.[about][contact]应根据所选语言进行翻译,例如在英语中应保留contact ,但对于波兰语则应为kontakt等等。

How can it be done as simple as possible?怎样才能做到尽可能简单?

First step:第一步:

Go to app/lang directory and create here translations for your routes for each language.转到app/lang目录并在此处为每种语言的路线创建翻译。 You need to create 3 routes.php files - each in separate language directory (pl/en/fr) because you want to use 3 languages您需要创建 3 个routes.php文件 - 每个文件都在单独的语言目录 (pl/en/fr) 中,因为您想使用 3 种语言

For Polish:波兰语:

<?php

// app/lang/pl/routes.php

return array(

    'contact' => 'kontakt',
    'about'   => 'o-nas'
);

For English:对于英语:

<?php

// app/lang/en/routes.php

return array(
    'contact' => 'contact',
    'about'   => 'about-us'
);

For French:对于法语:

<?php

// app/lang/fr/routes.php

return array(
    'contact' => 'contact-fr',
    'about'   => 'about-fr'
);

Second step:第二步:

Go to app/config/app.php file.转到app/config/app.php文件。

You should find line:你应该找到一行:

'locale' => 'en',

and change it into language that should be your primary site language (in your case Polish):并将其更改为您的主要站点语言(在您的情况下为波兰语):

'locale' => 'pl',

You also need to put into this file the following lines:您还需要将以下几行放入此文件:

/**
 * List of alternative languages (not including the one specified as 'locale')
 */
'alt_langs' => array ('en', 'fr'),

/**
 *  Prefix of selected locale  - leave empty (set in runtime)
 */
'locale_prefix' => '',

In alt_langs config you set alternative languages (in your case en and fr ) - they should be the same as file names from first step where you created files with translations.alt_langs配置中,您设置替代语言(在您的情况下enfr )-它们应该与从第一步创建带有翻译的文件的文件名相同。

And locale_prefix is the prefix for your locale. locale_prefix是您的语言环境的前缀。 You wanted no prefix for your default locale so it's set to empty string.您不需要默认语言环境的前缀,因此将其设置为空字符串。 This config will be modified in runtime if other language than default will be selected.如果选择默认语言以外的其他语言,将在运行时修改此配置。

Third step第三步

Go to your app/routes.php file and put their content (that's the whole content of app/routes.php file):转到您的app/routes.php文件并放置它们的内容(即app/routes.php文件的全部内容):

<?php

// app/routes.php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/


/*
 *  Set up locale and locale_prefix if other language is selected
 */
if (in_array(Request::segment(1), Config::get('app.alt_langs'))) {

    App::setLocale(Request::segment(1));
    Config::set('app.locale_prefix', Request::segment(1));
}


/*
 * Set up route patterns - patterns will have to be the same as in translated route for current language
 */
foreach(Lang::get('routes') as $k => $v) {
    Route::pattern($k, $v);
}


Route::group(array('prefix' => Config::get('app.locale_prefix')), function()
{
    Route::get(
        '/',
        function () {
            return "main page - ".App::getLocale();
        }
    );


    Route::get(
        '/{contact}/',
        function () {
            return "contact page ".App::getLocale();
        }
    );



    Route::get(
        '/{about}/',
        function () {
            return "about page ".App::getLocale();

        }
    );

});

As you see first you check if the first segment of url matches name of your languages - if yes, you change locale and current language prefix.正如您首先看到的,您检查 url 的第一段是否与您的语言名称匹配 - 如果是,则更改区域设置和当前语言前缀。

Then in tiny loop, you set requirements for your all route names (you mentioned that you want have about and contact translated in URL) so here you set them as the same as defined in routes.php file for current language.然后在小循环中,您为所有路由名称设置要求(您提到要在 URL 中翻译aboutcontact ),因此在这里您将它们设置为与当前语言的routes.php文件中定义的相同。

At last you create Route group that will have prefix as the same as your language (for default language it will be empty) and inside group you simply create paths but those parameters about and contact you treat as variables so you use {about} and {contact} syntax for them.最后,您创建路由组,该组的前缀将与您的语言相同(对于默认语言,它将为空)并且在组内您只需创建路径,但那些aboutcontact参数您将视为variables因此您使用{about}{contact}语法。

You need to remember that in that case {contact} in all routes will be checked if it's the same as you defined it in first step for current language.您需要记住,在这种情况下,将检查所有路线中的{contact}是否与您在第一步中为当前语言定义的相同。 If you don't want this effect and want to set up routes manually for each route using where, there's alternative app\\routes.php file without loop where you set contact and about separately for each route:如果您不想要这种效果并希望使用 where 为每条路线手动设置路线,则有替代的app\\routes.php文件没有循环,您可以在其中分别为每条路线设置contactabout

<?php

// app/routes.php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

/*
 *  Set up locale and locale_prefix if other language is selected
 */
if (in_array(Request::segment(1), Config::get('app.alt_langs'))) {

    App::setLocale(Request::segment(1));
    Config::set('app.locale_prefix', Request::segment(1));
}


Route::group(array('prefix' => Config::get('app.locale_prefix')), function()
{
    Route::get(
        '/',
        function () {
            return "main page - ".App::getLocale();
        }
    );


    Route::get(
        '/{contact}/',
        function () {
            return "contact page ".App::getLocale();
        }
    )->where('contact', Lang::get('routes.contact'));



    Route::get(
        '/{about}/',
        function () {
            return "about page ".App::getLocale();

        }
    )->where('about', Lang::get('routes.about'));


});

Fourth step:第四步:

You haven't mentioned about it, but there's one extra thing you could consider.你还没有提到它,但还有一件你可以考虑的额外事情。 If someone will use url /en/something where something isn't correct Route, I think the best solution to make redirection.如果有人会使用 url /en/somethingsomething不正确的地方使用 Route,我认为是进行重定向的最佳解决方案。 But you should make redirection not to / because it's default language but to /en .但是您不应该重定向到/因为它是默认语言而是重定向到/en

So now you can open app/start/global.php file and create here 301 redirection for unknown urls:所以现在你可以打开app/start/global.php文件并在此处为未知 url 创建 301 重定向:

// app/start/global.php

App::missing(function()
{
   return Redirect::to(Config::get('app.locale_prefix'),301);
});

What Marcin Nabiałek provided us with in his initial answer is a solid solution to the route localization problem.Marcin Nabiałek在他最初的回答中为我们提供的是路线定位问题的可靠解决方案。

The Minor Bugbear:小熊熊:

The only real downside with his solution is that we cannot use cached routes, which can sometimes be of great benefit as per Laravel's docs :他的解决方案唯一真正的缺点是我们不能使用缓存路由,根据Laravel's文档,这有时会带来很大的好处:

If your application is exclusively using controller based routes, you should take advantage of Laravel's route cache.如果你的应用专门使用基于控制器的路由,你应该利用 Laravel 的路由缓存。 Using the route cache will drastically decrease the amount of time it takes to register all of your application's routes.使用路由缓存将大大减少注册所有应用程序路由所需的时间。 In some cases, your route registration may even be up to 100x faster.在某些情况下,您的路线注册速度甚至可能快 100 倍。 To generate a route cache, just execute the route:cache Artisan command.要生成路由缓存,只需执行route:cache Artisan 命令。


Why can we not cache our routes?为什么我们不能缓存我们的路由?

Because Marcin Nabiałek's method generates new routes based on the locale_prefix dynamically, caching them would result in a 404 error upon visiting any prefix not stored in the locale_prefix variable at the time of caching.由于Marcin Nabiałek 的方法基于locale_prefix动态生成新路由,因此在访问缓存时未存储在locale_prefix变量中的任何前缀时,缓存它们将导致404错误。


What do we keep?我们保留什么?

The foundation seems really solid and we can keep most of it!基础看起来很扎实,我们可以保留大部分!

We can certainly keep the various localization-specific route files:我们当然可以保留各种特定于本地化的路由文件:

<?php

// app/lang/pl/routes.php

return array(

    'contact' => 'kontakt',
    'about'   => 'o-nas'
);

We can also keep all the app/config/app.php variables:我们还可以保留所有app/config/app.php变量:

/**
* Default locale 
*/
'locale' => 'pl'

/**
 * List of alternative languages (not including the one specified as 'locale')
 */
'alt_langs' => array ('en', 'fr'),

/**
 *  Prefix of selected locale  - leave empty (set in runtime)
 */
'locale_prefix' => '',

 /**
 * Let's also add a all_langs array
 */
'all_langs' => array ('en', 'fr', 'pl'),

We will also need the bit of code that checks the route segments.我们还需要一些检查路由段的代码。 But since the point of this is to utilize the cache we need to move it outside the routes.php file.但由于这样做的目的是利用缓存,我们需要将它移到routes.php文件之外。 That one will not be used anymore once we cache the routes.一旦我们缓存了路由,就不会再使用那个了。 We can for the time being move it to app/Providers/AppServiceProver.php for example:我们可以暂时将其移动到app/Providers/AppServiceProver.php例如:

public function boot(){
  /*
   *  Set up locale and locale_prefix if other language is selected
   */
   if (in_array(Request::segment(1), config('app.alt_langs'))) {
       App::setLocale(Request::segment(1));
       config([ 'app.locale_prefix' => Request::segment(1) ]);
   }
}

Don't forget:不要忘记:

use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\App;

Setting up our routes:设置我们的路线:

Several changes will occur within our app/Http/routes.php file.我们的app/Http/routes.php文件中会发生一些变化。

Firstly we have to make a new array contain all of the alt_langs as well as the default locale_prefix , which would most likely be '' :首先,我们必须创建一个包含所有alt_langs以及默认locale_prefix的新数组,这很可能是''

$all_langs = config('app.all_langs');

In order to be able to cache all the various lang prefixes with translated route parameters we need to register them all.为了能够使用翻译后的路由参数缓存所有各种 lang 前缀,我们需要将它们全部注册。 How can we do that?我们怎么做?

*** Laravel aside 1: ***

Let's take a look at the definition of Lang::get(..) :我们来看看Lang::get(..)的定义:

public static function get($key, $replace = array(), $locale = null, $fallback = true){
      return \Illuminate\Translation\Translator::get($key, $replace, $locale, $fallback);
}

The third parameter of that function is a $locale variable!该函数的第三个参数是$locale变量! Great - we can certainly use that to our advantage!太好了 - 我们当然可以利用它来发挥我们的优势! This function actually let's us choose which locale we want to obtain the translation from!这个函数实际上让我们选择我们想要从哪个语言环境获取翻译!

The next thing we are going to do is iterate over the $all_langs array and create a new Route group for each language prefix.接下来我们要做的是遍历$all_langs数组并为每个语言前缀创建一个新的Route组。 Not only that, but we are also going to get rid of the where chains and patterns that we previously needed, and only register the routes with their proper translations (others will throw 404 without having to check for it anymore):不仅如此,我们还将摆脱我们以前需要的where链和patterns ,只注册具有正确翻译的路由(其他人将抛出404而无需再检查它):

/**
* Iterate over each language prefix 
*/
foreach( $all_langs as $prefix ){
   
   if ($prefix == 'pl') $prefix = '';

   /**
   * Register new route group with current prefix
   */
   Route::group(['prefix' => $prefix], function() use ($prefix) {

         // Now we need to make sure the default prefix points to default  lang folder.
         if ($prefix == '') $prefix = 'pl';

         /**
         * The following line will register:
         *
         * example.com/
         * example.com/en/
         */
         Route::get('/', 'MainController@getHome')->name('home');

         /**
         * The following line will register:
         *
         * example.com/kontakt
         * example.com/en/contact
         */
         Route::get(Lang::get('routes.contact',[], $prefix) , 'MainController@getContact')->name('contact');

         /**
         * “In another moment down went Alice after it, never once 
         * considering how in the world she was to get out again.”
         */
         Route::group(['prefix' => 'admin', 'middleware' => 'admin'], function () use ($prefix){

            /**
            * The following line will register:
            *
            * example.com/admin/uzivatelia
            * example.com/en/admin/users
            */
            Route::get(Lang::get('routes.admin.users',[], $prefix), 'AdminController@getUsers')
            ->name('admin-users');

         });
   });
}

/**
* There might be routes that we want to exclude from our language setup.
* For example these pesky ajax routes! Well let's just move them out of the `foreach` loop.
* I will get back to this later.
*/
Route::group(['middleware' => 'ajax', 'prefix' => 'api'], function () {
    /**
    * This will only register example.com/api/login
    */
    Route::post('login', 'AjaxController@login')->name('ajax-login');
});

Houston, we have a problem!休斯顿,我们有一个问题!

As you can see I prefer using named routes (most people do probably):如您所见,我更喜欢使用命名路由(大多数人可能会这样做):

Route::get('/', 'MainController@getHome')->name('home');

They can be very easily used inside your blade templates:它们可以很容易地在您的刀片模板中使用:

{{route('home')}}

But there is an issue with my solution so far: Route names override each other.但是到目前为止,我的解决方案存在一个问题:路由名称相互覆盖。 The foreach loop above would only register the last prefixed routes with their names.上面的foreach循环只会用它们的名字注册最后一个带前缀的路由。

In other words only example.com/ would be bound to the home route as locale_perfix was the last item in the $all_langs array.换句话说,只有example.com/会绑定到home路由,因为locale_perfix$all_langs数组中的最后一项。

We can get around this by prefixing route names with the language $prefix .我们可以通过使用语言$prefix为路由名称添加前缀来解决这个问题。 For example:例如:

Route::get('/', 'MainController@getHome')->name($prefix.'_home');

We will have to do this for each of the routes within our loop.我们必须为循环中的每条路线都这样做。 This creates another small obstacle.这造成了另一个小障碍。


But my massive project is almost finished!但我的庞大工程快要完成了!

Well as you probably guessed you now have to go back to all of your files and prefix each route helper function call with the current locale_prefix loaded from the app config.正如您可能猜到的那样,您现在必须返回到所有文件,并使用从app配置加载的当前locale_prefix每个route辅助函数调用添加前缀。

Except you don't!除了你没有!

*** Laravel aside 2: ***

Let's take a look at how Laravel implements it's route helper method.让我们来看看 Laravel 如何实现它的route辅助方法。

if (! function_exists('route')) {
    /**
     * Generate a URL to a named route.
     *
     * @param  string  $name
     * @param  array   $parameters
     * @param  bool    $absolute
     * @return string
     */
    function route($name, $parameters = [], $absolute = true)
    {
        return app('url')->route($name, $parameters, $absolute);
    }
}

As you can see Laravel will first check if a route function exists already.如您所见,Laravel 将首先检查route函数是否已经存在。 It will register its route function only if another one does not exist yet!只有当另一个route功能不存在时,它才会注册它的route功能!

Which means we can get around our problem very easily without having to rewrite every single route call made so far in our Blade templates.这意味着我们可以非常轻松地解决我们的问题,而无需重写迄今为止在我们的Blade模板中进行的每个route调用。

Let's make a app/helpers.php file real quick.让我们快速创建一个app/helpers.php文件。

Let's make sure Laravel loads the file before it loads its helpers.php by putting the following line in bootstrap/autoload.php让我们确保 Laravel 在加载文件 helpers.php 之前加载文件,方法是helpers.php放在bootstrap/autoload.php

//Put this line here
require __DIR__ . '/../app/helpers.php';
//Right before this original line
require __DIR__.'/../vendor/autoload.php';

UPDATE FOR LARAVEL 7+ Laravel 7+ 的更新

The bootstrap/autoload.php file doesn't exist anymore, you will have to add the code above in the public/index.php file instead. bootstrap/autoload.php文件不再存在,您必须将上面的代码添加到public/index.php文件中。

All we now have to do is make our own route function within our app/helpers.php file.我们现在要做的就是在app/helpers.php文件中创建我们自己的route函数。 We will use the original implementation as the basis:我们将使用原始实现作为基础:

<?php
//Same parameters and a new $lang parameter
use Illuminate\Support\Str;

function route($name, $parameters = [], $absolute = true, $lang = null)
{
    /*
    * Remember the ajax routes we wanted to exclude from our lang system?
    * Check if the name provided to the function is the one you want to
    * exclude. If it is we will just use the original implementation.
    **/
    if (Str::contains($name, ['ajax', 'autocomplete'])){
        return app('url')->route($name, $parameters, $absolute);
    }

   //Check if $lang is valid and make a route to chosen lang
   if ( $lang && in_array($lang, config('app.alt_langs')) ){
       return app('url')->route($lang . '_' . $name, $parameters, $absolute);
   }

    /**
    * For all other routes get the current locale_prefix and prefix the name.
    */
    $locale_prefix = config('app.locale_prefix');
    if ($locale_prefix == '') $locale_prefix = 'pl';
    return app('url')->route($locale_prefix . '_' . $name, $parameters, $absolute);
}

That's it!就是这样!

So what we have done essentially is registered all of the prefix groups available.所以我们所做的基本上是注册了所有可用的前缀组。 Created each route translated and with it's name also prefixed.创建每个路由翻译并带有它的名称前缀。 And then sort of overriden the Laravel route function to prefix all the route names (except some) with the current locale_prefix so that appropriate urls are created in our blade templates without having to type config('app.locale_prefix') every single time.然后排序的被覆盖的的Laravel route功能与当前前缀的所有路径名(除了一些) locale_prefix以便采取适当的网址是在我们的刀片模板创建,而不必键入config('app.locale_prefix')每一次。

Oh yeah:哦耶:

php artisan route:cache

Caching routes should only really be done once you deploy your project as it is likely you will mess with them during devlopement.缓存路由应该只在你部署你的项目后才真正完成,因为在开发过程中你很可能会弄乱它们。 But you can always clear the cache:但是您可以随时清除缓存:

php artisan route:clear

Thanks again to Marcin Nabiałek for his original answer.再次感谢Marcin Nabiałek的原始回答。 It was really helpful to me.这对我真的很有帮助。

The same results can be applied with a simpler approach.. not perfect, but does offer a quick and easy solution.可以通过更简单的方法应用相同的结果......并不完美,但确实提供了一种快速简便的解决方案。 In that scenario, you do, however, have to write each routes so it might not do it for large websites.但是,在这种情况下,您必须编写每个路由,因此它可能不适用于大型网站。

Route::get('/contact-us', function () {
    return view('contactus');
})->name('rte_contact'); // DEFAULT

Route::get('/contactez-nous', function () {
    return view('contactus');
})->name('rte_contact_fr');

just define the route names in the localization file as so:只需在本地化文件中定义路由名称,如下所示:

# app/resources/lang/en.json
{ "rte_contact": "rte_contact" } //DEFAULT

// app/resources/lang/fr.json
{ "rte_contact": "rte_contact_fr" }

You can then use them in your blade templates using generated locale variables like so:然后,您可以使用生成的语言环境变量在您的刀片模板中使用它们,如下所示:

<a class="nav-link" href="{{ route(__('rte_contact')) }}"> {{ __('nav_contact') }}</a>

I re-open this discussion cause I had some problem whit my laravel 8 project, but in realty the problem is olso for the oldest version.我重新打开这个讨论,因为我的 laravel 8 项目有一些问题,但实际上问题是最旧版本的问题。

In my case I've olso two languages, and in the navbar I will print just ITA for original language, and ENG for english languge.就我而言,我还有两种语言,在导航栏中,我将只打印原始语言的 ITA,以及英语语言的 ENG。

Main problem: If I'm looking to the italian page, the ENG link in the navbar should point to the same english translate page.主要问题:如果我正在查看意大利语页面,导航栏中的 ENG 链接应该指向相同的英文翻译页面。

How to do this??这个怎么做?? good question, cause I can't in this way.好问题,因为我不能这样。

Why?为什么? Cause everytime we change langage we do this:因为每次我们更改语言时,我们都会这样做:

Config::set('app.locale_prefix', Request::segment(1));

We overwrite the variable in the config file local_prefix, and this sounds me strange, another thing we do is this:我们覆盖了配置文件 local_prefix 中的变量,这听起来很奇怪,我们要做的另一件事是:

   if ( $lang && in_array($lang, config('app.alt_langs')) ){
       return app('url')->route($lang . '_' . $name, $parameters, $absolute);
   }

We use the alt_langs where are definited only the alternative languages, and this is a problem cause if I pass the local lang, in my case 'it' like lang parameter this will not be found cause, from the description, the alt_lang should not contain the locale language and you will be able to get only the translated string.我们使用alt_langs ,其中仅定义了替代语言,如果我传递本地语言,这是一个问题,在我的情况下'it' like lang 参数将找不到原因,从描述中,alt_lang 不应该包含语言环境,您将只能获得翻译后的字符串。

If you change the如果你改变

       if ( $lang && in_array($lang, config('app.alt_langs')) ){
           return app('url')->route($lang . '_' . $name, $parameters, $absolute);
       }

in:在:

   if ( $lang && in_array($lang, config('app.all_langs')) ){
       return app('url')->route($lang . '_' . $name, $parameters, $absolute);
   }

Now using 'app.all_langs' you are able to choose wich url you want and in wich language you want, and this is not all.现在使用'app.all_langs' ,您可以选择所需的 url 和所需的语言,这还不是全部。

For how my site should work, and as I wrote in the beginning, in the blade file I need to get the translated url of the page, and if you remember we used the $prefix for caching the route and giving to the route a new name ->name($prefix.'_home');对于我的网站应该如何工作,正如我在开头所写的那样,在刀片文件中,我需要获取页面的翻译 url,如果你记得我们使用 $prefix 来缓存路由并给路由一个新的名称->name($prefix.'_home'); in this way you can cache all the route and you can call the ruoutes using blade without prefix {{ route('name') }} but what if I need the translated route of the actual route??这样,您可以缓存所有路由,并且可以使用不带前缀{{ route('name') }}刀片调用路由,但是如果我需要实际路由的翻译路由怎么办?

     $ThisRoute = Route::currentRouteName();

 $result = substr($ThisRoute, 0, 2);
 if ($result =='it' ){
    $routeName = str_replace('it_', '', $ThisRoute);
    $url = route($routeName,[],true,'en');
 } else {
    $routeName = str_replace('en_', '', $ThisRoute);
    $url = route($routeName,[],true,'it');
}

Doing this I get the actual route name that shuold be it_home I check if strart with it or en, I remove the it_ or en_ prefix and I get the translated url now you can use the $url as <a href="{{ $url" }}>text这样做我得到了应该是 it_home 的实际路由名称我检查是否以它或 en 开头,我删除 it_ 或 en_ 前缀,我得到翻译后的 url 现在你可以使用 $url 作为 <a href="{{ $网址”}}>文字

Be carefull using this code, cause is made in 5 minutes, need more implementation, and check.小心使用此代码,原因在 5 分钟内完成,需要更多实施,并检查。

I hope that someone more expert than me can explain me why we overwirte the app.locale_prefix sincerly I don't like, it's an app variable not a session variable..我希望比我更专业的人能解释一下为什么我们会覆盖app.locale_prefix我不喜欢,它是一个应用程序变量而不是一个会话变量..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM