localization – i18n: How do I load translations for a language specified in the request?
So I know how __, _e etc. work. They fetch the translations on the basis of the site language selected in the General settings. My challenge is slightly different: I want to provide the ability to specify the language dynamically, let’s say in the request as a
lang parameter. I want this
lang parameter to be used to determine the translation not the site language. In the twentytwentythree theme (the theme I’m testing with but not limited to only this theme), all the static texts are loaded before the
template_include hooks are called (and I can set the language in those hooks only) so it looks like this cannot be done.
Leave an answer