Is there a way like switch_to_blog()
for switching the language in WordPress.
Something like
global $locale
$currentLanguage = $locale;
switch_to_language('de_DE');
//do some action with german localisation
switch_to_language($currentLanguage);
Is this possible in general with WordPress?
So I finally found the solution. The function is called
load_textdomain()
This is how it’s done on my side. Keep in mind to define
LANGUAGE_PATH
and the language you would like to switch to in$new_language
.$your_domain
is the text domain of your plugin/themeTook a while to find this method in the core. Read more about that function on the codex site
I’m afraid you’re going to need a plugin for that. WordPress doesn’t do that out of the box.
WPML is usually the go-to multi-lingual plugin for WordPress, you should check it out 🙂