Title: PO::export_entry
Published: April 25, 2014
Last modified: May 20, 2026

---

# PO::export_entry( Translation_Entry $entry ): string|false

## In this article

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

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

Builds a string from the entry for inclusion in PO file

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

 `$entry`[Translation_Entry](https://developer.wordpress.org/reference/classes/translation_entry/)
required

the entry to convert to po string.

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

 string|false PO-style formatted string for the entry or false if the entry is empty

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

    ```php
    public static function export_entry( $entry ) {
    	if ( null === $entry->singular || '' === $entry->singular ) {
    		return false;
    	}
    	$po = array();
    	if ( ! empty( $entry->translator_comments ) ) {
    		$po[] = PO::comment_block( $entry->translator_comments );
    	}
    	if ( ! empty( $entry->extracted_comments ) ) {
    		$po[] = PO::comment_block( $entry->extracted_comments, '.' );
    	}
    	if ( ! empty( $entry->references ) ) {
    		$po[] = PO::comment_block( implode( ' ', $entry->references ), ':' );
    	}
    	if ( ! empty( $entry->flags ) ) {
    		$po[] = PO::comment_block( implode( ', ', $entry->flags ), ',' );
    	}
    	if ( $entry->context ) {
    		$po[] = 'msgctxt ' . PO::poify( $entry->context );
    	}
    	$po[] = 'msgid ' . PO::poify( $entry->singular );
    	if ( ! $entry->is_plural ) {
    		$translation = empty( $entry->translations ) ? '' : $entry->translations[0];
    		$translation = PO::match_begin_and_end_newlines( $translation, $entry->singular );
    		$po[]        = 'msgstr ' . PO::poify( $translation );
    	} else {
    		$po[]         = 'msgid_plural ' . PO::poify( $entry->plural );
    		$translations = empty( $entry->translations ) ? array( '', '' ) : $entry->translations;
    		foreach ( $translations as $i => $translation ) {
    			$translation = PO::match_begin_and_end_newlines( $translation, $entry->plural );
    			$po[]        = "msgstr[$i] " . PO::poify( $translation );
    		}
    	}
    	return implode( "\n", $po );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/pomo/po.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/pomo/po.php#L217)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/pomo/po.php#L217-L251)

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

| Uses | Description | 
| [PO::match_begin_and_end_newlines()](https://developer.wordpress.org/reference/classes/po/match_begin_and_end_newlines/)`wp-includes/pomo/po.php` |  | 
| [PO::comment_block()](https://developer.wordpress.org/reference/classes/po/comment_block/)`wp-includes/pomo/po.php` |

Prepare a text as a comment — wraps the lines and prepends # and a special character to each line

  | 
| [PO::poify()](https://developer.wordpress.org/reference/classes/po/poify/)`wp-includes/pomo/po.php` |

Formats a string in PO-style

  |

## User Contributed Notes

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