Subdomains based localization - 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: Subdomains based localization (/showthread.php?tid=75034) |
Subdomains based localization - ARAmiss - 12-11-2019 Hello. I have main domain.com and its subdomains en.domain.com, fr.domain.com, de.domain.com and others. I need to build localization versions of main domain on subdomains. How can i do it? There are only 2 codeigniter 4 official ways in docs: 1) https://codeigniter4.github.io/userguide/outgoing/localization.html#content-negotiation 2) https://codeigniter4.github.io/userguide/outgoing/localization.html#in-routes The first method has nothing to do with subdomains. The second method based on zero uri segment and it's also not my case. RE: Subdomains based localization - ARAmiss - 12-12-2019 The simplest way to define language locale is to set it in BaseController: Code: $domain = $_SERVER['HTTP_HOST']; It's working. But there must be more than one action "set locale". For example, "get all locales", "get locale from cookie", etc. So we need some Class. Questions: 1) What is the best way to implement this: library, model or other? What do you advise? 2) Where the best to set locale? I think not Routes.php, and not App.php (maybe?). |