Welcome Guest, Not a member yet? Register   Sign In
How to set default Locale {locale} on default redirected controller?
#1

(This post was last modified: 05-10-2022, 08:15 PM by luckmoshy.)

Hi all! I have an app that works ok in different languages but want to filter and fix on home URL to append locale as
PHP Code:
/*Filter class*/
    /*I get too many redirect error message*/
        
$uri = &$request->uri;
        
$segments array_filter($uri->getSegments());
        
$checkSegments count($segments);

   
//  the first 2 letters (en => en)
        
$userLocale strtolower(substr($request->getLocale(), 02));

            
$locale in_array($userLocale$request->config->supportedLocales) ? 
                                         
$userLocale :
                                         
$this->request->config->defaultLocale;

       if if (
$checkSegments == 0)
        {
        return 
redirect()->to("/{$locale}");
        } 

I want if any incoming request should fall on eg: (www. example.com/en) and not (www. example.com)
PHP Code:
public function index(){
      return 
view('homepage');/*I want to fix in homepage should be appended with surport locale  = exapmple.com/{locale}*/
}
/* I get 404 error */
      
$routes->get('/{locale}''HomePage::index',['filter'=>'locales']); /*get 404 error*/ 
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply


Messages In This Thread
How to set default Locale {locale} on default redirected controller? - by luckmoshy - 05-10-2022, 03:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB