Title: MU-Plugins: No strings can be extracted from source code
Last modified: August 5, 2022

---

# MU-Plugins: No strings can be extracted from source code

 *  Resolved [SoN9ne](https://wordpress.org/support/users/son9ne/)
 * (@son9ne)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/)
 * Hello,
 * I am running into an issue with mu-plugins.
 * I am getting:
 * > No strings can be extracted from source code
 * Everything looks good and the POT file does exist as well as the PO and MO files.
 * The issue appears to be due to no mu-plugins logic in the `Loco_gettext_Extraction`
   object.
 * mu-plugins have a proxy loader file that is used to load the plugin properly.
   WordPress shows an example of how this works [here](https://wordpress.org/support/article/must-use-plugins/).
 * The problem seems to be due to the proxy loader not having any gettext inside
   it, all it does is load the actual plugin main file which does. Seems it only
   checks the initial file and I haven’t looked too deep into this yet.
 * Would it be possible to add mu-plugin support? mu-plugins are a core component
   of WP and I would expect them to be supported properly. I wouldn’t mind pushing
   a PR but I don’t see a public repo other than a mirror that just sends me here
   and clearly states PR are not welcome.
 * > This is not a collaborative project and there are no resources available for
   > examining pull requests.
 * My Debug shows (this is all accurate and correct):
 * >  Configuration auto-detected from file headers
   >  WordPress says primary text domain is “olymp-wp-core”
   >  Primary domain path declared by author as “/olymp-wp-core/languages”
   >  1 domain path[s] configured for “olymp-wp-core” -> [“olymp-wp-core/languages”]
   >  Template file for “olymp-wp-core” exists at “olymp-wp-core/languages/olymp-
   > wp-core.pot”
   >  No strings can be extracted from source code
   > Current configuration as XML:
 *     ```
       <?xml version="1.0" encoding="utf-8"?>
       <bundle name="Olympusat WordPress Core">
         <domain name="olymp-wp-core">
           <project name="Olympusat WordPress Core" slug="olymp-wp-core">
             <source>
               <file>1-olymp-wp-core.php</file>
             </source>
             <target>
               <directory>olymp-wp-core/languages</directory>
             </target>
             <template>
               <file>olymp-wp-core/languages/olymp-wp-core.pot</file>
             </template>
           </project>
         </domain>
       </bundle>
       ```
   
 * This is relative to the `mu-plugins` directory
 * Thanks for your time.
    -  This topic was modified 3 years, 10 months ago by [SoN9ne](https://wordpress.org/support/users/son9ne/).
    -  This topic was modified 3 years, 10 months ago by [SoN9ne](https://wordpress.org/support/users/son9ne/).
    -  This topic was modified 3 years, 10 months ago by [SoN9ne](https://wordpress.org/support/users/son9ne/).
    -  This topic was modified 3 years, 10 months ago by [SoN9ne](https://wordpress.org/support/users/son9ne/).

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Thread Starter [SoN9ne](https://wordpress.org/support/users/son9ne/)
 * (@son9ne)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15892596)
 * nevermind, seems I messed up the text doamin…
    -  This reply was modified 3 years, 10 months ago by [SoN9ne](https://wordpress.org/support/users/son9ne/).
 *  Thread Starter [SoN9ne](https://wordpress.org/support/users/son9ne/)
 * (@son9ne)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15898374)
 * Actually, even with fixing the text domain, it still says
 * > No strings can be extracted from source code
 * I am able to do the string translations in my PO files but it’s not seeing any
   changes in my code.
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15900246)
 * MU-plugins are single files by convention. If you have a folder of source files
   which you auto-load from the stub file then you will have to **configure your
   bundle** to scan this directory.
 * See [https://localise.biz/wordpress/plugin/manual/bundle-config](https://localise.biz/wordpress/plugin/manual/bundle-config)
   and note the “Source file paths” option.
 *  Thread Starter [SoN9ne](https://wordpress.org/support/users/son9ne/)
 * (@son9ne)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15901515)
 * Thanks for your response.
 * It seems mu-plugin support is minimal.
 * WordPress recommends using a proxy loader which then loads the mu-plugin from
   a folder which acts like a normal plugin.
 * This is implemented as:
 *     ```
       mu-plugins
       ├── 1-olymp-wp-core.php
       ├── 2-oly-ott-core.php
       ├── 3-oly-ott-features.php
       ├── olymp-wp-core
       ├── oly-ott-core
       └── oly-ott-features
       ```
   
 * Whereas every folder is a proper WordPress plugin.
 * Using `loco.xml` for mu-plugins is not possible unless I build a `loco.xml` in
   the `mu-plugins` folder and configure them all in it (not ideal at all). It also
   seems that adding “Source File Paths”, it still gives:
 * > No strings can be extracted from source code
 * I even tried configuring it in the backend interface and it still never seems
   to work.
 * I tried with using the main directory:
 *     ```
       <source>
           <directory>oly-ott-core</directory>
       </source>
       ```
   
 * Then I also tried declaring every directory that has translatable files but it
   just doesn’t seem to work.
 * I then tried to specify a single file and still nothing. I tried relative at 
   first then even tried absolute path (I know it’s not recommended, just trying
   to get this to work) and still nothing.
 * Do you have any suggestions?
 * There are 2 design patterns most commonly used with mu-plugins:
 * 1. Single PHP file in the mu-plugins directory that is the simple plugin
    2. 
   A proxy loader that loads the plugin from a sub-directory in mu-plugins (WordPress
   recommended way).
 * It seems that the first way is supported but I cannot prove this. The second 
   way would be nice to have supported as this is the recommended way by WordPress.
 * This is the way I was able to add mu-plugins support to Polylang for the `wpml-
   config.xml` (awaiting review to have it put into Polylang):
 *     ```
               // Mu-Plugins
               // Search for top level wpml-config.xml, not ideal or best practice but these exist.
               if (file_exists($file = WPMU_PLUGIN_DIR . '/wpml-config.xml')) {
                   $files[basename(WPMU_PLUGIN_DIR)] = WPMU_PLUGIN_DIR . '/wpml-config.xml';
               }
               // Search for proxy loaded mu-plugins
               foreach (new DirectoryIterator(WPMU_PLUGIN_DIR) as $file_info) {
                   if ($file_info->isDot()) continue;
                   // Check if a directory (proxy loader method)
                   if ($file_info->isDir()) {
                       if (file_exists($file = $file_info->getPathname() . '/wpml-config.xml')) {
                           $files[$file_info->getFilename()] = $file;
                       }
                   }
               }
       ```
   
 * Perhaps this is worth checking out for this plugin too?
 * I really like the work done on this plugin and I would like to have my mu-plugins
   integrated into it properly. I hope this is possible to get done.
 * Thanks
    -  This reply was modified 3 years, 10 months ago by [SoN9ne](https://wordpress.org/support/users/son9ne/).
    -  This reply was modified 3 years, 10 months ago by [SoN9ne](https://wordpress.org/support/users/son9ne/).
    -  This reply was modified 3 years, 10 months ago by [SoN9ne](https://wordpress.org/support/users/son9ne/).
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15901549)
 * I understand the autoloading design pattern.
 * I have no problem configuring directories inside mu-plugins for including in 
   source string extraction. I did this via the backend interface. If you set the
   correct information (including the text domain) it will work.
 *  Thread Starter [SoN9ne](https://wordpress.org/support/users/son9ne/)
 * (@son9ne)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15901607)
 * Not sure how this isn’t correct, am I missing something?
 *     ```
       <?xml version="1.0" encoding="utf-8"?>
       <bundle name="Oly OTT Core">
           <domain name="oly-ott-core">
               <project name="Oly OTT Core" slug="oly-ott-core">
                   <source>
                       <directory>oly-ott-core/views</directory>
                       <file>oly-ott-core/views/olyrecommends-sync.php</file>
                   </source>
                   <target>
                       <directory>oly-ott-core/languages</directory>
                   </target>
                   <template>
                       <file>oly-ott-core/languages/oly-ott-core.pot</file>
                   </template>
               </project>
           </domain>
       </bundle>
       ```
   
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15901625)
 * I can’t know if your config is correct without the files you’re configuring. 
   If you post them I’ll look.
 *  Thread Starter [SoN9ne](https://wordpress.org/support/users/son9ne/)
 * (@son9ne)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15901661)
 * Thank you.
 * `oly-ott-core` folder structure in the `mu-plugins`:
 *     ```
       oly-ott-core
       ├── assets
       ├── index.php
       ├── js
       ├── languages
       │   ├── oly-ott-core-en_US.mo
       │   ├── oly-ott-core-en_US.po
       │   ├── oly-ott-core-es_ES.mo
       │   ├── oly-ott-core-es_ES.po
       │   └── oly-ott-core.pot
       ├── lib
       ├── metabox-views
       ├── oly-ott-core.php
       ├── readme.md
       ├── templates
       ├── Third-Party
       ├── views
       │   ├── olyrecommends-sync.php
       │   ├── user-profile.php
       │   └── woocommerce-pricing-updater.php
       └── wpml-config.xml
       ```
   
 * Plugin Header
 *     ```
       /**
        * Plugin Name: Oly OTT Core
        * Description: Core resources for Oly OTT Platform
        * Version: 1.7.4
        * Text Domain: oly-ott-core
        */
       ```
   
 * This should be enough to see the text domain and the folder structure.
 * The `olyrecommends-sync.php` is using standard WP i18n:
 * `_e('Translatable String', 'oly-ott-core')`
    -  This reply was modified 3 years, 10 months ago by [SoN9ne](https://wordpress.org/support/users/son9ne/).
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15901712)
 * No issue for me here:
 * > [View post on imgur.com](https://imgur.com/a/EdLu1y9)
 * This using your exact XML config and the file names and content you’ve posted.
 * Whatever you’re doing differently from me, it is not present in your description.
 *  Thread Starter [SoN9ne](https://wordpress.org/support/users/son9ne/)
 * (@son9ne)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15901757)
 * Thank you for your response.
 * Could you please check the Debug tab and see if you see the message:
 * > No strings can be extracted from source code
 * I never checked past seeing that error.
 * I just tested now and I am actually able to get the translations to work. So 
   perhaps this is working but that error is not accurate.
 * It would be nice to be able to use the `loco.xml` in the sub-folders but this
   works for my needs.
 * Thank you so much for your time. I truly appreciate it. Thank you
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15901775)
 * Yes, you’re right. The debug tab seems to have a problem. Off the top of my head
   I don’t know why. I’ll have to look into that and fix. But you’ve got extraction
   working. Good news.
 *  Thread Starter [SoN9ne](https://wordpress.org/support/users/son9ne/)
 * (@son9ne)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15901780)
 * Awesome, I will close this ticket then. Seems this was all a false-flag due to
   that error but it is working. Thanks again!

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘MU-Plugins: No strings can be extracted from source code’ is closed to
new replies.

 * ![](https://ps.w.org/loco-translate/assets/icon-256x256.png?rev=1000676)
 * [Loco Translate](https://wordpress.org/plugins/loco-translate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/loco-translate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/loco-translate/)
 * [Active Topics](https://wordpress.org/support/plugin/loco-translate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/loco-translate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/loco-translate/reviews/)

## Tags

 * [mu-plugins](https://wordpress.org/support/topic-tag/mu-plugins/)

 * 12 replies
 * 2 participants
 * Last reply from: [SoN9ne](https://wordpress.org/support/users/son9ne/)
 * Last activity: [3 years, 10 months ago](https://wordpress.org/support/topic/mu-plugins-no-strings-can-be-extracted-from-source-code/#post-15901780)
 * Status: resolved