Welcome Guest, Not a member yet? Register   Sign In
Allow for route matching without need for {locale} placeholder for localized URI's
#6

It seems that those of you who replied did not understand my feature request.

I wasn't asking for information on how to setup & use localized URLS; I already know how to do this. I DO understand how to use '{locale}' placeholder within the routes config (I even mentioned this in my post). I also wasn't referring to the use of session cookies (I don't even understand what that has to do with this request).

The goal of my request was simply to suggest making URI-based locale handling more transparent & easier to use within CI4 by removing the necessity of including the {locale} placeholder in every single route which might be subject to localization, and to remove the locale segment from CI's built-in URI libraries/functions.

Why? Well, if a site has been built & configured to implement URI-based localization, it's UNDERSTOOD that there *MIGHT* be a locale string present in the first segment of the request URI, so there's really no need to include this segment within CI's internal routing & URI handling features; it will only complicate any further processing of the request routes & URI. CI should just handle the presence of a URI locale segment auto-magically and then allow the user to handle things accordingly.

Another example:
Assuming that I've setup my site to handle localized URL's,  with a request for either of the following two URL's...

https://mysite.org/foo/bar/baz
https://mysite.org/en-us/foo/bar/baz

...the only URI segments of IMPORTANCE would be '/foo/bar/baz', and NOT the optional locale string '/en-us/'. It shouldn't be necessary to include the {locale} placeholder in a route for '/foo/bar/baz' in order to match either of these URI's, and it subsequently also doesn't need to be included in CI's request URI object.

Again, having to do something like "$routes->get('({locale}/)?foo/bar/baz', 'Foo::bar/baz')" is UNNECESSARY. 
The single, simple route of "$routes->get('/foo/bar/baz', 'Foo::bar/baz')" should suffice for both URI's.

IOW, I shouldn't have to care if the locale segment was present in the original URI request. The framework should just handle it and allow me to check for its presence by some other means (via something like '$request->hasLocale()' or '$request->getUriLocale() should be sufficient).

All of this seems fairly obvious & self-explanatory, but apparently my explanation isn't being grokked.

In any case, I'm now going to be forced to build this functionality myself, which means having to dig into CI4's system libraries, which was something I wanted to avoid  before attempting to bring it up as a feature request. However, if the CI community doesn't appreciate or understand the value of this functionality, then I guess I'm on my own.
Reply


Messages In This Thread
RE: Allow for route matching without need for {locale} placeholder for localized URI's - by csrf - 12-30-2023, 06:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB