Welcome Guest, Not a member yet? Register   Sign In
Localization duplicate page problem when locale set in routes
#7

I may be over-complicating this, but you could do what you're talking about with the Regular Expression feature in routes.

https://codeigniter4.github.io/userguide...xpressions

You would essentially be treating the locale segment like any other URL segment, bypassing the special "locale" option. You'll want to follow the RegEx route with a catch-all site.com/uri route definition.

Again... not tested, but something like this:

PHP Code:
//grab the locales and implode into regex string
$config = new \Config\App();
$locs implode("|"$config->supportedLocales);

$routes->add('('.$locs.')/uri''Controller::home');
$routes->add('uri''Controller::home'); 

If you go that route (pun intended), you might need to catch the segment to explicitly set the language using lang()

https://codeigniter4.github.io/userguide...=lang#lang

Don't know if this is the BEST solution, but it might be a path forward.
Designer, developer and Diet Dr. Pepper addict. Messing up PHP since <?= $when['year';] ?>
Reply


Messages In This Thread
RE: Localization duplicate page problem when locale set in routes - by jameslittle - 01-24-2020, 02:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB