Title: WP_Translation_File::translate
Published: April 3, 2024
Last modified: May 20, 2026

---

# WP_Translation_File::translate( string $text ): false|string

## In this article

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

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

Translates a given string.

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

 `$text`stringrequired

String to translate.

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

 false|string Translation(s) on success, false otherwise.

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

    ```php
    public function translate( string $text ) {
    	if ( ! $this->parsed ) {
    		$this->parse_file();
    	}

    	return $this->entries[ $text ] ?? false;
    }
    ```

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

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

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

Parses the file.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_translation_file/translate/?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_file%2Ftranslate%2F)
before being able to contribute a note or feedback.