Welcome Guest, Not a member yet? Register   Sign In
{locale} placeholder in routes
#4

(06-09-2022, 01:56 AM)webdeveloper Wrote: One important difference is that your locale have to be placed always on the first place of URL. 

This wont work for you:

PHP Code:
$routes->group('translations', function ($routes) {
  $routes->group('{locale}', function ($routes) {
      $routes->get('/''Translations::index');
  });
}); 

You're right, I didn't think it could be a problem as all my routes are configured with the locale as the first segment of the URL.

(06-09-2022, 01:56 AM)webdeveloper Wrote: Why did you remove second part of locale? This is used in most cases for variants of language e.g. "en-US". I consider this language fallback behaviour as useful

Quote:So, if you are using the locale fr-CA, then a localized message will first be sought in Language/fr/CA, then in Language/fr, and finally in Language/en.

I remove the second part of the locale because it doesn't really make a difference. At least not in my case. My blog is in French and in English. So if the locale detected is en-US, en-UK or any other en-xx it redirects to the English version of the blog. Same thing for fr-FR, fr-CA, etc, it goes to the French version. Anything else goes to the default locale, with is English.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply


Messages In This Thread
{locale} placeholder in routes - by webdeveloper - 06-08-2022, 06:23 AM
RE: {locale} placeholder in routes - by includebeer - 06-09-2022, 02:44 PM
RE: {locale} placeholder in routes - by InsiteFX - 06-09-2022, 11:57 PM
RE: {locale} placeholder in routes - by kenjis - 06-10-2022, 06:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB