laravel本地化将我重定向到mainURL / assets

时间:2017-04-13 09:04:58

标签: php laravel nginx localization multiple-languages

当我在浏览器中运行主网址时,需要mainURL/assets。但是当我放mainURL/enmainURL/bn时,它运行正常。没有选择“/ lang”应用程序显示403错误。

  

403 Forbidden

     

nginx / 1.4.6(Ubuntu)

配置/ app.php

 'locale' => 'en',
 'locales' => ['en', 'bn','hi','zh','ja'],
 'fallback_locale' => 'en',

帮助方法:

public static function switchLang($lang = 'bn')
    {
        $fullUrl = request()->url();
        $segments = request()->segments();
        $partSegment = implode('/', $segments);

        $domain = str_replace('/'.$partSegment, '', $fullUrl);

        $availableLang = config('app.locales');

        if(in_array($lang, $availableLang)) {
            $segments[0] = '/'.$lang;
            $newPartSegment = implode('/', $segments);
            return $domain.$newPartSegment;
        }
        return $fullUrl;
    }

视图:

 <ul class="dropdown-menu">
       <li><a href="{{ Helpers::switchLang() }}"> বাংলা </a></li>
       <li><a href="{{ Helpers::switchLang('en') }}"> English </a></li>
       <li><a href="{{ Helpers::switchLang('zh') }}"> 中國 </a></li>
       <li><a href="{{ Helpers::switchLang('hi') }}"> हिंदी  </a></li>
       <li><a href="{{ Helpers::switchLang('ja') }}"> 日本語 </a></li>
  </ul>

0 个答案:

没有答案