07-27-2023, 12:59 AM
I config the multi-language setting dynamically using the `locale` filter. Which fetch the sub-domain name to determine the language.
function load_custom_language($locale) {
// get the locale code according to the sub-domain name.
// en.mysite.com => return `en`
// zh.mysite.com => return `zh_CN`
// tw.mysite.com => return `zh_TW`
// etc..
}
add_filter('locale', 'load_custom_language');
---
That works for the index page, but when I redirect to another page, because of the settings of `home` and `siteurl`, it always redirects my site to the original one (`www.mysite.com`).
So I'm curious to find a dynamic way to filter the `home` and `siteurl` according to the request, because I might use more than one sub-domain for mysite and I have only one settings for the two settings.
function load_custom_language($locale) {
// get the locale code according to the sub-domain name.
// en.mysite.com => return `en`
// zh.mysite.com => return `zh_CN`
// tw.mysite.com => return `zh_TW`
// etc..
}
add_filter('locale', 'load_custom_language');
---
That works for the index page, but when I redirect to another page, because of the settings of `home` and `siteurl`, it always redirects my site to the original one (`www.mysite.com`).
So I'm curious to find a dynamic way to filter the `home` and `siteurl` according to the request, because I might use more than one sub-domain for mysite and I have only one settings for the two settings.