Title: WP_Translation_Controller::load_file
Published: April 3, 2024
Last modified: August 20, 2026

---

# WP_Translation_Controller::load_file( string $translation_file, string $textdomain = ‘default’, string $locale = null ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_translation_controller/load_file/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_translation_controller/load_file/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_translation_controller/load_file/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_translation_controller/load_file/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_translation_controller/load_file/?output_format=md#changelog)

Loads a translation file for a given text domain.

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

 `$translation_file`stringrequired

Translation file.

`$textdomain`stringoptional

Text domain. Default `'default'`.

Default:`'default'`

`$locale`stringoptional

Locale. Default current locale.

Default:`null`

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

 bool True on success, false otherwise.

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

    ```php
    public function load_file( string $translation_file, string $textdomain = 'default', ?string $locale = null ): bool {
    	if ( null === $locale ) {
    		$locale = $this->current_locale;
    	}

    	$translation_file = realpath( $translation_file );

    	if ( false === $translation_file ) {
    		return false;
    	}

    	if (
    		isset( $this->loaded_files[ $translation_file ][ $locale ][ $textdomain ] ) &&
    		false !== $this->loaded_files[ $translation_file ][ $locale ][ $textdomain ]
    	) {
    		return null === $this->loaded_files[ $translation_file ][ $locale ][ $textdomain ]->error();
    	}

    	if (
    		isset( $this->loaded_files[ $translation_file ][ $locale ] ) &&
    		array() !== $this->loaded_files[ $translation_file ][ $locale ]
    	) {
    		$moe = reset( $this->loaded_files[ $translation_file ][ $locale ] );
    	} else {
    		$moe = WP_Translation_File::create( $translation_file );
    		if ( false === $moe || null !== $moe->error() ) {
    			$moe = false;
    		}
    	}

    	$this->loaded_files[ $translation_file ][ $locale ][ $textdomain ] = $moe;

    	if ( ! $moe instanceof WP_Translation_File ) {
    		return false;
    	}

    	if ( ! isset( $this->loaded_translations[ $locale ][ $textdomain ] ) ) {
    		$this->loaded_translations[ $locale ][ $textdomain ] = array();
    	}

    	$this->loaded_translations[ $locale ][ $textdomain ][] = $moe;

    	return true;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/l10n/class-wp-translation-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/l10n/class-wp-translation-controller.php#L101)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/l10n/class-wp-translation-controller.php#L101-L144)

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

| Uses | Description | 
| [WP_Translation_File::create()](https://developer.wordpress.org/reference/classes/wp_translation_file/create/)`wp-includes/l10n/class-wp-translation-file.php` |

Creates a new [WP_Translation_File](https://developer.wordpress.org/reference/classes/wp_translation_file/) instance for a given file.

  |

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

| Version | Description | 
| [6.5.0](https://developer.wordpress.org/reference/since/6.5.0/) | Introduced. |

## User Contributed Notes

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