I have a custom MU plugin mup for which I've coded some custom admin pages. For these and all of their related strings; I've successfully created the according .mo files and placed them all both in:

wp-content/languages/plugins/ wp-content/mu-plugins/mup/languages/

My text domain is loaded in the main plugin file of mup via (this actually fails if called on a page using the default language, no idea why, but this is another issue):

        function() {
          $check = load_muplugin_textdomain( 'mup', 'mup/languages' );
          if (! $check) {echo "ohoh";}

Let's say you load an admin page X, for which you've localized all the contents via __() functions. You then go to the user account edits in the wp admin, and change the language of your user, let's say from english to german. You then go back to your admin page X, and at first sight it all appears to be in german, and not in english anymore, so the language switch worked ok. BUT, as soon as you make a client - server request on that page, e.g. via AJAX, which is part of your mup plugin: Surprize, every localized string coming from the server via __() again appears in english, and not in german! Also, when I echo out the current locale via global $locale; echo $locale; I weirdly get EN_GB, although the entire page content is shown in german. WTH is going on...?

  • This is the same question you asked about in 2 other questions but phrased in the context of AJAX. If your textdomain fails to load then it is unreasonable to expect other things that require it to be loaded to work. You should focus on one aspect of the problem at a time
    – Tom J Nowell
    Aug 14, 2021 at 2:47
  • No it is not the same, because it gets triggered as soon as I switch the admin user's language. Before that it all works perfectly well! I'm sorry Tom but you keep commenting that my answer is the same as another one; yet it's always about something really different, as stated in my question. I'm also digging and researching all this time; just thinking that it may be due to some hooking I forgot of my custom plugin to the admin user language switch; for plugin localizations to work properly, if that's even necessary. Hence the reason of this question here.
    – DevelJoe
    Aug 14, 2021 at 2:50
  • And thanks for your continuous reply; so you think this has nothing to do with admin user language switches? If you're sure about that we can close this question; no problem.
    – DevelJoe
    Aug 14, 2021 at 2:54
  • I'm confused, you've just described your other question in terms that exactly match this question. Please be more specific and clear. What do you mean by admin user language switches? All AJAX requests or just your plugins AJAX requests? Simplify things, and describe things as they are, not as you theorise them to be
    – Tom J Nowell
    Aug 14, 2021 at 2:57
  • Yes because the problem A is maybe linked with problem B, but I don't know if yes or not, which is why I'm asking. All I know is that I can trigger problems / errors in relation to loading the text domain and switching the admin language; but I don't know which error causes which problems (if only...). Could we may talk about this in the stack chat real quick?
    – DevelJoe
    Aug 14, 2021 at 3:00


Browse other questions tagged or ask your own question.