Subdomains based localization |
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...egotiation 2) https://codeigniter4.github.io/userguide...#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.
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?). |
Welcome Guest, Not a member yet? Register Sign In |