title: Wordpress: How to override plugin translation through theme folder?
body: <p>I have plugins <code>.mo</code> translations files in the <code>wp-content/languages/plugins</code> folder,  I would like to add my custom translation for a specific plugin and put the <code>.mo</code> file into the <code>wp-content/themes/my_theme</code> folder, so the new <code>.mo</code> file which in the theme folder overrides the original <code>.mo</code> which in the plugins languages folder.</p>
  
  <p><strong>Solved: <a href="https://docs.woocommerce.com/document/woocommerce-localization/" rel="nofollow noreferrer">translation upgrade safe</a></strong>:</p>
  
  <pre><code>add_filter( 'load_textdomain_mofile', 'load_custom_plugin_translation_file', 10, 2 );
  
  /*
   * Replace 'textdomain' with your plugin's textdomain. e.g. 'woocommerce'. 
   * File to be named, for example, yourtranslationfile-en_GB.mo
   * File to be placed, for example, wp-content/lanaguages/textdomain/yourtranslationfile-en_GB.mo
   */
  function load_custom_plugin_translation_file( $mofile, $domain ) {
    if ( 'woocommerce' === $domain ) {
      $mofile = get_stylesheet_directory() . '/languages/woocommerce-' . get_locale() . '.mo';
    }
    return $mofile;
  }
  </code></pre>