Title: Change plugin locale
Last modified: March 4, 2022

---

# Change plugin locale

 *  Resolved [laszlogo](https://wordpress.org/support/users/laszlogo/)
 * (@laszlogo)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/change-plugin-locale/)
 * I’m trying to change the local of the **packingslip PDF** so that it matches 
   the website language instead of the user language. I see that inside the function`
   translations()` there is a filter for `plugin_locale` but i’m unable to get it
   to work.
 * This is where i’m stuck at:
 *     ```
       add_filter('plugin_locale', 'custom_plugin_locale', 10, 2);
   
       function custom_plugin_locale($locale, $textdomain)
       {
          if($textdomain == 'woocommerce-pdf-invoices-packing-slips'):
             $locale = 'de_DE';
          endif;
   
          return $locale;
       }
       ```
   
 * Could you please provide assistance, or even better a working example, on how
   to get it to work?
    -  This topic was modified 4 years, 3 months ago by [laszlogo](https://wordpress.org/support/users/laszlogo/).

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

 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/change-plugin-locale/#post-15425914)
 * Your code should work fine, where did you add it? To ensure it’s being loaded
   early enough, you may want to place it in a custom plugin (`mu-plugin` or regular
   plugin), or use [Code Snippets](https://wordpress.org/plugins/code-snippets/).
 * Here’s a cleaner version of your code (logic is the same):
 *     ```
       add_filter( 'plugin_locale', function ( $locale, $textdomain ) {
       	if( $textdomain == 'woocommerce-pdf-invoices-packing-slips' ) {
       		$locale = 'de_DE';
       	}
       	return $locale;
       }, 10, 2);
       ```
   
 *  Thread Starter [laszlogo](https://wordpress.org/support/users/laszlogo/)
 * (@laszlogo)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/change-plugin-locale/#post-15426027)
 * Hello Ewout,
 * Thanks for your quick reply.
    I tried to put the filter inside a `muplugins_loaded`
   action, but no succes:
 *     ```
       add_action('muplugins_loaded', 'custom_muplugins_loaded', 10);
   
       function custom_muplugins_loaded()
       {
          add_filter('plugin_locale', function($locale, $textdomain) {
             if($textdomain == 'woocommerce-pdf-invoices-packing-slips') {
                $locale = 'de_DE';
             }
   
             return $locale;
          }, 10, 2);
       }
       ```
   
 * You don’t by any change have a working example on how the change the locale of
   the **packingslip PDF**?
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/change-plugin-locale/#post-15426153)
 * You hooked to `muplugins_loaded`, but where did you place the code? If you didn’t
   place the code inside an actual `mu-plugin`, the action will never be executed
   anymore, because it already executed before your code was loaded. And if you 
   do place it inside an actual `mu-plugin`, there’s no need to delay until `muplugins_loaded`.
 * > You don’t by any change have a working example on how the change the locale
   > of the packingslip PDF?
 * The code from your original post is correct. I tested [my own code too](https://wordpress.org/support/topic/change-plugin-locale/#post-15425914)
   and it works as expected.
 * The problem is not with the code itself, it’s where you place it (loading too
   late). If you want to execute this before plugins are loaded, you have 3 options:
    1. place it inside a mu-plugin
    2. place it inside a regular (custom) plugin
    3. Use [Code Snippets](https://wordpress.org/plugins/code-snippets/)

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

The topic ‘Change plugin locale’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-pdf-invoices-packing-slips/assets/icon-256x256.
   png?rev=2189942)
 * [PDF Invoices & Packing Slips for WooCommerce](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/)

## Tags

 * [language](https://wordpress.org/support/topic-tag/language/)
 * [locale](https://wordpress.org/support/topic-tag/locale/)

 * 3 replies
 * 2 participants
 * Last reply from: [Ewout](https://wordpress.org/support/users/pomegranate/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/change-plugin-locale/#post-15426153)
 * Status: resolved