![]() |
Routing Advice - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Routing Advice (/showthread.php?tid=78355) |
Routing Advice - demyr - 01-07-2021 Hi all, I would like to ask your suggestions about an issue on which I am working: Imagine a website which has been prepared in a few languages, such as english (en), German (de), Italian (it) etc. By the way, English is the main/base one. If I set up the base url for the domain like mywebsite.com, there is no problem to switch to other languages such as : mywebsite.com/de or mywebsite.com/it. Because the site works for English as the base : mywebsite.com/about-us, mywebsite.com/blog-detail etc. But if I set up the base url for /en , then how can I route for the other languages? Because my pages are like these: Code: $routes->get('en', 'SiteEn::index_en'); As I don't know which language can the site owner sets in admin panel, I cannot fix it like : PHP Code: $routes->get('it/prodotti', 'SiteIt::categori_dei_prodotti_it'); On the contrary it must be aranged automaticaly: (What I want and need): PHP Code: $routes->get('-any-language-/-any-segment-', 'SiteOtherLangs::products_other_lang'); As I said if I set the base url for "/en" , it works like: mywebsite.com/en/it, not like mywebsite.com/it What would you suggest for this kind of problem and how do you handle this kind of problem? Regards RE: Routing Advice - nicojmb - 01-07-2021 (01-07-2021, 03:29 AM)demyr Wrote: Hi all, Hi, have you tried with the {locale} parameter? https://codeigniter4.github.io/userguide/outgoing/localization.html#in-routes RE: Routing Advice - demyr - 01-07-2021 @nicojmb Thanks for the suggestion but I believe it is not the thing I need. Because in documentation, for routes, it says PHP Code: $routes->get('{locale}/books', 'App\Books::index'); I can understand the "{locale}" part, but it is not "books" in each language. It is different. books for english pages, it is "libri" for italian or "kitaplar" for Turkish or "bucher" for German. ?? RE: Routing Advice - MrWhite - 01-07-2021 (01-07-2021, 01:18 PM)demyr Wrote: @nicojmb Thanks for the suggestion but I believe it is not the thing I need. Because in documentation, for routes, it says Router doesnt have this level of flexibility right now. the only way you can do this is using multiple routes for each language. for ex: PHP Code: $routes->get('en/books', 'App\Books::index'); RE: Routing Advice - demyr - 01-07-2021 So, we cannot talk about creating a complete dynamic and flexible cms for customers. They will need us for any kind of routing issue. Unfortunately using such systems like wix or godady things are much wiser for them. It's sad. Routing system must accept link parameters from the menu which is created by the customer or there must be a menu system like the one you can find within Joomla. |