Title: unload_textdomain
Published: April 25, 2014
Last modified: February 24, 2026

---

# unload_textdomain( string $domain, bool $reloadable = false ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#wp--skip-link--target)

Unloads translations for a text domain.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#parameters)󠁿

 `$domain`stringrequired

Text domain. Unique identifier for retrieving translated strings.

`$reloadable`booloptional

Whether the text domain can be loaded just-in-time again.

Default:`false`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#return)󠁿

 bool Whether textdomain was unloaded.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#source)󠁿

    ```php
    function unload_textdomain( $domain, $reloadable = false ) {
    	global $l10n, $l10n_unloaded;

    	$l10n_unloaded = (array) $l10n_unloaded;

    	/**
    	 * Filters whether to override the text domain unloading.
    	 *
    	 * @since 3.0.0
    	 * @since 6.1.0 Added the `$reloadable` parameter.
    	 *
    	 * @param bool   $override   Whether to override the text domain unloading. Default false.
    	 * @param string $domain     Text domain. Unique identifier for retrieving translated strings.
    	 * @param bool   $reloadable Whether the text domain can be loaded just-in-time again.
    	 */
    	$plugin_override = apply_filters( 'override_unload_textdomain', false, $domain, $reloadable );

    	if ( $plugin_override ) {
    		if ( ! $reloadable ) {
    			$l10n_unloaded[ $domain ] = true;
    		}

    		return true;
    	}

    	/**
    	 * Fires before the text domain is unloaded.
    	 *
    	 * @since 3.0.0
    	 * @since 6.1.0 Added the `$reloadable` parameter.
    	 *
    	 * @param string $domain     Text domain. Unique identifier for retrieving translated strings.
    	 * @param bool   $reloadable Whether the text domain can be loaded just-in-time again.
    	 */
    	do_action( 'unload_textdomain', $domain, $reloadable );

    	// Since multiple locales are supported, reloadable text domains don't actually need to be unloaded.
    	if ( ! $reloadable ) {
    		WP_Translation_Controller::get_instance()->unload_textdomain( $domain );
    	}

    	if ( isset( $l10n[ $domain ] ) ) {
    		if ( $l10n[ $domain ] instanceof NOOP_Translations ) {
    			unset( $l10n[ $domain ] );

    			return false;
    		}

    		unset( $l10n[ $domain ] );

    		if ( ! $reloadable ) {
    			$l10n_unloaded[ $domain ] = true;
    		}

    		return true;
    	}

    	return false;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/l10n.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/l10n.php#L879)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/l10n.php#L879-L937)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#hooks)󠁿

 [apply_filters( ‘override_unload_textdomain’, bool $override, string $domain, bool $reloadable )](https://developer.wordpress.org/reference/hooks/override_unload_textdomain/)

Filters whether to override the text domain unloading.

 [do_action( ‘unload_textdomain’, string $domain, bool $reloadable )](https://developer.wordpress.org/reference/hooks/unload_textdomain/)

Fires before the text domain is unloaded.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Translation_Controller::get_instance()](https://developer.wordpress.org/reference/classes/wp_translation_controller/get_instance/)`wp-includes/l10n/class-wp-translation-controller.php` |

Utility method to retrieve the main instance of the class.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#)

| Used by | Description | 
| [WP_Locale_Switcher::load_translations()](https://developer.wordpress.org/reference/classes/wp_locale_switcher/load_translations/)`wp-includes/class-wp-locale-switcher.php` |

Load translations for a given locale.

  | 
| [load_default_textdomain()](https://developer.wordpress.org/reference/functions/load_default_textdomain/)`wp-includes/l10n.php` |

Loads default translated strings based on locale.

  | 
| [wp_timezone_choice()](https://developer.wordpress.org/reference/functions/wp_timezone_choice/)`wp-includes/functions.php` |

Gives a nicely-formatted list of timezone strings.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.1.0](https://developer.wordpress.org/reference/since/6.1.0/) | Added the `$reloadable` parameter. | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/unload_textdomain/?output_format=md#comment-content-4495)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  5 years ago  ](https://developer.wordpress.org/reference/functions/unload_textdomain/#comment-4495)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funload_textdomain%2F%23comment-4495)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funload_textdomain%2F%23comment-4495)
 4. In case you need to prevent a text domain from unloading, the `override_unload_textdomain`
    filter is called before attempting to unload the text domain.
 5.     ```php
        add_filter( 'override_unload_textdomain', 'myplugin_override_unload_textdomain' );
        function myplugin_override_unload_textdomain( $override, $domain ) {
        	if ( $domain === 'my-domain' ) {
        		// Prevents WordPress from unloading this text domain
        		$override = true;
        	}
        	return $override;
        }
        ```
    
 6. Immediately before unloading a text domain, the `unload_textdomain` action is called
    to notify WordPress that the text domain is being unloaded.
 7.     ```php
        add_action( 'unload_textdomain', 'myplugin_unload_textdomain' );
        function myplugin_unload_textdomain( $domain ) {
        	// add code here to handle the unloading the text domain
        }
        ```
    
 8.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funload_textdomain%2F%3Freplytocom%3D4495%23feedback-editor-4495)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funload_textdomain%2F)
before being able to contribute a note or feedback.